perf: fix performance issue caused by refactoring

This commit is contained in:
zkochan
2016-10-31 22:22:44 +02:00
parent 2f88729a05
commit a3939e0414
2 changed files with 20 additions and 13 deletions

View File

@@ -92,17 +92,20 @@ async function installInContext (installType: string, packagesToInstall: Depende
cacheTTL: opts.cacheTTL
}),
}
return (
await installMultiple(installCtx,
return Array.prototype.concat.apply([], await Promise.all([
installMultiple(
installCtx,
packagesToInstall,
nodeModulesPath,
installOpts)
).concat(
await installMultiple(installCtx,
installOpts
),
installMultiple(
installCtx,
ctx.pkg && ctx.pkg && ctx.pkg.optionalDependencies || {},
nodeModulesPath,
Object.assign({}, installOpts, {optional: true}))
)
Object.assign({}, installOpts, {optional: true})
),
]))
})
if (opts.flatTree) {

View File

@@ -92,18 +92,22 @@ async function install (pkgRawSpec: string, modules: string, ctx: InstallContext
optional: dependency.optional,
root: dependency.srcPath,
})
dependency.dependencies = (await installMultiple(ctx,
dependency.dependencies = Array.prototype.concat.apply([], await Promise.all([
installMultiple(
ctx,
dependency.pkg.dependencies || {},
path.join(dependency.path, 'node_modules'),
nextInstallOpts)
).concat(
await installMultiple(ctx,
nextInstallOpts
),
installMultiple(
ctx,
dependency.pkg.optionalDependencies || {},
path.join(dependency.path, 'node_modules'),
Object.assign({}, nextInstallOpts, {
optional: true
}))
)
})
),
]))
ctx.piq = ctx.piq || []
ctx.piq.push({
path: dependency.path,