grunt-init과 동시에, npm install & bower install도 해 버린다
3043 단어 grunt
그 후.
그런 이유로 자신은 이런 스크립트를 쓰고 npm install과 함께 bower install도 단번에 해주도록 합니다.
(또한이 스크립트는 async에 의존하기 때문에 사용하기 전에 npm install하십시오 w)
사용하는 방법
이 녀석을 grunt-template의/lib에 넣고 template.js에서 이런 느낌으로 쓰면 길입니다.
(↓ 많이 생략하고 있습니다. 정확한 코드는 github쪽으로보십시오)
var shellLines = require('./lib/shellLines');
exports.template = function (grunt, init, done) {
init.process( {}, [
init.prompt('name'),
init.prompt('description')
], function(err, props) {
// write package.json
init.writePackageJSON('package.json', pkg);
// write bower.json
init.writePackageJSON('bower.json', bower);
// npm install & bower install
shellLines([{
command: 'npm install',
message: 'Installing npm dependencies'
},{
command: 'bower install',
message: 'Installing bower dependencies'
}], done);
});
};
마지막 부분, 이번에 만든
npm install
라는 함수에,실행할 명령 목록, (& 실행하는 동안 표시하려는 메시지)
배열로 전달하면 하나씩 실행됩니다. 모두 끝나면 done을 실행.
덧붙여서
shellLines
그리고 bower.json도 쓸 수 있다는 것도 수수하게 포인트입니다.출력
수수함을 고집하고 있는 것은, 출력의 형식입니다.
↑와 같은 간지로, 다른 「Writing …
경과를 따라가면서 메시지가 나오게 되어 있습니다.
요약
이런 식으로,
init.writePackageJSON
이나 npm install
이외의 shell 커멘드도, grunt-init내에서 단번에 실행할 수 있게 되어 있으므로,원한다면 삼가 해주십시오.
bower install
에 건네주는 배열에, 설정을 더하면 됩니다.(
shellLines
라든지 하는 것도 좋네요.)2013/08/26 추가
shellLines를 npm화했습니다.
grunt build
그리고 ↑의 샘플 코드와 같이 사용해 주시면!Reference
이 문제에 관하여(grunt-init과 동시에, npm install & bower install도 해 버린다), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/fnobi/items/68074616035f20cd23e4텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)