是否可以使用另一个npm脚本中的params运行npm脚本?
例如:
import re
s = u"characters (in this case, they are áéíóöőúüű)."
res = re.sub(ur'\W+', u' ', s, flags=re.UNICODE).encode("utf8")
print(res) # => characters in this case they are áéíóöőúüű
因此,最终应将诸如"scripts": {
"build": "node_modules/webpack/bin/webpack.js ", //should get params here
"build:dev": "npm run build --env.type=dev"
"build:prod": "npm run build --env.type=prod"
}
之类的参数传递给--env.type=dev
。
P.S。我试过webpack
,但没有运气
怎么做?
答案 0 :(得分:1)
https://nodejs.org/api/cli.html#cli_1
<强>的package.json 强>
"scripts": {
"tt": "node ./t.js",
"tt:t": "npm run tt -- --env.type=prod"
}
<强> t.js 强>
'use strict';
console.log(process.argv);
<强>结果强>
npm run tt
> node ./t.js
[ '/home/nazar/.nvm/versions/node/v6.6.0/bin/node',
'/home/nazar/Workspace/Source/t.js'
npm run tt:t
> npm run tt -- --env.type=prod
> node ./t.js "--env.type=prod"
[ '/home/nazar/.nvm/versions/node/v6.6.0/bin/node',
'/home/nazar/Workspace/Source/t.js',
'--env.type=prod' ]