Skip to content

Commit

Permalink
fix(core): Add missing formatFiles to migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsharvey committed Jun 11, 2022
1 parent 9721844 commit 85dead6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
formatFiles,
joinPathFragments,
readProjectConfiguration,
Tree,
Expand All @@ -9,7 +10,9 @@ import { SwcExecutorOptions } from '../../utils/schema';

type OldSwcExecutorOptions = SwcExecutorOptions & { swcrcPath?: string };

export function updateSwcrcPath(tree: Tree) {
export async function updateSwcrcPath(tree: Tree) {
let changesMade = false;

forEachExecutorOptions(
tree,
'@nrwl/js:swc',
Expand All @@ -30,8 +33,14 @@ export function updateSwcrcPath(tree: Tree) {
executorOptions.swcrc = newSwcrcPath;

updateProjectConfiguration(tree, projectName, projectConfig);

changesMade = true;
}
);

if (changesMade) {
await formatFiles(tree);
}
}

export default updateSwcrcPath;
3 changes: 3 additions & 0 deletions packages/nx-plugin/src/generators/migration/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
readJson,
writeJson,
joinPathFragments,
formatFiles,
} from '@nrwl/devkit';
import type { Tree } from '@nrwl/devkit';
import type { Schema } from './schema';
Expand Down Expand Up @@ -152,6 +153,8 @@ export async function migrationGenerator(host: Tree, schema: Schema) {
readJson<PackageJson>(host, packageJsonPath)
);
}

await formatFiles(host);
}

export default migrationGenerator;
Expand Down
3 changes: 3 additions & 0 deletions packages/nx/src/migrations/update-14-2-0/add-json-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
getRelativeProjectJsonSchemaPath,
updateProjectConfiguration,
} from '../../generators/utils/project-configuration';
import { formatFiles } from '@nrwl/devkit';

export default async function (tree: Tree) {
// update nx.json $schema
Expand Down Expand Up @@ -43,4 +44,6 @@ export default async function (tree: Tree) {
...projConfig,
} as ProjectConfiguration);
}

await formatFiles(tree);
}

0 comments on commit 85dead6

Please sign in to comment.