Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async readLockfile () {
try {
return await readYamlFile(path.join(projectPath, WANTED_LOCKFILE)) // tslint:disable-line
} catch (err) {
if (err.code === 'ENOENT') return null!
throw err
}
},
async writePackageJson (pkgJson: object) {
async function requirePackagesManifest (dir: string): Promise<{packages?: string[]} | null> {
try {
return await readYamlFile<{ packages?: string[] }>(path.join(dir, WORKSPACE_MANIFEST_FILENAME))
} catch (err) {
if (err['code'] === 'ENOENT') { // tslint:disable-line
return null
}
throw err
}
}
async function _read (
lockfilePath: string,
prefix: string,
opts: {
wantedVersion?: number,
ignoreIncompatible: boolean,
},
): Promise {
let lockfile
try {
lockfile = await readYamlFile(lockfilePath)
} catch (err) {
if ((err as NodeJS.ErrnoException).code !== 'ENOENT') {
throw err
}
return null
}
// tslint:disable:no-string-literal
if (typeof lockfile?.['specifiers'] !== 'undefined') {
lockfile.importers = {
'.': {
specifiers: lockfile['specifiers'],
},
}
delete lockfile['specifiers']
for (const depType of DEPENDENCIES_FIELDS) {
if (lockfile[depType]) {
async function readPackageYaml (filePath: string) {
try {
return await readYamlFile(filePath)
} catch (err) {
if (err.name !== 'YAMLException') throw err
err.message += `\nin ${filePath}`
err['code'] = 'ERR_PNPM_YAML_PARSE'
throw err
}
}