Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
message: `The store server disabled upload requests, could not upload ${depNode.packageId}`,
prefix: opts.lockfileDir,
})
} else {
logger.warn({
error: err,
message: `An error occurred while uploading ${depNode.packageId}`,
prefix: opts.lockfileDir,
})
}
}
}
} catch (err) {
if (depNode.optional) {
// TODO: add parents field to the log
const pkg = await readPackageFromDir(path.join(depNode.peripheralLocation)) as DependencyManifest
skippedOptionalDependencyLogger.debug({
details: err.toString(),
package: {
id: depNode.packageId,
name: pkg.name,
version: pkg.version,
},
prefix: opts.lockfileDir,
reason: 'build_failure',
})
return
}
throw err
}
}
)
const integrity = fileIntegrities
.reduce((acc, info) => {
Object.assign(acc, info)
return acc
}, {})
await writeJsonFile(path.join(target, 'integrity.json'), integrity, { indent: undefined })
} else {
// TODO: save only filename: {size}
await writeJsonFile(path.join(target, 'integrity.json'), filesIndex, { indent: undefined })
}
finishing.resolve(undefined)
let pkgName: string | undefined = opts.pkgName
if (!pkgName || opts.fetchRawManifest) {
const manifest = await readPkgFromDir(tempLocation) as DependencyManifest
bundledManifest.resolve(pickBundledManifest(manifest))
if (!pkgName) {
pkgName = manifest.name
}
}
const unpacked = path.join(target, 'node_modules', pkgName)
await makeDir(path.dirname(unpacked))
// rename(oldPath, newPath) is an atomic operation, so we do it at the
// end
await renameOverwrite(tempLocation, unpacked)
await symlinkDir(unpacked, linkToUnpacked)
if (isLocalTarballDep && opts.resolution['integrity']) { // tslint:disable-line:no-string-literal
await fs.writeFile(path.join(target, TARBALL_INTEGRITY_FILENAME), opts.resolution['integrity'], 'utf8') // tslint:disable-line:no-string-literal
export async function _unlinkPkgs (
pkgNames: string[],
opts: StrictInstallOptions,
importers: Array<{ modulesDir: string, prefix: string }>,
) {
if (importers.length > 1) throw new Error('Unlink not implemented for multiple importers yet')
const importer = importers[0]
const pkg = await readPkgFromDir(importer.prefix)
const allDeps = getAllDependenciesFromPackage(pkg)
const packagesToInstall: string[] = []
for (const pkgName of pkgNames) {
try {
if (!await isExternalLink(opts.store, importer.modulesDir, pkgName)) {
logger.warn({
message: `${pkgName} is not an external link`,
prefix: importer.prefix,
})
continue
}
} catch (err) {
if (err['code'] !== 'ENOENT') throw err // tslint:disable-line:no-string-literal
}
await rimraf(path.join(importer.modulesDir, pkgName))
async function readBundledManifest (dir: string): Promise {
return pickBundledManifest(await readPkgFromDir(dir) as DependencyManifest)
}