Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
step: LockfileWalkerStep,
depth: number,
opts: {
getIndependentPackageLocation?: (packageId: string, packageName: string) => Promise,
registries: Registries,
lockfileDir: string,
virtualStoreDir: string,
},
): Promise {
const deps: Dependency[] = []
const nextSteps: LockfileWalkerStep[] = []
for (const { pkgSnapshot, relDepPath, next } of step.dependencies) {
const absolutePath = dp.resolve(opts.registries, relDepPath)
const pkgName = nameVerFromPkgSnapshot(relDepPath, pkgSnapshot).name
const modules = path.join(opts.virtualStoreDir, pkgIdToFilename(absolutePath, opts.lockfileDir), 'node_modules')
const independent = opts.getIndependentPackageLocation && packageIsIndependent(pkgSnapshot)
const allDeps = {
...pkgSnapshot.dependencies,
...pkgSnapshot.optionalDependencies,
}
deps.push({
absolutePath,
children: Object.keys(allDeps).reduce((children, alias) => {
children[alias] = dp.refToAbsolute(allDeps[alias], alias, opts.registries)
return children
}, {}),
depth,
location: !independent
? path.join(modules, pkgName)
: await opts.getIndependentPackageLocation!(pkgSnapshot.id || absolutePath, pkgName),
name: pkgName,
})
.filter((relDepPath) => !packageIsIndependent(pkgSnapshots[relDepPath]))
.map((relDepPath) => limitLinking(() => {
async () => {
const pkgSnapshot = pkgSnapshots[relDepPath]
const depPath = dp.resolve(opts.registries, relDepPath)
const pkgInfo = nameVerFromPkgSnapshot(relDepPath, pkgSnapshot)
const independent = ctx.independentLeaves && packageIsIndependent(pkgSnapshot)
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 })