npm run-script

运行任意包脚本

概要

npm run-script <command> [--if-present] [--silent] [-- <args>]
npm run-script <command> [--workspace=<workspace-name>]
npm run-script <command> [--workspaces]

aliases: run, rum, urn

描述

这会从包的 "scripts" 对象运行任意命令。如果没有提供 "command",它将列出可用的脚本。

run[-script] 由 test、start、restart 和 stop 命令使用,但也可以直接调用。当包中的脚本被打印出来时,它们被分为生命周期(测试、启动、重启)和直接运行的脚本。

任何位置参数都会传递给指定的脚本。使用 -- 传递以 - 为前缀的标志和选项,否则它们会被 npm 解析。

例如:

npm run test -- --grep="pattern"

QPL+0YLl4+9bzIHoPkkO+2jjXANkSp5AMUIZcz4ClZzMGhJsAe2X+CUZd0jMW8CHlcqy9Gl8tWfg7Rk97EVnJ+OvO8P7VrSu8eCTKGI2fvi4E9WK9ZROXl/Kqs50AGP4pVMLo7TuopF5aWna4XCERzBL6jhd0tyJ07PKb+67G6/8seEfJYPICMkZSt7II8W1

U761r2ULL5O2DnjmB2tJAvxG3shZ7NOIMaWvYmb5yoij5xSW4A0Nhf+GMDsVYzFqQbCbEppYZ20mz/tAAGwc0zZrC1dQBvl9yw5Ad8bdKS9qzqQ1cYtnkHOQJW8Rl2MqPrMURd1y/symHFDb8paYbZiDEm2Z7OjeUEbRmfzCjFXcKLBp5FFqG7giA4m5F7nMtLAUdNKkeO+7Is4t16vEB+TymmeHh2qaD+WPrpZg5OeXkYstyk/KD27lcXuYvwJy

8Gpq55a7RvHAA0OK99ResNjtGOTmR2ve863bkpCoBINTCEz8gPAMFxTHzOAAG11mPk2Q9gW+3r5XyiQxrNi/Gq3bJuuJE6PaE1KZQwODTdUjuQJFFhPHZFUqOknJ9G8jQgmdN2FNzDK734U8Y9c9qjkw1Lu9ZeIvOX7Bevwhwu9oEzYhwfSy6RVPHfMUfqLIsMkbPSjDjw0PRO3TS3iPinVaoOxcS3zvzJqJxplQQywCWtcQWGxrf/FszkQ0+TJGI+6cvBp/OlkMZ7A0GzT2SAt328XTCRTLC4jxwN9K0vq+MZRkYsLDK1oi/k2+eSfe9G1C1H85SYSx9a+MoFB3lefU6agpcU/Es8hXDxwfETdv1G8r9P9t6EvNQSbl/dcRXG5srgWEEnpStTxV1q8X6yLmNaUYummz8IxkJrTK5xVbozMEhC4eQ3JzYnN44zxyvDearpCip3ODjNFSMAFcoZc1IW2ZrCYMLe7SCePWkaOKvHueTlogWHEgUOQWFjoiwu+cpg5Hp3y+bzIwTE/mPdByHerjIT3kt8f5MKUvEEk=

"scripts": {"test": "tap test/*.js"}

6Tjc/lkpIFNvHrZPi2DX0w==

"scripts": {"test": "node_modules/.bin/tap test/*.js"}

LzfKgRJwMToIrKYBIgg6OdMCflDIBpq8XcFhWlS46DvRi+acQtNHKUwU8pOwQ2MEeqenYlKysj6OVqOmh1mytOW6MO5Mf4OgpOGDFBmNfHpU8Q7yPiRzX4N2BXYr3CsV2sbNjiY8QGkgo6KVrdOiH5bUqQnExR893V4ohJkywKpNDnOQI1F754OF0edwozBib47KLS5cGuh5lLzPeRKJUCKzepbdnv4W5mGJrBpBsS9p7SMj52mztf+/UFu+PaLgcu9xZqh6MMUfgXu7A1SoahP+z06l00cbKl6rGQrYFLlFLnYpgYY/SqOurtDs8FOuxRjVSA0sTVwfGFZDBpI9r0bvaWZDeAyV9EAk6SMXGcaf/sIEWVwat9BsoYOL7l5QqRa3wMgDKi+nNDC7MJtubg==

/RADA0/cSt5AZoWNM3k0mS1vs2zm6GwXqGmIOUAVujKcnTRJebeiNHddFlKbSrNoIfEHpswlmI+kJu3kiBKOcVLsVhOVPoTpSoRjrQCRjgP8A+uZVIns3CyeOsQV23JNLVWYWB1VrupoyvgsTd/4swySc1HrtEPrsAEqo/CpEjZpT+B+G9tjs5Osnmc9euqCiOM6skf2l5aW9ZT6gOlYzG0XIPU0lW7ulaZFXM3kmWrVYle/lFuhFoKBiPMZjNxELYELhPRapOBplP48ZQStp7YyqyG8x/TTQaV4vH+Ol8YUUtkFXFBke3Ry2mP6pGRWbqzifwIVECzOUTsAnwwtzNFN7SyUQn3UhvQzBtP3A+E45ygsN8DBqOi8owRohjfZCgICat/PGosjdXPdnIpXinwZ9RxcCmYICkAQnQA5kSQ=

