npm install - 确定安装结束

npm install - determine the end of the installation

使用 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 上工作)

要在 npm install 的输出末尾将 npm install done 打印到日志文件中:

npm install >> D:\npmInstall.log 2>&1 && echo npm install done >> D:\npmInstall.log 2>&1