如何在package.json中调用另一个命令?

Lij*_*raj 9 npm package.json

假设我在package.json中有这样的脚本

 "scripts": {
    "a1": "first command",
    "a2": "second command",
    "a3": "third command",

  }
Run Code Online (Sandbox Code Playgroud)

如果我想在脚本a3中运行脚本a1a2我该怎么办呢?这有可能吗?我在用

节点版本:v6.9.4

npm版本:4.3.0

我希望实现这样的目标

"scripts": {
    "a1": "first command",
    "a2": "second command",
    "a3": "third command && a1 && a2",

  }
Run Code Online (Sandbox Code Playgroud)

Rob*_*obC 14

npm run在脚本中使用.例如

"scripts": {
  "a1": "first command",
  "a2": "second command",
  "a3": "third command && npm run a1 && npm run a2",
}
Run Code Online (Sandbox Code Playgroud)

运行$ npm run a3通过CLI将运行third command(不管它是什么),然后a1,然后a2.

但是,如果$npm run a3通过CLI运行,则只运行a1,a2然后执行:

"scripts": {
  "a1": "first command",
  "a2": "second command",
  "a3": "npm run a1 && npm run a2",
}
Run Code Online (Sandbox Code Playgroud)