The following Gruntfile.js will send foo and baz parameters to doe/ray/me which may consume the request with optimist.
module.exports = function(grunt) {
grunt.initConfig({
pkg: '<json:package.json>',
OTHER STUFF HERE
executetagger: {
main: {
//path to code
src: [],
dest: 'tagger',
options: {}
}
},
clean: ["<%= build.dest %>"]
});
OTHER STUFF HERE TOO
grunt.registerMultiTask('executetagger', 'something er other', function(outDir) {
var done = this.async();
console.log(arguments);
executetagger = grunt.util.spawn({
cmd: "node",
args: ["doe/ray/me",
"--foo=bar",
"--baz=qux"]
}, function(error, result, code) {
if(code == 127) {
return grunt.warn(
'The attempt to do whatever failed. '
);
}
done(error);
});
executetagger.stdout.pipe(process.stdout);
executetagger.stderr.pipe(process.stderr);
});
grunt.registerTask('tagger', 'executetagger');
grunt.registerTask('hudson-ci', ['tagger', 'somethingelse', 'athirdthing']);
};
process.argv[0] ...may be used instead of "node" above. I've seen some stuff online that suggests this is good practice and some stuff that claims the opposite. Whatever. The package.json at doe/ray/me will need to look like so:
{
"name": "somethingelse-cli",
"main": "somethingelse-cli.js"
}
The "main" setting will route the request to somethingelse-cli.js (in doe/ray/me) which may in turn defer to somethingelse.js (in doe/ray/me) as suggested here.
No comments:
Post a Comment