Skip to content

Commit

Permalink
fix(version): only apply prettier if it was explicitly installed (#3406)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHenry committed Nov 2, 2022
1 parent b31a92c commit 0161bbe
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions commands/version/lib/git-add.js
Expand Up @@ -4,7 +4,7 @@ const fs = require("fs");
const log = require("npmlog");
const path = require("path");
const slash = require("slash");
const { workspaceRoot } = require("@nrwl/devkit");
const { workspaceRoot, readJsonFile } = require("@nrwl/devkit");
const childProcess = require("@lerna/child-process");

module.exports.gitAdd = gitAdd;
Expand All @@ -13,7 +13,12 @@ let resolvedPrettier;
function resolvePrettier() {
if (!resolvedPrettier) {
try {
// If the workspace has prettier installed, apply it to the updated files
// If the workspace has prettier (explicitly) installed, apply it to the updated files
const packageJson = readJsonFile(path.join(workspaceRoot, "package.json"));
const hasPrettier = packageJson.devDependencies?.prettier || packageJson.dependencies?.prettier;
if (!hasPrettier) {
return;
}
const prettierPath = path.join(workspaceRoot, "node_modules", "prettier");
// eslint-disable-next-line import/no-dynamic-require, global-require
resolvedPrettier = require(prettierPath);
Expand Down

0 comments on commit 0161bbe

Please sign in to comment.