4
我正在寫一個咕task任務,我想以編程方式安裝依賴項。但是,我似乎無法弄清楚如何使用他們的API。以編程方式與bower一起安裝?
這只是正常,但解析響應是脆弱,因爲它使用CLI:
grunt.util.spawn({
cmd: 'bower',
args: ['install', '--save', '[email protected]:foo/bar.git']
}, function(none, message) {
grunt.log.writeln(message);
});
這不起作用:
bower.commands.install.line(['--save', '[email protected]:foo/bar.git'])
.on('end', function(data) {
grunt.log.writeln(data);
done();
})
.on('err', function(err) {
grunt.log.fail(err);
done();
});
我收到以下錯誤:
$ grunt my-task
Running "my-task:default_options" (my-task) task
Fatal error: Could not find any dependencies
什麼是正確的方法來做到這一點?