Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(() => {
if (result.currentLockfile.packages === undefined && result.removedDepPaths.size === 0) {
return Promise.resolve()
}
return writeModulesYaml(ctx.rootModulesDir, {
...ctx.modulesFile,
hoistedAliases: result.newHoistedAliases,
hoistPattern: ctx.hoistPattern,
included: ctx.include,
independentLeaves: ctx.independentLeaves,
layoutVersion: LAYOUT_VERSION,
packageManager: `${opts.packageManager.name}@${opts.packageManager.version}`,
pendingBuilds: ctx.pendingBuilds,
registries: ctx.registries,
shamefullyHoist: ctx.shamefullyHoist,
skipped: Array.from(ctx.skipped),
store: ctx.storeDir,
virtualStoreDir: ctx.virtualStoreDir,
})
})(),
])
const shrinkwrapOpts = { forceSharedFormat: opts.forceSharedShrinkwrap }
if (opts.shrinkwrap) {
await saveShrinkwrap(ctx.shrinkwrapDirectory, newShr, currentShrinkwrap, shrinkwrapOpts)
} else {
await saveCurrentShrinkwrapOnly(ctx.shrinkwrapDirectory, currentShrinkwrap, shrinkwrapOpts)
}
if (opts.shamefullyFlatten) {
ctx.hoistedAliases = await shamefullyFlattenByShrinkwrap(currentShrinkwrap, ctx.importerId, {
defaultRegistry: ctx.registries.default,
modulesDir: ctx.modulesDir,
prefix: opts.prefix,
virtualStoreDir: ctx.virtualStoreDir,
}) || {}
}
await writeModulesYaml(ctx.virtualStoreDir, {
...ctx.modulesFile,
importers: {
...ctx.modulesFile && ctx.modulesFile.importers,
[ctx.importerId]: {
hoistedAliases: ctx.hoistedAliases,
shamefullyFlatten: opts.shamefullyFlatten,
},
},
included: ctx.include,
independentLeaves: opts.independentLeaves,
layoutVersion: LAYOUT_VERSION,
packageManager: `${opts.packageManager.name}@${opts.packageManager.version}`,
pendingBuilds: ctx.pendingBuilds,
registries: ctx.registries,
skipped: Array.from(ctx.skipped).filter((pkgId) => !removedPkgIds.has(pkgId)),
store: ctx.storePath,
getIndependentPackageLocation: opts.independentLeaves
? async (packageId: string, packageName: string) => {
const { directory } = await opts.storeController.getPackageLocation(packageId, packageName, {
lockfileDirectory: ctx.lockfileDirectory,
targetEngine: opts.sideEffectsCacheRead && ENGINE_NAME || undefined,
})
return directory
}
: undefined,
lockfileDirectory: opts.lockfileDirectory,
modulesDir: ctx.modulesDir,
registries: ctx.registries,
virtualStoreDir: ctx.virtualStoreDir,
}) || {}
}
await writeModulesYaml(ctx.virtualStoreDir, {
...ctx.modulesFile,
importers: {
...ctx.modulesFile && ctx.modulesFile.importers,
[ctx.importerId]: {
hoistedAliases: ctx.hoistedAliases,
shamefullyFlatten: opts.shamefullyFlatten,
},
},
included: ctx.include,
independentLeaves: opts.independentLeaves,
layoutVersion: LAYOUT_VERSION,
packageManager: `${opts.packageManager.name}@${opts.packageManager.version}`,
pendingBuilds: ctx.pendingBuilds,
registries: ctx.registries,
skipped: Array.from(ctx.skipped).filter((pkgId) => !removedPkgIds.has(pkgId)),
store: ctx.storePath,
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,
independentLeaves: ctx.independentLeaves,
layoutVersion: LAYOUT_VERSION,
packageManager: `${opts.packageManager.name}@${opts.packageManager.version}`,
pendingBuilds: ctx.pendingBuilds,
registries: ctx.registries,
shamefullyHoist: ctx.shamefullyHoist,
skipped: Array.from(ctx.skipped),
store: ctx.storeDir,
virtualStoreDir: ctx.virtualStoreDir,
})
}