【发布时间】:2018-05-13 09:05:28
【问题描述】:
我有一个场景,我必须运行三个 npm 脚本才能在我的应用程序中获得一些结果。我将它们组合在一个 npm 脚本中。这是我的package.json:
"scripts": {
"setup": "npm install && npm run some-script && npm install",
"some-script": "gulp some-other-script"
}
我想做的是从命令行将参数传递给setup 脚本,该脚本将进一步传递给some-script 脚本。
如果我运行npm run script -- --abc=123,参数会添加到脚本末尾,但我想将其传递给特定脚本(在本例中为npm run some-script)。我还尝试像这样重写脚本定义:
"setup": "npm install && npm run some-script -- --sample=sample&& npm install" 但没有运气。
我知道 shell 函数(在此处描述:Sending command line arguments to npm script 和此处https://github.com/npm/npm/issues/9627),但我需要一个可以跨平台工作的解决方案。
有没有办法做到这一点?
【问题讨论】:
-
您好,您知道如何实现这一点吗,我有相同的案例用法;)
-
问题似乎来自 && 部分脚本