输出单行、多命令制作文件配方



我想在我的制作文件中抑制某些命令的输出

例如,我有一个目标,阶段

stagel:
cd scripts && npm list body-parser || npm install body-parser
node scripts/app.js

我想抑制目标中第一行的输出。

我试过了,@cd scripts && npm list body-parser || npm install body-parser,但我仍然得到了输出。我还尝试将@附加到每个 npm 命令,但得到@npm: command not found

我认为这个命令是不对的:

cd scripts && npm list body-parser || npm install body-parser

这说,"运行cd scripts:如果cd工作,则运行npm list body-parser,如果cd失败,则运行npm install body-parser"。 我不知道你想做什么,但我怀疑你想说的是,"先cd scripts,然后运行npm list body-parser,如果失败,则运行npm install body-parser"。 要做到这一点,你需要这样的东西:

cd scripts && { npm list body-parser || npm install body-parser; }

目前尚不清楚您所说的"支持第一行的输出"是什么意思。 您的意思是,您不希望make打印出它正在运行的命令行吗? 或者您的意思是,您不希望显示命令的输出?

如果是前者,那么您@cd ...尝试将这样做。 既然你对此不满意,我只能假设你指的是后者。

Make 对运行命令生成的输出没有任何说明。 如果要抑制该输出,则必须使用正常的shell重定向操作自己完成。 例如:

stagel:
cd scripts && { npm list body-parser || npm install body-parser; } >/dev/null
node scripts/app.js

最新更新