如何将命令行参数传递给纱线脚本

时间:2021-07-01 20:46:38

标签: javascript reactjs npm yarnpkg package.json

我想使用命令行参数并使用此值替换纱线脚本中的 url。 我的脚本看起来像这样 -

"demo:req": "curl -s -D - -o /dev/null https://test.com/demo?request=true&type=${0} | grep -i '^location: ' | awk '{print $2}' | sed 's/https/http/' | sed 's/test.com/localhost:3012/'",

所以当我跑步时

yarn demo:req type1

它应该在触发 curl 命令之前用 type1 替换 ${0}。但这不起作用。

我尝试在 url 中使用 ${TYPE} 并将命令运行为

yarn demo:req TYPE=type1

但仍然没有运气。

任何帮助将不胜感激

0 个答案:

没有答案