fix(core): Add missing formatFiles to migrations

Fixes nrwl/nx#10665
This commit is contained in:
Daniel Harvey 2022-06-11 23:14:13 +08:00 committed by Jason Jean
parent 63ae3ae077
commit 09baf958e8
3 changed files with 16 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import {
formatFiles,
joinPathFragments,
readProjectConfiguration,
Tree,
@ -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',
@ -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;

View File

@ -8,6 +8,7 @@ import {
readJson,
writeJson,
joinPathFragments,
formatFiles,
} from '@nrwl/devkit';
import type { Tree } from '@nrwl/devkit';
import type { Schema } from './schema';
@ -152,6 +153,8 @@ export async function migrationGenerator(host: Tree, schema: Schema) {
readJson<PackageJson>(host, packageJsonPath)
);
}
await formatFiles(host);
}
export default migrationGenerator;

View File

@ -1,3 +1,4 @@
import { formatChangedFilesWithPrettierIfAvailable } from 'nx/src/generators/internal-utils/format-changed-files-with-prettier-if-available';
import { ProjectConfiguration } from '../../config/workspace-json-project-json';
import type { Tree } from '../../generators/tree';
import { updateJson } from '../../generators/utils/json';
@ -43,4 +44,6 @@ export default async function (tree: Tree) {
...projConfig,
} as ProjectConfiguration);
}
await formatChangedFilesWithPrettierIfAvailable(tree);
}