How to use the @microsoft/rush-lib.Utilities.createFolderWithRetry function in @microsoft/rush-lib

To help you get started, we’ve selected a few @microsoft/rush-lib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / rushstack / rush / rush / src / utilities / TempModuleGenerator.ts View on Github external
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;
        }
      });
    } else {
      shrinkwrapIsValid = false;
    }
github microsoft / rushstack / rush / rush / src / actions / LinkAction.ts View on Github external
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);
    }
  }
}
github microsoft / rushstack / rush / rush / src / actions / LinkAction.ts View on Github external
function createSymlinksForDependencies(localPackage: Package): void {
  const localModuleFolder: string = path.join(localPackage.folderPath, 'node_modules');

  if (!localPackage.symlinkTargetFolderPath) {
    // Program bug
    throw Error('localPackage.symlinkTargetFolderPath was not assigned');
  }

  // This is special case for when localPackage.name has the form '@scope/name',
  // in which case we need to create the '@scope' folder first.
  const parentFolderPath: string = path.dirname(localPackage.folderPath);
  if (parentFolderPath && parentFolderPath !== localPackage.folderPath) {
    if (!fsx.existsSync(parentFolderPath)) {
      Utilities.createFolderWithRetry(parentFolderPath);
    }
  }

  if (localPackage.children.length === 0) {
    // If there are no children, then we can symlink the entire folder
    createSymlink(localPackage.symlinkTargetFolderPath, localPackage.folderPath, SymlinkKind.Directory);
  } else {
    // If there are children, then we need to symlink each item in the folder individually
    Utilities.createFolderWithRetry(localPackage.folderPath);

    for (const filename of fsx.readdirSync(localPackage.symlinkTargetFolderPath)) {
      if (filename.toLowerCase() !== 'node_modules') {
        // Create the symlink
        let symlinkKind: SymlinkKind = SymlinkKind.File;

        const linkSource: string = path.join(localPackage.folderPath, filename);
github microsoft / rushstack / rush / rush / src / actions / LinkAction.ts View on Github external
// This is special case for when localPackage.name has the form '@scope/name',
  // in which case we need to create the '@scope' folder first.
  const parentFolderPath: string = path.dirname(localPackage.folderPath);
  if (parentFolderPath && parentFolderPath !== localPackage.folderPath) {
    if (!fsx.existsSync(parentFolderPath)) {
      Utilities.createFolderWithRetry(parentFolderPath);
    }
  }

  if (localPackage.children.length === 0) {
    // If there are no children, then we can symlink the entire folder
    createSymlink(localPackage.symlinkTargetFolderPath, localPackage.folderPath, SymlinkKind.Directory);
  } else {
    // If there are children, then we need to symlink each item in the folder individually
    Utilities.createFolderWithRetry(localPackage.folderPath);

    for (const filename of fsx.readdirSync(localPackage.symlinkTargetFolderPath)) {
      if (filename.toLowerCase() !== 'node_modules') {
        // Create the symlink
        let symlinkKind: SymlinkKind = SymlinkKind.File;

        const linkSource: string = path.join(localPackage.folderPath, filename);
        let linkTarget: string = path.join(localPackage.symlinkTargetFolderPath, filename);

        const linkStats: fsx.Stats = fsx.lstatSync(linkTarget);

        if (linkStats.isSymbolicLink()) {
          const targetStats: fsx.Stats = fsx.statSync(linkTarget);
          if (targetStats.isDirectory()) {
            // Neither a junction nor a directory-symlink can have a directory-symlink
            // as its target; instead, we must obtain the real physical path.
github microsoft / rushstack / rush / rush / src / actions / LinkAction.ts View on Github external
// (even though it has the ability to create them both), so the safest policy
            // is to always make a junction and always to the real physical path.
            linkTarget = fsx.realpathSync(linkTarget);
            symlinkKind = SymlinkKind.Directory;
          }
        } else if (linkStats.isDirectory()) {
          symlinkKind = SymlinkKind.Directory;
        }

        createSymlink(linkTarget, linkSource, symlinkKind);
      }
    }
  }

  if (localPackage.children.length > 0) {
    Utilities.createFolderWithRetry(localModuleFolder);

    for (const child of localPackage.children) {
      createSymlinksForDependencies(child);
    }
  }
}