From a5e8d5cb808c93fb23125fb9bea43ea21bfe905b Mon Sep 17 00:00:00 2001 From: whyour Date: Sun, 29 May 2022 01:50:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dpnpm=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/services/dependence.ts | 23 +++++++++++++---------- shell/update.sh | 1 + 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/back/services/dependence.ts b/back/services/dependence.ts index 2cd1b51c..7013cf2b 100644 --- a/back/services/dependence.ts +++ b/back/services/dependence.ts @@ -13,6 +13,7 @@ import _ from 'lodash'; import { spawn } from 'child_process'; import SockService from './sock'; import { Op } from 'sequelize'; +import { concurrentRun } from '../config/util'; @Service() export default class DependenceService { @@ -27,7 +28,7 @@ export default class DependenceService { return tab; }); const docs = await this.insert(tabs); - await this.installDependenceOneByOne(docs); + this.installDependenceOneByOne(docs); return docs; } @@ -47,7 +48,7 @@ export default class DependenceService { status: DependenceStatus.installing, }); const newDoc = await this.updateDb(tab); - await this.installDependenceOneByOne([newDoc]); + this.installDependenceOneByOne([newDoc]); return newDoc; } @@ -62,7 +63,7 @@ export default class DependenceService { { where: { id: ids } }, ); const docs = await DependenceModel.findAll({ where: { id: ids } }); - await this.installDependenceOneByOne(docs, false, force); + this.installDependenceOneByOne(docs, false, force); return docs; } @@ -98,16 +99,18 @@ export default class DependenceService { } } - private async installDependenceOneByOne( + private installDependenceOneByOne( docs: Dependence[], isInstall: boolean = true, force: boolean = false, ) { - for (const dep of docs) { - if (dep) { - await this.installOrUninstallDependencies([dep], isInstall, force); - } - } + concurrentRun( + docs.map( + (dep) => async () => + await this.installOrUninstallDependencies([dep], isInstall, force), + ), + 1, + ); } public async reInstall(ids: number[]): Promise { @@ -117,7 +120,7 @@ export default class DependenceService { ); const docs = await DependenceModel.findAll({ where: { id: ids } }); - await this.installDependenceOneByOne(docs); + this.installDependenceOneByOne(docs); return docs; } diff --git a/shell/update.sh b/shell/update.sh index f8fc1882..60bbaf4c 100755 --- a/shell/update.sh +++ b/shell/update.sh @@ -305,6 +305,7 @@ patch_version() { fi # 兼容pnpm@7 + npm i -g pnpm pnpm setup source ~/.bashrc