2013-10-22 6 views
5

私は最初のYeomanジェネレータを作成しています。私は、CMSを含む外部zipをダウンロードし、それをルートに解凍したいと思います。 this threadによれば、これが可能であるはずです。まだ実装されていないのですか?私が発電機にコピーしなければならないものは何ですか?ヨモマンジェネレータでジップをダウンロード

私はジェネレータジェネレータを実行して、私の基本ジェネレータをアップしました。これはこれまでの私のコードです。

Generator.prototype.getVersion = function getVersion() { 
    var cb = this.async() 
    , self = this 

    this.log.writeln('Downloading Umbraco version 6.1.6') 
    this.download('http://our.umbraco.org/ReleaseDownload?id=92348', '.'); 
} 

これは、「モジュールがダウンロードできません」というエラーが表示されます。正しい構文は何ですか?

+0

こんにちは。私の答えを受け入れるのは気になりますか?ありがとう。 –

答えて

6

少し調べました。

There are two methods to download something with yeoman...

/** 
* Download a string or an array of files to a given destination. 
* 
* @param {String|Array} url 
* @param {String} destination 
* @param {Function} cb 
*/ 

this.fetch(url, destination, cb) 

/** 
* Fetch a string or an array of archives and extract it/them to a given 
* destination. 
* 
* @param {String|Array} archive 
* @param {String} destination 
* @param {Function} cb 
*/ 

this.extract(archive, destination, cb) 

何かが間違っていた場合、コールバックはエラーを渡します。

There's also a method to download packages from Github.

/** 
* Remotely fetch a package from github (or an archive), store this into a _cache 
* folder, and provide a "remote" object as a facade API to ourself (part of 
* generator API, copy, template, directory). It's possible to remove local cache, 
* and force a new remote fetch of the package. 
* 
* ### Examples: 
* 
*  this.remote('user', 'repo', function(err, remote) { 
*  remote.copy('.', 'vendors/user-repo'); 
*  }); 
* 
*  this.remote('user', 'repo', 'branch', function(err, remote) { 
*  remote.copy('.', 'vendors/user-repo'); 
*  }); 
* 
*  this.remote('http://foo.com/bar.zip', function(err, remote) { 
*  remote.copy('.', 'vendors/user-repo'); 
*  }); 
* 
* When fetching from Github 
* @param {String} username 
* @param {String} repo 
* @param {String} branch 
* @param {Function} cb 
* @param {Boolean} refresh 
* 
* @also 
* When fetching an archive 
* @param {String} url 
* @param {Function} cb 
* @param {Boolean} refresh 
*/ 
+0

ヘルプが必要です! 'repo'と' vendors/user-repo'は何を表していますか? 'repo'は実際の'リポジトリ 'への' URL'パス全体ですか? – Daggerhunt

+0

@Daggerhunt:remote.copyの引数は 'source'と 'destination'のパスです(ローカル)。そのため、ファイルの最終的な場所を変更するだけです。 url = 'https://github.com/' + [username、repo、 'archive'、branch] .join( '/')+ 'リポジトリ'は、リポジトリ名である必要があります。 '.tar.gz'; ' –

関連する問題