简体   繁体   English

如何在命令行中传递参数以运行纱线脚本

[英]How to pass an argument in command line to run the script for yarn

i'm pretty new to JS.我对 JS 很陌生。 I know that npm allows you to use process.env.npm_config_key to pass variable in command line like我知道npm允许您使用process.env.npm_config_key在命令行中传递变量,例如

npm run --key="My Secret Passphrase" test:integration

But how i can do that using yarn ?但我怎么能用yarn做到这一点?

expected smth like this: yarn run --key="My Secret Passphrase" test:integration期望像这样: yarn run --key="My Secret Passphrase" test:integration

You could use standard environment variables:您可以使用标准环境变量:

On the command line,在命令行上,

MY_KEY="My Secret Passphrase" yarn run test:integration

And in code, read process.env.MY_KEY在代码中,阅读process.env.MY_KEY

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将命令行参数传递给嵌套脚本? - How to pass a command line argument to a nested script? 如何通过命令行将变量作为参数传递给CasperJS脚本? - How to pass a variable as an argument to a CasperJS script through the command line? 如何在NodeJS中传递命令行参数? - How to Pass a Command Line Argument in NodeJS? Adobe After Effects扩展脚本 - 如何从命令行运行脚本并传入参数? - Adobe After Effects extend script - how to run script from command line and pass in arguments? 如何在qooxdoo中运行命令行脚本? - How to run a command line script in qooxdoo? npm将命令行参数传递给命令 - npm pass command line argument to command 如何使用 npm 在命令行中传递参数并在反应 javascript 代码中读取它 - How to pass argument in command line with npm and read it in react javascript code 使用纱线运行不在 package.json 中的命令脚本 - Run command script that is not in package.json using yarn cypress:将数组作为命令行参数传递 - cypress: pass array as command line argument 如何从命令行将参数传递给UltraEdit脚本? - How do I pass parameters to an UltraEdit script from the command line?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM