[英]Is there an elegant way to pass npm run options to grunt options
我有一個如下所示的package.json,
{
"scripts": {
"start": "node app.js",
"test": "./node_modules/.bin/grunt test"
}
}
我想通過npm run test
調用帶有以下參數的測試腳本:
npm run test --host=<value1> --testType=<value2>
是否可以通過grunt文件中的grunt.option
將這些參數讀取為grunt選項?
如果我像這樣傳遞這些參數:
"test": "./node_modules/.bin/grunt test --host=<value1> --testType=<value2>"
但是基於testType
,測試運行的性質會有所不同-因此,如果可以從npm run
讀取這些值,那就太好了。
不知道這是您要追求的,但是:
從
npm@2.0.0
,您可以在執行腳本時使用自定義參數。 特殊選項--
由getopt用來分隔選項的結尾。 npm將--
之后的所有參數直接傳遞給您的腳本
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.