使用python自动化工具,我在项目中运行命令npm install
,然后运行npm run build
来构建.war文件并将其放在tomcat服务器中。
我每次都需要运行npm install
,因为我擦除文件夹并使用Jenkins创建一个新的git克隆,每次。
问题是python脚本试图找到一个我事先确定会确认它可以启动下一个任务的句子,但是当我运行命令npm install
时,我无法确定任务完成是因为输出的结束:
| `-- is-buffer@1.1.5
+-- webpack-war-plugin@1.0.0-beta.3
| +-- archiver@1.3.0
| | +-- archiver-utils@1.3.0
| | | +-- glob@7.1.2
| | | `-- lazystream@1.0.0
| | +-- async@2.4.1
| | +-- buffer-crc32@0.2.13
| | +-- glob@7.1.2
| | +-- tar-stream@1.5.4
| | | +-- bl@1.2.1
| | | `-- end-of-stream@1.4.0
| | +-- walkdir@0.0.11
| | `-- zip-stream@1.1.1
| | `-- compress-commons@1.2.0
| | `-- crc32-stream@2.0.0
| | `-- crc@3.4.4
| `-- typescript@2.3.4
+-- whatwg-fetch@1.1.1
`-- write@0.3.3
`-- fs-exists-sync@0.1.0
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\browser-sync\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
但输出并不总是一样的。我正在寻找的是一种正确地知道命令完成的方式:npm installation completed
。除非有更好的方法来做到这一点。 (它必须在Windows和Linux上工作)
答案 0 :(得分:0)
将npm install done
输出结尾处的npm install
打印到日志文件中:
npm install >> D:\npmInstall.log 2>&1 && echo npm install done >> D:\npmInstall.log 2>&1