yarn run

运行一个定义好的包脚本。

你可以在你的 package.json 文件中定义 scripts

{
  "name": "my-package",
  "scripts": {
    "build": "babel src -d lib",
    "test": "jest"
  }
}
yarn run [script] [<args>]

如果你已经在你的包里定义了 scripts,这个命令会运行指定的 [script]。例如:

yarn run test

运行这个命令会执行你的 package.json 里名为 "test" 的脚本。

You can pass additional arguments to your script by passing them after the script name.

yarn run test -o --watch

运行这个命令会执行 jest -o --watch

[script] 也可以是任何 node_modules/.bin/ 里本地安装的可执行程序。

It’s also possible to leave out the run in this command, each script can be executed with its name:

yarn test -o --watch

Running this command will do the same as yarn run test -o --watch. Note that built-in cli commands will have preference over your scripts, so you shouldn’t always rely on this shortcut in other scripts

yarn run env

Running this command will list environment variables available to the scripts at runtime.

If you want to override this command, you can do so by defining your own "env" script in package.json.

yarn run

如果你不指定一个脚本给 yarn run 命令,run 命令会列出包里所有可运行的脚本。