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"
的脚本。
你可以用 --
给你的脚本传递附加参数。
yarn run test -- -o --watch
运行这个命令会执行 jest -o --watch
。
[script]
也可以是任何 node_modules/.bin/
里本地安装的可执行程序。
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
命令会列出包里所有可运行的脚本。