【发布时间】:2013-11-21 17:13:33
【问题描述】:
我有一个 Grunt 构建文件。我的构建文件有一个如下所示的任务:
myTask: {
options: {
configFile: "config/default.js",
args: { }
},
dev: {
configFile: 'config/local.js',
options: { args: {} },
},
test: {
configFile: 'config/remote.js',
options: { args: {} }
}
}
...
grunt.registerTask('customTask', ['myTask:dev']);
grunt.registerTask('customTask-Test', ['myTask:test']);
目前,我可以从命令行运行以下命令:
> grunt customTask
一切正常。但是,我需要添加执行以下操作的功能:
> grunt customTask --myParam=myValue
我需要查看“开发”任务目标中 myParam 的值。但是,我不知道该怎么做。 如果我能在 myTask:dev 运行时打印出 myParam 的值,我会很高兴。换句话说, 我想在运行时看到以下内容
> grunt customTask
> grunt customTask --myParam=hello
You entered hello
> grunt customTask-Test
> grunt customTask-Test --myParam=hello
我该如何做这样的事情?
【问题讨论】:
-
之前已经回答过这个问题:stackoverflow.com/questions/17012102/…
标签: gruntjs