我有一個Grunt構建文件。我的構建文件有類似以下任務: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
我需要看看我的「dev」任務目標中myParam的值。但是,我無法弄清楚如何去做。 如果我可以在運行myTask:dev時打印出myParam的值,我會很高興。換句話說, 我想看看下面的運行
> grunt customTask
> grunt customTask --myParam=hello
You entered hello
> grunt customTask-Test
> grunt customTask-Test --myParam=hello
我怎麼做這樣的事是什麼時候?
這已被回答之前:http://stackoverflow.com/questions/17012102/grunt-command-line- arguments-not-working –