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

How to call one command from another in package.json?

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

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

如果我想 运行 脚本 a1a2 在脚本 a3 我该怎么做?这可能吗?我正在使用

node version : v6.9.4

npm version : 4.3.0

我想实现这样的目标

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

在脚本中使用 npm run。例如

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

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

但是,如果通过 CLI 运行ning $npm run a3 只是 运行 a1 后跟 a2 那么:

"scripts": {
  "a1": "first command",
  "a2": "second command",
  "a3": "npm run a1 && npm run a2",
}