首页 > 解决方案 > 将参数/通配符定义为 npm 脚本键/名称的一部分

问题描述

我有一个package.json这样的定义:

{
  "name": "example",
  "version": "1.0.0",
  "description": "example",

  (...)

  "scripts": {
    "something:special": "script-that-does-something.sh",
    (...)
  },

  (...)

}

script-that-does-something.sh得到一个做某事的论据,这意味着我通常会做类似的事情:

npm run something:special ARGUMENT

以上内容非常好并且有效,但我想知道我是否可以在中定义脚本package.json以便能够在仍然运行如下npm命令的同时使用任何参数:

npm run something:special:ARGUMENT

标签: node.jsbashnpmnpm-scripts

解决方案


推荐阅读