CS+19GIzHuU0vEnaR0WWDdH5Svgak0qfaoRMMMfzzlHxS8ltUYMSMENlQS2L4dNrF88BIl0UKIf30o3WvepTXm2BVx/lOyETngbW9Uh6ImwSkSZevFQMn/tlT+VWK0O43DMdi/IXsJVauKPnf03KWRsyyl2w9f5LmGh/uSNeOM4DYFLddoxamfLp6YS3S/c/

HHVc8u+egdr4w3bTQs4rhQCU2p46xU9SudCrPENApHzsCzZNBYiiMNSm546bTXBoxpfK9wWLvXIU4AtSpoQvyXp81a4jl+DrKTYtYPyRAy2EA807BlvmWevUyh4+mN7FuuwTdo7oh/iWPUTsKrZ0F07Q5zHYU7C7a4P0flzph9D0nySh3sBjfA6Cro9+cXEKwO9MJyaB5UKxCztAHBNk/88i0uHReGoGxisqN59xJfZrVYX4+UxCjPYBD4+yGHq9

工作区支持

ffZwyL3PlrCKtCwyD2AkIcFpvbmfvMq9AUrs1vEH2k5HIHfY6tlr7cv0tK9k36vZx5YPjo6uWrJNj9RNZjnmHq2QG1g0U8+AxFfYwFTihQVc3K/YaiPN4kg27QIlsXttP6Bsma9AlLIs8V7Vk0ZRIq2KCGEk7Bnjx6WJenzIrzUASyIx05KxsBH8alU17DWmAoFWtT38hnvqA30acI5uW6clM646XY0OKe7ZZplEY/yc6gKfHXekckAXlnwifTLM2hctiSJhb9heNZ6D99CUkEk/u3w5glEUQy80dJtVdLjNs5JKRec3Ck5pDKYE0OTzP2Y77uh3QrueFJdaCwnFbbLCWTImRwSpAjEQ+o7ao69ntgLUSe+FY5PLHDzzoKxs

2q3idZLdP8QVkA9IsnGd5vhkXaBnptLfm9UDFQrhFoqbFP6Vs125uSN06pAZMzQVL4dvyK6TqmWu3RHkWRupXQ==

.
+-- package.json
`-- packages
   +-- a
   |   `-- package.json
   +-- b
   |   `-- package.json
   `-- c
       `-- package.json

G+b0FOaRspOQLSdVV9IFW7l6+z0yB8CZd+EFeODDeohJiwanEC7zAmXLmUwf1lBpEYq3V8PxNUbrl1ByyReiyM3tHa1NmkKZoLhmf7ZkiRgwkIGxgLJKwOSdAL6oSIYIDycEpvfdVntpxGEPYcYJ9g==

{
    "workspaces": [ "./packages/*" ]
}

zzwzFJrZKudEeN/vy+oKkCVZsVcoo1epAaZWdfBhN0ttpB38wfcEY1sa33UahLFb6bQYpOhkq0HqcGsJjdXfB4E15jDJ/T2678MPayOJf+Adz4swTue+bHTKQrxt8OeOTiv9rVA096c0igJzUthXXeH7dmkqjgTol8ktMp+TlGt7VKp1XZ+S9AMzXL1JI/0qbbC+MaHVAjluHxUhGRPnzuWopOSGhtKqUETjXst/OkA=

npm test --workspaces

过滤工作区

yAFXpenXDXBE2X8Fzw7YSuUvEz+LLi50KsOkBGsGLCj8TxyVu6w6eFeXtktS7muWY59oaup3Rii4dyL6yv9T5b+a4+yZAgPDd5zCImuCwKZYAzeHc+3Ku/x2svdxD78czu7iAg48tI6R5QrNlfNjdA==

npm test --workspace=a

lkjrjevbgv8w9KNkZvPMy6wjZQ2fJDArplz2vISJMgr5DbBYzEWnSr+ZG/8CcSi3TY3FBMr390oTSEsxvc+wsWCHdxgEDnoUtg+m55N+VSn8cM4ujFvjRvD1yyn+/bHc7/nnYhbhL+MDV4YlPwliIdgOvivSM3c3AY2D3rc9lPfOTE4V2pycBThx9IDEeZCYovZ5/Zm8ozBvUrKoAXh4HIXKuR5yiw6/9rCh7m3N2v2iMa+iqxY0QhzSTFMmxriluEeVAtqGl9Rc0QEZlxjnqtH8a6O+o9HlnFrd2P8GpDiaSana7caLkShTBUDpjdtP

npm test -w a -w b

sMoXd24Bp4fMRCbPjrZ721ilkrwjJ9GS+vHxjrj3/VXkpll4OVn3GPxlB2gy30xVh6TgxErSotExuhrnfdYxdAUMTlVy4o1VAmEZDMp9L7S2Y9iMD2lNvLrYNL9Vv7yFKr39gkoaXqT9jgKDAO1Vat4ZcKtbEjIJQ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