Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public regenerateAndValidateShrinkwrap(shrinkwrapFile: ShrinkwrapFile|undefined): boolean {
console.log('Creating temp projects...');
if (fsx.existsSync(this._rushConfiguration.tempModulesFolder)) {
Utilities.dangerouslyDeletePath(this._rushConfiguration.tempModulesFolder);
}
Utilities.createFolderWithRetry(this._rushConfiguration.tempModulesFolder);
let shrinkwrapIsValid: boolean = true;
if (shrinkwrapFile) {
// Check any pinned dependencies first
this._rushConfiguration.pinnedVersions.forEach((version: string, dependency: string) => {
if (!shrinkwrapFile.hasCompatibleDependency(dependency, version)) {
console.log(colors.yellow(
`${os.EOL}The NPM shrinkwrap file does satisfy pinned version ${dependency}`
+ ` ("${version}").`));
shrinkwrapIsValid = false;
}
});
function createSymlinksForTopLevelProject(localPackage: Package): void {
const localModuleFolder: string = path.join(localPackage.folderPath, 'node_modules');
// Sanity check
if (localPackage.parent) {
throw new Error('The provided package is not a top-level project');
}
// The root-level folder is the project itself, so we simply delete its node_modules
// to start clean
console.log('Purging ' + localModuleFolder);
Utilities.dangerouslyDeletePath(localModuleFolder);
if (localPackage.children.length > 0) {
Utilities.createFolderWithRetry(localModuleFolder);
for (const child of localPackage.children) {
createSymlinksForDependencies(child);
}
}
}