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

How to pass dynamic file name in npm run command

我想 npm 运行 一个命令,根据我在命令行中传递的文件名生成一个动态输出文件。但是我无法从下面的命令生成它

在我的 package.json 脚本中,我添加了命令:

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 

它生成一个名称为 $npm_config_filene.js 的文件而不是 myfile.js

有人能帮忙吗?

对于 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