Skip to content

Commit

Permalink
fix(js): do not ensure prettier package presence when skipPackageJson…
Browse files Browse the repository at this point in the history
… is true
  • Loading branch information
leosvelperez committed Sep 24, 2024
1 parent 2c86214 commit 68fa008
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 6 additions & 2 deletions packages/js/src/generators/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,12 @@ export async function initGeneratorInternal(
: () => {};
tasks.push(installTask);

if (!schema.skipFormat && schema.setUpPrettier) {
ensurePackage('prettier', prettierVersion);
if (!schema.skipFormat) {
if (!schema.skipPackageJson) {
ensurePackage('prettier', prettierVersion);
}
// even if skipPackageJson === true, we can safely run formatFiles, prettier might
// have been installed earlier and if not, the formatFiles function still handles it
await formatFiles(tree);
}

Expand Down
6 changes: 5 additions & 1 deletion packages/js/src/generators/setup-prettier/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ export async function setupPrettierGenerator(
});

if (!options.skipFormat) {
ensurePackage('prettier', prettierVersion);
if (!options.skipPackageJson) {
ensurePackage('prettier', prettierVersion);
}
// even if skipPackageJson === true, we can safely run formatFiles, prettier might
// have been installed earlier and if not, the formatFiles function still handles it
await formatFiles(tree);
}

Expand Down

0 comments on commit 68fa008

Please sign in to comment.