How to use the just-scripts-utils.paths.tempPath function in just-scripts-utils

To help you get started, we’ve selected a few just-scripts-utils 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 / just / packages / just-scripts / src / tasks / upgradeStackTask.ts View on Github external
function upgradePackageDeps(stackPath: string, projectPath: string, packageJson: PackageJson) {
  const templatePath = paths.tempPath(packageJson.name);
  applyTemplate(stackPath, templatePath, { name: packageJson.name });

  // Update package.json deps
  const stackPackageJson = readPackageJson(templatePath);
  if (!stackPackageJson) {
    logger.error(`Cannot find or read stack's package.json under ${stackPath}`);
    return;
  }

  const newPackageJson = mergePackageJson(packageJson, stackPackageJson);

  // If modified, the reference would be different
  logger.info(`Checking if package ${packageJson.name} should be upgraded...`);
  if (newPackageJson !== packageJson) {
    logger.info(`Package ${chalk.cyan(packageJson.name)} is being upgraded.`);
    fse.writeJsonSync(path.join(projectPath, 'package.json'), newPackageJson, { spaces: 2 });