Skip to content

Commit

Permalink
fix(core): Add missing formatFiles to migrations
Browse files Browse the repository at this point in the history
Fixes #10665
  • Loading branch information
danielsharvey authored and FrozenPandaz committed Jun 15, 2022
1 parent 63ae3ae commit 09baf95
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
@@ -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
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
@@ -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';
Expand Down Expand Up @@ -43,4 +44,6 @@ export default async function (tree: Tree) {
...projConfig,
} as ProjectConfiguration);
}

await formatChangedFilesWithPrettierIfAvailable(tree);
}

1 comment on commit 09baf95

@vercel
Copy link

@vercel vercel bot commented on 09baf95 Jun 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

nx-dev – ./

nx-dev-nrwl.vercel.app
nx-five.vercel.app
nx.dev
nx-dev-git-master-nrwl.vercel.app

Please sign in to comment.