gruntjs - 命令行参数 [英] gruntjs - command line arguments

查看:114
本文介绍了gruntjs - 命令行参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



例如 grunt dist --env = UAT 。我如何获得 env



的值当我处于这种状态时,我将如何分配默认值如果它没有在命令行中设置,那么它的值是否为这个值?

解决方案

您可以使用 grunt.option )或更具体地说:



var env = grunt.option('env')|| 'default';



可以获取 env 参数或默认为字符串'default'如果参数不存在。


Where can I get a handle for command line arguments?

eg grunt dist --env=UAT. How do I get the value for env?

While I'm at it, how would I assign a default value to this if it's not set on the command line?

解决方案

You can use grunt.option() or more specifically:

var env = grunt.option('env') || 'default';

to grab the env argument or default to the string 'default' if the argument is not present.

这篇关于gruntjs - 命令行参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