Skip to content

Commit

Permalink
feat(core): install packages after migrations have run and dependenci…
Browse files Browse the repository at this point in the history
…es haven been modified
  • Loading branch information
leosvelperez committed May 21, 2022
1 parent e439718 commit e32b6ea
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/nx/src/command-line/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,8 @@ async function runMigrations(
(shouldCreateCommits ? ', with each applied in a dedicated commit' : '')
);

const depsBeforeMigrations = getStringifiedPackageJsonDeps(root);

const migrations: {
package: string;
name: string;
Expand Down Expand Up @@ -988,11 +990,24 @@ async function runMigrations(
logger.info(`---------------------------------------------------------`);
}

const depsAfterMigrations = getStringifiedPackageJsonDeps(root);
if (depsBeforeMigrations !== depsAfterMigrations) {
runInstall();
}

logger.info(
`NX Successfully finished running migrations from '${opts.runMigrations}'`
);
}

function getStringifiedPackageJsonDeps(root: string): string {
const { dependencies, devDependencies } = readJsonFile<PackageJson>(
join(root, 'package.json')
);

return JSON.stringify([dependencies, devDependencies]);
}

function commitChangesIfAny(commitMessage: string): {
sha: string | null;
reasonForNoCommit: string | null;
Expand Down

0 comments on commit e32b6ea

Please sign in to comment.