Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// TODO: Try to reproduce this issue with a test in supi
logger.debug({ message: `Failed to link bins of "${alias}" to "${binPath}". This is probably not an issue.` })
return false
}
return dep.hasBin && dep.installable !== false
})
.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 })
}
}
)
// Linking should happen after removing orphans
// Otherwise would've been removed
for (const { alias, manifest, path } of linkedPkgs) {
// TODO: cover with test that linking reports with correct dependency types
const stu = specsToUpsert.find((s) => s.alias === manifest.name)
await symlinkDirectRootDependency(path, destModules, alias, {
fromDependenciesField: stu?.saveType ?? opts.targetDependenciesField,
linkedPackage: manifest,
prefix: opts.dir,
})
}
const linkToBin = maybeOpts?.linkToBin || path.join(destModules, '.bin')
await linkBinsOfPackages(linkedPkgs.map((p) => ({ manifest: p.manifest, location: p.path })), linkToBin, {
warn: (message: string) => logger.warn({ message, prefix: opts.dir }),
})
let newPkg!: ImporterManifest
if (opts.targetDependenciesField) {
newPkg = await save(opts.dir, opts.manifest, specsToUpsert)
for (const { alias } of specsToUpsert) {
updatedWantedLockfile.importers[importerId].specifiers[alias] = getSpecFromPackageManifest(newPkg, alias)
}
} else {
newPkg = opts.manifest
}
const lockfileOpts = { forceSharedFormat: opts.forceSharedLockfile }
if (opts.useLockfile) {
await writeLockfiles({
currentLockfile: updatedCurrentLockfile,