Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(version): only apply prettier if it was explicitly installed #3406

Merged
merged 1 commit into from Nov 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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