Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
opts: {
binsDir: string,
dryRun?: boolean,
modulesDir: string,
muteLogs?: boolean,
rootDir: string,
},
) {
const results = await Promise.all([
removeBins(dependency.name, opts),
!opts.dryRun && remove(path.join(opts.modulesDir, dependency.name)) as any, // tslint:disable-line:no-any
])
const uninstalledPkg = results[0]
if (!opts.muteLogs) {
rootLogger.debug({
prefix: opts.rootDir,
removed: {
dependencyType: dependency.dependenciesField === 'devDependencies' && 'dev' ||
dependency.dependenciesField === 'optionalDependencies' && 'optional' ||
dependency.dependenciesField === 'dependencies' && 'prod' ||
undefined,
name: dependency.name,
version: uninstalledPkg?.version,
},
})
}
}
destModulesDirReal = await fs.realpath(destModulesDir)
} catch (err) {
if (err.code === 'ENOENT') {
await makeDir(destModulesDir)
destModulesDirReal = await fs.realpath(destModulesDir)
} else {
throw err
}
}
const dependencyRealocation = await fs.realpath(dependencyLocation)
const dest = path.join(destModulesDirReal, importAs)
const { reused } = await symlinkDir(dependencyRealocation, dest)
if (reused) return // if the link was already present, don't log
rootLogger.debug({
added: {
dependencyType: opts.fromDependenciesField && DEP_TYPE_BY_DEPS_FIELD_NAME[opts.fromDependenciesField] as DependencyType,
linkedFrom: dependencyRealocation,
name: importAs,
realName: opts.linkedPackage.name,
version: opts.linkedPackage.version,
},
prefix: opts.prefix,
})
}
.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,
})
}),
)