How to use the @microsoft/rush-lib.JsonFile.saveJsonFile 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
}

        // We will NOT locally link this package; add it as a regular dependency.
        tempPackageJson.dependencies[pair.packageName] = pair.packageVersion;

        if (shrinkwrapFile) {
          if (!shrinkwrapFile.hasCompatibleDependency(pair.packageName, pair.packageVersion, tempProjectName)) {
            console.log(colors.yellow(
              `${os.EOL}The NPM shrinkwrap file does not provide dependency ${pair.packageName}`
              + ` ("${pair.packageVersion}") required by "${rushProject.packageName}".`));
            shrinkwrapIsValid = false;
          }
        }
      }

      JsonFile.saveJsonFile(tempPackageJson, tempPackageJsonFilename);
    }

    console.log('Writing common/package.json');
    const commonPackageJsonFilename: string = path.join(this._rushConfiguration.commonFolder, 'package.json');
    JsonFile.saveJsonFile(commonPackageJson, commonPackageJsonFilename);

    return shrinkwrapIsValid;
  }
}
github microsoft / rushstack / rush / rush / src / utilities / TempModuleGenerator.ts View on Github external
if (shrinkwrapFile) {
          if (!shrinkwrapFile.hasCompatibleDependency(pair.packageName, pair.packageVersion, tempProjectName)) {
            console.log(colors.yellow(
              `${os.EOL}The NPM shrinkwrap file does not provide dependency ${pair.packageName}`
              + ` ("${pair.packageVersion}") required by "${rushProject.packageName}".`));
            shrinkwrapIsValid = false;
          }
        }
      }

      JsonFile.saveJsonFile(tempPackageJson, tempPackageJsonFilename);
    }

    console.log('Writing common/package.json');
    const commonPackageJsonFilename: string = path.join(this._rushConfiguration.commonFolder, 'package.json');
    JsonFile.saveJsonFile(commonPackageJson, commonPackageJsonFilename);

    return shrinkwrapIsValid;
  }
}
github microsoft / rushstack / rush / rush / src / actions / LinkAction.ts View on Github external
throw error;
        } else {
          const commonRootPackage: Package = Package.createFromNpm(npmPackage);

          const commonPackageLookup: PackageLookup = new PackageLookup();
          commonPackageLookup.loadTree(commonRootPackage);

          const rushLinkJson: IRushLinkJson = { localLinks: {} };

          for (const rushProject of this._rushConfiguration.projects) {
            console.log(os.EOL + 'LINKING: ' + rushProject.packageName);
            linkProject(rushProject, commonRootPackage, commonPackageLookup, this._rushConfiguration, rushLinkJson);
          }

          console.log(`Writing "${this._rushConfiguration.rushLinkJsonFilename}"`);
          JsonFile.saveJsonFile(rushLinkJson, this._rushConfiguration.rushLinkJsonFilename);

          stopwatch.stop();
          console.log(os.EOL + colors.green(`Rush link finished successfully. (${stopwatch.toString()})`));
          console.log(os.EOL + 'Next you should probably run: "rush rebuild -q"');
        }
      });
    });