Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
include: ctx.include,
lockfileDir: opts.lockfileDir,
registries: ctx.registries,
skipped: ctx.skipped,
storeController: opts.storeController,
virtualStoreDir: ctx.virtualStoreDir,
wantedLockfile: updatedCurrentLockfile,
},
)
// 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)
await Promise.all(pkgAliases.map(async (pkgAlias) => {
await symlinkDependency(depNode.location, opts.modulesDir, pkgAlias)
}))
}
.map(async ({ rootAlias, depGraphNode }) => {
if (
!opts.dryRun &&
(await symlinkDependency(depGraphNode.peripheralLocation, modulesDir, rootAlias)).reused
) return
const isDev = manifest.devDependencies?.[depGraphNode.name]
const isOptional = manifest.optionalDependencies?.[depGraphNode.name]
rootLogger.debug({
added: {
dependencyType: isDev && 'dev' || isOptional && 'optional' || 'prod',
id: depGraphNode.packageId,
latest: opts.outdatedDependencies[depGraphNode.packageId],
name: rootAlias,
realName: depGraphNode.name,
version: depGraphNode.version,
},
prefix: rootDir,
})
}),
await limitLinking(() => symlinkDependency(pkg.peripheralLocation, modules, childAlias))
}),
Promise.all(importer.linkedDependencies.map((linkedDependency) => {
const depLocation = resolvePath(importer.rootDir, linkedDependency.resolution.directory)
return symlinkDirectRootDependency(depLocation, importer.modulesDir, linkedDependency.alias, {
fromDependenciesField: linkedDependency.dev && 'devDependencies' || linkedDependency.optional && 'optionalDependencies' || 'dependencies',
linkedPackage: linkedDependency,
prefix: importer.rootDir,
})
})),
),