diff --git a/package.json b/package.json index 619d6d12bf..73d99a84b7 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,6 @@ "pnpm-file-reporter": "0.0.1", "pnpm-install-checks": "1.1.0", "pnpm-logger": "0.2.0", - "promisequence": "1.1.6", "proper-lockfile": "2.0.0", "rc": "1.1.7", "read-pkg": "2.0.0", diff --git a/src/api/extendOptions.ts b/src/api/extendOptions.ts index c2bd956e57..e23b6fc62d 100644 --- a/src/api/extendOptions.ts +++ b/src/api/extendOptions.ts @@ -28,6 +28,7 @@ const defaults = () => ({ networkConcurrency: 16, fetchingConcurrency: 16, lockStaleDuration: 60 * 1000, // 1 minute + childConcurrency: 5, }) export default (opts?: PnpmOptions): StrictPnpmOptions => { diff --git a/src/api/install.ts b/src/api/install.ts index 0a0e9d8661..bf81d03135 100644 --- a/src/api/install.ts +++ b/src/api/install.ts @@ -1,6 +1,5 @@ import rimraf = require('rimraf-then') import path = require('path') -import seq = require('promisequence') import RegClient = require('npm-registry-client') import logger from 'pnpm-logger' import cloneDeep = require('lodash.clonedeep') @@ -143,8 +142,9 @@ async function installInContext (installType: string, packagesToInstall: Depende // postinstall hooks if (!(opts.ignoreScripts || !installCtx.installationSequence || !installCtx.installationSequence.length)) { - await seq( - installCtx.installationSequence.map(async pkgId => { + const limitChild = pLimit(opts.childConcurrency) + await Promise.all( + installCtx.installationSequence.map(pkgId => limitChild(async () => { try { await postInstall(installCtx.installs[pkgId].hardlinkedLocation, installLogger(pkgId)) } catch (err) { @@ -157,7 +157,7 @@ async function installInContext (installType: string, packagesToInstall: Depende } throw err } - }) + })) ) } if (!opts.ignoreScripts && ctx.pkg) { diff --git a/src/types.ts b/src/types.ts index 1d1c40214c..36615a7b06 100644 --- a/src/types.ts +++ b/src/types.ts @@ -23,6 +23,7 @@ export type PnpmOptions = { nodeVersion?: string, networkConcurrency?: number, fetchingConcurrency?: number, + childConcurrency?: number, lockStaleDuration?: number, // proxy @@ -65,6 +66,7 @@ export type StrictPnpmOptions = { networkConcurrency: number, fetchingConcurrency: number, lockStaleDuration: number, + childConcurrency: number, // proxy proxy?: string, diff --git a/typings/local.d.ts b/typings/local.d.ts index 7896700823..1d4ca243dc 100644 --- a/typings/local.d.ts +++ b/typings/local.d.ts @@ -68,11 +68,6 @@ declare module 'os-homedir' { export = anything; } -declare module 'promisequence' { - const anything: any; - export = anything; -} - declare module 'read-pkg-up' { const anything: any; export = anything;