【发布时间】:2015-06-29 19:53:17
【问题描述】:
我有一个 shell 脚本,它从基本目录递归搜索 package.json 并像这样运行 npm test。
find "$parent_dir" -name package.json -maxdepth 2 -execdir npm test \;
我想拦截测试失败的形式:
npm ERR! Test failed. See above for more details.
npm ERR! not ok code 0
所以我可以让 shell 脚本以错误状态退出。
感谢任何帮助。
【问题讨论】:
-
有类似的问题...
-
刚找到这个问题,和我的差不多。两年了,没有答案……
-
这里有一个相关的问题可以解决这个问题stackoverflow.com/questions/17830326/…
-
这能回答你的问题吗? Ignoring specific errors in a shell script