英文:
Call npm script from another script and pass arguments
问题
"script-a" 是一个脚本,它的定义在我的 package.json 文件中:
"script-a": "npm run script-b",
"script-b": "ts-node ./src/the-script.ts"
假设 "script-b" 支持一个名为 "logging" 的参数。那么,你可以这样调用它:
npm run script-b --logging
你是否可以在调用 "script-a" 时将参数 "logging" 传递给 "script-b" 呢?看起来是这样的:
npm run script-a --logging
英文:
Let's say I have two scripts defined in my package json:
"script-a": "npm run script-b",
"script-b": "ts-node ./src/the-script.ts",
Let's say script-b
accepts an argument logging
. So I could do the following
npm run script-b --logging
Is it somehow possible to call script-a
but pass the argument logging
to the call of script-b
.
Looking like this:
npm run script-a --logging
答案1
得分: 1
我不确定我是否正确理解你想要做什么,但你可以像这样传递参数:
npm run script-a -- --logging
英文:
I'm not sure if I understand correctly what you want to do, but you can pass arguments like this
npm run script-a -- --logging
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论