Programmatically install with a gazebo?

I am writing a grunt task and I want to set the dependency programmatically. However, I cannot figure out how to use their API.

This works fine, but parsing the response is fragile because it uses the CLI:

grunt.util.spawn({ cmd: 'bower', args: ['install', '--save', ' git@github.com :foo/bar.git'] }, function(none, message) { grunt.log.writeln(message); }); 

This does not work:

 bower.commands.install.line(['--save', ' git@github.com :foo/bar.git']) .on('end', function(data) { grunt.log.writeln(data); done(); }) .on('err', function(err) { grunt.log.fail(err); done(); }); 

I get the following error:

 $ grunt my-task Running "my-task:default_options" (my-task) task Fatal error: Could not find any dependencies 

What is the right way to do this?

+4
source share
1 answer

The line() function expects an integer argv, so it should be:

bower.commands.install.line(['node', 'bower', '--save', ' git@github.com :foo/bar.git']);

However, you'd better just pass the paths and parameters directly to the install() method:

bower.commands.install([' git@github.com :foo/bar.git'], {save: true});

+8
source

All Articles