pnpm set-script
新增于:v11.3.0
🌐 Added in: v11.3.0
别名:ss
🌐 Aliases: ss
在项目清单的 scripts 字段中添加或更新条目。
🌐 Adds or updates an entry in the scripts field of the project manifest.
pnpm set-script <name> <command>
支持 package.json、package.json5 和 package.yaml 清单格式。
🌐 Supports package.json, package.json5, and package.yaml manifest formats.
如果 scripts 字段不存在,它将被创建。如果已存在同名脚本,则会被覆盖。
🌐 If the scripts field does not exist, it is created. If a script with the same name already exists, it is overwritten.
示例
🌐 Examples
pnpm set-script test "vitest run"
pnpm set-script build "tsc -p ."
pnpm ss lint "eslint ."
上述等同于手动编辑 package.json:
🌐 The above is equivalent to manually editing package.json:
{
"scripts": {
"test": "vitest run",
"build": "tsc -p .",
"lint": "eslint ."
}
}
另请参阅
🌐 See also
pnpm pkg set— set arbitrary fields inpackage.json, including individual scripts viascripts.<name>=<command>.