npm-scriptsで指定したコマンドにオプションを渡す

  "scripts": {
      "tsc" : "tsc",
      "test": "echo \"Error: no test specified\" && exit 1"
  },
  • package.jsonが上のような状態とする。
 SHELL> tsc -v
 Version 2.9.2
 SHELL> npm -v
 5.6.0
 
 SHELL> npm run tsc -v       (1)
 5.6.0
 SHELL> npm run tsc -- -v    (2)
 Version 2.9.2
  • (1)のようにすると-vはnpmコマンドに渡る。
  • よって、(2)のように--の後にオプションを渡す。

参考

https://stackoverflow.com/questions/38030078/how-to-install-and-run-typescript-locally-in-npm


トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS

Last-modified: 2018-09-07 (金) 08:26:45