perf: run postinstall scripts concurrently

This commit is contained in:
zkochan committed 2017-03-01 23:41:11 +02:00
1 parent 43871af83e
commit c3fd6855ea
5 files changed
+7 -10

No files matched your search

-1
View File
@@ -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",
+1
View File
@@ -28,6 +28,7 @@ const defaults = () => (<StrictPnpmOptions>{
networkConcurrency: 16,
fetchingConcurrency: 16,
lockStaleDuration: 60 * 1000, // 1 minute
childConcurrency: 5,
})
export default (opts?: PnpmOptions): StrictPnpmOptions => {
+4 -4
View File
@@ -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) {
+2
View File
@@ -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,
-5
View File
@@ -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;