有没有办法为 grunt.option 发送多个值

Is there a way to send multiple values for grunt.option

我想从设置多个值的选项开始 grunt。这可能吗? 即

grunt doThis --ip 1.2.3.4 --ip 2.3.4.5

这可能吗?

grunt.registerTask('doThis', function () { console.log(grunt.option('ip')); });

grunt doThis --ip="192.168.1.1" --ip="192.169.1.10"
Running "doThis" task
192.169.1.10

Done, without errors.

是的。 Grunt 使用 nopt 来解析命令行选项,它支持多个值。你会像这样传递它们:

grunt doThis --ip=1.2.3.4 --ip=2.3.4.5

您至少需要 v1.0.0-rc1 版本的 Grunt 才能正常工作。