Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
PnpmLinkManager._createSymlinksForTopLevelProject(localPackage);
if (!this._rushConfiguration.experimentsConfiguration.configuration.legacyIncrementalBuildDependencyDetection) {
pnpmProjectDependencyManifest.save();
} else {
pnpmProjectDependencyManifest.deleteIfExists();
}
// Also symlink the ".bin" folder
const projectFolder: string = path.join(localPackage.folderPath, 'node_modules');
const projectBinFolder: string = path.join(localPackage.folderPath, 'node_modules', '.bin');
// Return type is Promise because the API returns Promise.all()
return pnpmLinkBins(projectFolder, projectBinFolder)
.then(() => { /* empty block */ });
}
})
.map(async (alias) => {
const dep = depGraph[childrenToLink[alias]]
return {
location: dep.peripheralLocation,
manifest: await dep.fetchingBundledManifest?.() || (await readPackageFromDir(dep.peripheralLocation) as DependencyManifest),
}
}),
)
await linkBinsOfPackages(pkgs, binPath, { warn: opts.warn })
// link also the bundled dependencies` bins
if (depNode.hasBundledDependencies) {
const bundledModules = path.join(depNode.peripheralLocation, 'node_modules')
await linkBins(bundledModules, binPath, { warn: opts.warn })
}
}
lockfileDir: opts.lockfileDir,
registries: opts.registries,
virtualStoreDir: opts.virtualStoreDir,
},
)
const aliasesByDependencyPath = await hoistGraph(deps, opts.lockfile.importers['.'].specifiers, {
dryRun: false,
match,
modulesDir: opts.modulesDir,
})
const bin = path.join(opts.modulesDir, '.bin')
const warn = (message: string) => logger.warn({ message, prefix: path.join(opts.modulesDir, '../..') })
try {
await linkBins(opts.modulesDir, bin, { allowExoticManifests: true, warn })
} catch (err) {
// Some packages generate their commands with lifecycle hooks.
// At this stage, such commands are not generated yet.
// For now, we don't hoist such generated commands.
// Related issue: https://github.com/pnpm/pnpm/issues/2071
}
return aliasesByDependencyPath
}
const pkgRoot = !independent
? path.join(ctx.virtualStoreDir, pkgIdToFilename(depPath, opts.lockfileDir), 'node_modules', pkgInfo.name)
: await (
async () => {
const { dir } = await opts.storeController.getPackageLocation(pkgSnapshot.id || depPath, pkgInfo.name, {
lockfileDir: opts.lockfileDir,
targetEngine: opts.sideEffectsCacheRead && !opts.force && ENGINE_NAME || undefined,
})
return dir
}
)()
try {
if (!independent) {
const modules = path.join(ctx.virtualStoreDir, pkgIdToFilename(depPath, opts.lockfileDir), 'node_modules')
const binPath = path.join(pkgRoot, 'node_modules', '.bin')
await linkBins(modules, binPath, { warn })
}
await runPostinstallHooks({
depPath,
extraBinPaths: ctx.extraBinPaths,
optional: pkgSnapshot.optional === true,
pkgRoot,
prepare: pkgSnapshot.prepare,
rawConfig: opts.rawConfig,
rootNodeModulesDir: ctx.rootModulesDir,
unsafePerm: opts.unsafePerm || false,
})
pkgsThatWereRebuilt.add(relDepPath)
} catch (err) {
if (pkgSnapshot.optional) {
// TODO: add parents field to the log
skippedOptionalDependencyLogger.debug({
function linkBinsOfImporter ({ modulesDir, binsDir, rootDir }: ImporterToLink) {
const warn = (message: string) => logger.warn({ message, prefix: rootDir })
return linkBins(modulesDir, binsDir, { allowExoticManifests: true, warn })
}