Skip to content

Commit 7c1318f

Browse files
arturovtAgentEnder
authored andcommitted
fix(core): handle object form of bin field in getPrettierPath (#35680)
Co-authored-by: Craigory Coppola <craigorycoppola@gmail.com> (cherry picked from commit a174979)
1 parent a3acfd6 commit 7c1318f

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

packages/nx/src/command-line/format/format.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,12 @@ function getPrettierPath() {
277277

278278
const { packageJson, path: packageJsonPath } =
279279
readModulePackageJson('prettier');
280-
prettierPath = path.resolve(
281-
path.dirname(packageJsonPath),
282-
packageJson.bin as string
283-
);
280+
const bin = packageJson.bin;
281+
const binPath = typeof bin === 'string' ? bin : bin?.['prettier'];
282+
if (!binPath) {
283+
throw new Error(`Could not find prettier binary in ${packageJsonPath}`);
284+
}
285+
prettierPath = path.resolve(path.dirname(packageJsonPath), binPath);
284286

285287
return prettierPath;
286288
}

0 commit comments

Comments
 (0)