我想向grunt-shell传递一个参数,就像文档中定义的那样:
module.exports = function(grunt) {
// Configure Grunt
grunt.initConfig({
shell: {
hello: {
command: function (greeting) {
return 'echo ' + greeting;
},
options: {
stdout: true
}
}
}
});
grunt.loadNpmTasks('grunt-shell');
grunt.registerTask('d', 'shell:hello');当我在没有参数的情况下执行它时,它是有效的,但是当我试图设置一个参数时,我得到了一个错误:
Julio:Server julio$ grunt d
Running "shell:hello" (shell) task
undefined
Done, without errors.
Julio:Server julio$ grunt d:me
Warning: Task "me" not found. Use --force to continue.
Aborted due to warnings.我的误会在哪里?
谢谢
发布于 2013-12-27 10:38:08
你的问题是化名,化名不像你想的那样起作用。
如果您使用
grunt shell:hello:me然后它就会像你期望的那样起作用。
因为别名可以是零个或多个任务的列表,所以将参数传递给其他类是没有意义的。如果您非常想化名,那么您可以期望的最好是创建另一个任务来执行别名,而不是真正的别名。
grunt.registerTask('d', function (greeting) {
grunt.task.run('shell:hello:' + greeting);
});在这种情况下,您将能够做您想做的事,使用
grunt d:mehttps://stackoverflow.com/questions/20799069
复制相似问题