Skip to content

Commit

Permalink
fix(align-deps): reduce diff output (#1979)
Browse files Browse the repository at this point in the history
  • Loading branch information
tido64 authored Oct 27, 2022
1 parent e823ec9 commit 8a8c548
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .changeset/nervous-bags-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
18 changes: 16 additions & 2 deletions packages/align-deps/src/commands/check.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { info } from "@rnx-kit/console";
import { pickValues } from "@rnx-kit/tools-language";
import type { PackageManifest } from "@rnx-kit/tools-node/package";
import { readPackage } from "@rnx-kit/tools-node/package";
import chalk from "chalk";
import { diffLinesUnified } from "jest-diff";
Expand All @@ -12,6 +14,18 @@ import { resolve } from "../preset";
import type { Command, ErrorCode, Options } from "../types";
import { checkPackageManifestUnconfigured } from "./vigilant";

const visibleKeys = [
"name",
"version",
"dependencies",
"peerDependencies",
"devDependencies",
];

function stringify(manifest: PackageManifest): string {
return JSON.stringify(pickValues(manifest, visibleKeys), undefined, 2);
}

export function checkPackageManifest(
manifestPath: string,
options: Options,
Expand Down Expand Up @@ -58,8 +72,8 @@ export function checkPackageManifest(
);

// Don't fail when manifests only have whitespace differences.
const updatedManifestJson = JSON.stringify(updatedManifest, undefined, 2);
const normalizedManifestJson = JSON.stringify(manifest, undefined, 2);
const updatedManifestJson = stringify(updatedManifest);
const normalizedManifestJson = stringify(manifest);

if (updatedManifestJson !== normalizedManifestJson) {
if (options.write) {
Expand Down

0 comments on commit 8a8c548

Please sign in to comment.