簡體   English   中英

是否有一種優雅的方式將npm運行選項傳遞給grunt選項

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM