Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const makePartialCurrentLockfile = !installsOnly && (
ctx.existsWantedLockfile && !ctx.existsCurrentLockfile ||
// TODO: this operation is quite expensive. We'll have to find a better solution to do this.
// maybe in pnpm v2 it won't be needed. See: https://github.com/pnpm/pnpm/issues/841
!equalLockfiles
)
const result = await installInContext(importersToInstall, ctx, {
...opts,
currentLockfileIsUpToDate,
makePartialCurrentLockfile,
update: opts.update || !installsOnly,
updateLockfileMinorVersion: true,
})
if (!opts.ignoreScripts) {
await runLifecycleHooksConcurrently(['install', 'postinstall', 'prepublish', 'prepare'],
importersToBeInstalled,
opts.childConcurrency,
scriptsOpts,
)
}
return result
}
}
})
return importers
}
}
const importersToInstall = [] as ImporterToUpdate[]
const importersToBeInstalled = ctx.importers.filter(({ mutation }) => mutation === 'install') as Array<{ buildIndex: number, rootDir: string, manifest: ImporterManifest, modulesDir: string }>
const scriptsOpts = {
extraBinPaths: opts.extraBinPaths,
rawConfig: opts.rawConfig,
stdio: opts.ownLifecycleHooksStdio,
unsafePerm: opts.unsafePerm || false,
}
if (!opts.ignoreScripts) {
await runLifecycleHooksConcurrently(
['preinstall'],
importersToBeInstalled,
opts.childConcurrency,
scriptsOpts,
)
}
// TODO: make it concurrent
for (const importer of ctx.importers) {
switch (importer.mutation) {
case 'uninstallSome':
importersToInstall.push({
pruneDirectDependencies: false,
...importer,
removePackages: importer.dependencyNames,
updatePackageManifest: true,
const pkgsThatWereRebuilt = await _rebuild(
{
pkgsToRebuild: new Set(idsToRebuild),
...ctx,
},
opts,
)
ctx.pendingBuilds = ctx.pendingBuilds.filter((relDepPath) => !pkgsThatWereRebuilt.has(relDepPath))
const scriptsOpts = {
extraBinPaths: ctx.extraBinPaths,
rawConfig: opts.rawConfig,
unsafePerm: opts.unsafePerm || false,
}
await runLifecycleHooksConcurrently(
['preinstall', 'install', 'postinstall', 'prepublish', 'prepare'],
ctx.importers,
opts.childConcurrency || 5,
scriptsOpts,
)
for (const { id, manifest } of ctx.importers) {
if (manifest?.scripts && (!opts.pending || ctx.pendingBuilds.includes(id))) {
ctx.pendingBuilds.splice(ctx.pendingBuilds.indexOf(id), 1)
}
}
await writeModulesYaml(ctx.rootModulesDir, {
...ctx.modulesFile,
hoistedAliases: ctx.hoistedAliases,
hoistPattern: ctx.hoistPattern,
included: ctx.include,