相关疑难解决方法(0)

万一失败,如何继续运行 package.json 中定义的脚本?

我在 package.json 文件中有这个:

{
 "name": "test demo",
 "version": "1.0.0",
 "description": "test demo scripts",
 "scripts": {
   "test:v1": "wdio src/resources/config/wdio.chrome.conf.js --spec test/Tests.spec.ts",
   "test:v2": "wdio src/resources/config/wdio.firefox.conf.js --spec test/Tests.spec.ts",

   "test": "npm run test:v1 && npm run test:v2"
   },

    ...
}
Run Code Online (Sandbox Code Playgroud)

当运行此命令时:

npm run test
Run Code Online (Sandbox Code Playgroud)

如果test:v1失败,则test:v2根本不执行脚本。
有没有一种方法可以配置它,以便所有脚本都运行,无论其中一些脚本是否失败?

编辑:当我在 package.json 中尝试此操作时:

"test": "npm run test:v1 ; npm run test:v2"
Run Code Online (Sandbox Code Playgroud)

然后我仍然没有执行这两个脚本,只是test:v1执行时出错。
这是我在控制台中得到的:

C:\2020\demo>npm run test

> demo@1.0.0 test C:\2020\demo
> npm run test:v1 ; npm run test:v2

> demo@1.0.0 test:v1 C:\2020\demo …
Run Code Online (Sandbox Code Playgroud)

javascript node.js webdriver-io package.json npm-scripts

4
推荐指数
1
解决办法
3398
查看次数