node.js - 将参数/通配符定义为 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

最佳答案

我也在寻找一种方法来避免为我的测试和命令编写每个脚本。

至少它会迫使你做一些好的文档。

https://stackoverflow.com/questions/58092574/

相关文章:

python - 如何使用 Pandas 计算数据框中的类标签频率?

c# - Automapper:对所有其他成员使用默认映射

spring-boot - 将实体与 OneToMany 和 HATEOAS RessourceAs

oauth-2.0 - 松弛 Oauth : Automatically authorize use

c# - OmniSharp MSBuild ProjectManager 无法更新我的 .cspr

postgresql - 如何为 linux、Fedora 安装 psycopg2

reactjs - `react-dom` 是库还是框架?

asynchronous - 如何使 promise 因 clojure 错误而失败?

reactjs - react native : Module RCTLog is not a re

python - TensorFlow 无法将字符串类型的 Tensor 复制到设备