Skip to content

Commit

Permalink
cleanup(core): improve prettier bin path resolution (#18672)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michsior14 authored Aug 22, 2023
1 parent 9123271 commit 3f3f247
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions packages/nx/src/command-line/format/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import { readNxJson } from '../../config/configuration';
import { ProjectGraph } from '../../config/project-graph';
import { chunkify } from '../../utils/chunkify';
import { allFileData } from '../../utils/all-file-data';
import { gte } from 'semver';

const PRETTIER_PATH = getPrettierPath();

Expand Down Expand Up @@ -214,9 +213,6 @@ function sortTsConfig() {
}

function getPrettierPath() {
const prettierVersion = readModulePackageJson('prettier').packageJson.version;
if (gte(prettierVersion, '3.0.0')) {
return require.resolve('prettier/bin/prettier.cjs');
}
return require.resolve('prettier/bin-prettier');
const { bin } = readModulePackageJson('prettier').packageJson;
return require.resolve(path.join('prettier', bin as string));
}
2 changes: 1 addition & 1 deletion packages/nx/src/utils/package-json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export interface PackageJson {
peerDependenciesMeta?: Record<string, { optional: boolean }>;
resolutions?: Record<string, string>;
overrides?: PackageOverride;
bin?: Record<string, string>;
bin?: Record<string, string> | string;
workspaces?:
| string[]
| {
Expand Down

1 comment on commit 3f3f247

@vercel
Copy link

@vercel vercel bot commented on 3f3f247 Aug 22, 2023

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-dev-git-master-nrwl.vercel.app
nx.dev
nx-five.vercel.app

Please sign in to comment.