Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (fileSystem.existsSync(shrinkwrapFullPath)) {
throw new Error('`npm-shrinkwrap.json` was found while using lockfile.\n'
+ 'Please run your command again without `--file=' + targetFile + '` flag.');
}
const manifestFile = fileSystem.readFileSync(manifestFileFullPath);
const lockFile = fileSystem.readFileSync(lockFileFullPath, 'utf-8');
analytics.add('local', true);
analytics.add('generating-node-dependency-tree', {
lockFile: true,
targetFile,
});
const lockFileType = targetFile.endsWith('yarn.lock') ?
lockFileParser.LockfileType.yarn : lockFileParser.LockfileType.npm;
const resolveModuleSpinnerLabel = `Analyzing npm dependencies for ${lockFileFullPath}`;
debug(resolveModuleSpinnerLabel);
return spinner(resolveModuleSpinnerLabel)
.then(() => {
const strictOutOfSync = _.get(options, 'strictOutOfSync') !== 'false';
return lockFileParser
.buildDepTree(manifestFile, lockFile, options.dev, lockFileType, strictOutOfSync);
})
// clear spinner in case of success or failure
.then(spinner.clear(resolveModuleSpinnerLabel))
.catch((error) => {
spinner.clear(resolveModuleSpinnerLabel)();
throw error;
});
throw new Error('Manifest file yarn.lock not found at location: ' +
manifestFileFullPath);
}
if (!manifestFileFullPath && lockFileFullPath) {
throw new Error('Detected a lockfile at location: '
+ lockFileFullPath + '\n However the yarn.lock is missing!');
}
const manifestFile = await fs.readFile(manifestFileFullPath, 'utf-8');
const lockFile = await fs.readFile(lockFileFullPath, 'utf-8');
const defaultManifestFileName = path.relative(root, manifestFileFullPath);
const strictOutOfSync = _.get(options, 'strictOutOfSync', true);
return lockFileParser.buildDepTree(manifestFile, lockFile, options.dev,
lockFileParser.LockfileType.yarn, strictOutOfSync, defaultManifestFileName);
}
'` flag.',
);
}
const manifestFile = fs.readFileSync(manifestFileFullPath, 'utf-8');
const lockFile = fs.readFileSync(lockFileFullPath, 'utf-8');
analytics.add('local', true);
analytics.add('generating-node-dependency-tree', {
lockFile: true,
targetFile,
});
const lockFileType = targetFile.endsWith('yarn.lock')
? lockFileParser.LockfileType.yarn
: lockFileParser.LockfileType.npm;
const resolveModuleSpinnerLabel = `Analyzing npm dependencies for ${lockFileFullPath}`;
debug(resolveModuleSpinnerLabel);
try {
await spinner(resolveModuleSpinnerLabel);
const strictOutOfSync = options.strictOutOfSync !== false;
return lockFileParser.buildDepTree(
manifestFile,
lockFile,
options.dev,
lockFileType,
strictOutOfSync,
);
} finally {
await spinner.clear(resolveModuleSpinnerLabel);
}
throw new Error('Manifest file package.json not found at location: ' +
manifestFileFullPath);
}
if (!manifestFileFullPath && lockFileFullPath) {
throw new Error('Detected a lockfile at location: '
+ lockFileFullPath + '\n However the package.json is missing!');
}
const manifestFile = await fs.readFile(manifestFileFullPath, 'utf-8');
const lockFile = await fs.readFile(lockFileFullPath, 'utf-8');
const defaultManifestFileName = path.relative(root, manifestFileFullPath);
const strictOutOfSync = _.get(options, 'strictOutOfSync', true);
return lockFileParser.buildDepTree(manifestFile, lockFile, options.dev,
lockFileParser.LockfileType.npm, strictOutOfSync, defaultManifestFileName);
}