Scripts
本篇介紹 pnpm 如何處理 package.json 的 scripts 欄位。
Hidden Scripts
Added in: v11.0.0
Scripts with names starting with . are hidden. They cannot be run directly via pnpm run and are omitted from the pnpm run listing. Hidden scripts can only be called from other scripts.
{
"scripts": {
".helper": "echo 'I am hidden'",
"build": "pnpm run .helper && tsc"
}
}
In this example, pnpm run .helper would fail, but pnpm run build would succeed because .helper is called from another script.
Lifecycle Scripts
pnpm:devPreinstall
只在本機 pnpm install 時執行。
會在安裝任何依賴套件之前執行。
此指令檔僅在根專案的 package.json 有設定時執行。