Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 });