【发布时间】:2016-04-05 18:38:25
【问题描述】:
我正在处理大型项目,我们有多个npm packages。
我想并行安装所有包,这意味着我希望所有包同时运行(以节省时间),并且在最后一次安装完成后继续执行我的脚本。
示例脚本:
#!/bin/zsh
#...
NPM_FOLDERS=(
common.library/audit
common.library/cipher
common.library/logger
...
)
# Get the number of total folders to process
counter=${#NPM_FOLDERS[@]};
# counter for user feedback to the current install folder index
index=1;
# loop and install all the required packages
for folder in $NPM_FOLDERS;
do
# Print the installation message with the folder & couters
echo "\033[38;5;255m($index/$counter) Executing npm install in: \033[38;5;226m$folder";
# change the folder to the required location
cd $ROOT_FOLDER/$folder;
# Execute install on this folder
npm install ;
# increase current index
let index++;
done
echo
echo "\033[38;5;11mInstallation completed."
echo
不会接受最快的答案,而是会做我想做的事情并且不知道如何做的人,所以你可以讲述时间并给出完整的答案。
非常感谢您。
【问题讨论】:
-
npm install &?不过,不确定如何显式等待后台进程。
标签: node.js bash shell ubuntu zsh