2013-10-22 7 views
5

나는 Yeoman Generator를 처음 만들었습니다. CMS가 포함 된 외부 zip을 다운로드하고 루트에서 압축을 풀고 싶습니다. this thread에 따르면 이것이 가능해야합니다. 아직 구현되지 않았습니까? 내 발전기에 복사하지 않으면 무엇이 필요합니까?yeoman 생성기로 zip 다운로드

나는 발전기 제너레이터를 실행했으며 제 기본적인 발전기를 가동 시켰습니다. 지금까지 내 코드입니다.

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의 인수는 '소스'및 '대상'경로 (로컬)이므로 대상을 파일을 끝내려는 위치로 바꿀 수 있습니다. 'repo'는 url = 'https://github.com/'+ [username, repo, 'archive', branch] .join ('/') +를 구성하는 데 사용되는 저장소 이름이어야합니다. '.tar.gz'; ' –