简体   繁体   English

如何在 npm 运行命令中传递动态文件名

[英]How to pass dynamic file name in npm run command

I want to npm run a command to generate a dynamic output file from the file name I pass in the command line.我想在 npm 运行命令,从我在命令行中传递的文件名生成动态 output 文件。 But I am not able to generate that from the below command但我无法从以下命令生成它

In my package.json in the script I have added the command:在我的 package.json 脚本中,我添加了命令:

scripts:{
"gen-out":"some_cmd src/app/parser/$npm_config_filene.st -o src/app/parser/$npm_config_filene.j"
}

and after running并在运行后

npm run gen-out --filene=myfile 

it produces a file with the name $npm_config_filene.js instead of myfile.js它生成一个名为 $npm_config_filene.js 而不是 myfile.js 的文件

could anyone help, please?有人可以帮忙吗?

for windows platform use this format:对于 windows 平台,使用以下格式:

scripts:{
"gen-out":"some_cmd src/app/parser/%npm_config_filene%.st -o src/app/parser/%npm_config_filene%.j"
}

npm run gen-out --filene=myfile 

暂无
暂无

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

相关问题 如何在 npx 命令中传递参数(输入)以运行 npm package - How to pass argument(input) in an npx command to run the npm package 如何将参数从npm命令传递到量角器配置文件 - How to pass parameters from npm command to protractor config file 如果命令位于外部文件中,如何在Windows上运行npm脚本 - How can I run npm script on Windows if command is in an external file 如何在没有“run”的情况下运行“npm command”(即“npm command”而不是“npm run command”)? - How to run “npm command” run without “run” (i.e. “npm command” instead of “npm run command”)? 困难解决“sh:<npm package name> 命令未找到”与 npm run<npm package name> - Difficulty solving “sh: <npm package name> command not found” with npm run <npm package name> 如何将参数传递给 --world-parameters 或 npm run 命令以供包中的脚本使用 - How to pass a parameter to --world-parameters or npm run command to be consumed by scripts in package 将参数传递给 npm 运行“我的命令”并在我的函数中使用该参数 - Pass parameter to npm run "my command" and use that parameter in my functions 如何以 apache 用户身份运行 npm 命令 - How to run npm command as apache user 使用相同的npm run命令动态运行多个javascript文件 - Run several javascript file dynamically using same npm run command 什么是 npm 运行构建命令以及如何使用 webpack 创建捆绑文件 - What is npm run build command and how webpack is used in creating bundle file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM