gpt4 book ai didi

node.js - 如何执行并行命令

转载 作者:搜寻专家 更新时间:2023-10-31 23:12:10 25 4
gpt4 key购买 nike

<分区>

我正在处理大型项目,我们有多个 npm 包

我想并行安装所有包,这意味着我希望所有包同时运行(以节省时间),并在最后一次安装完成后继续我的脚本。

示例脚本:

#!/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

我不会接受最快的答案,而是会做我想做的事但不具备正确的知识如何去做的人,所以你可以讲时间并给出完整的答案。

非常感谢您。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com