Skip to content

Commit cd66607

Browse files
authored
Merge pull request gitgitgadget#1786 from gitgitgadget/dependabot/npm_and_yarn/json-stable-stringify-1.2.1
build(deps): bump json-stable-stringify from 1.1.1 to 1.2.1
2 parents c096f14 + 58cdc79 commit cd66607

File tree

5 files changed

+156
-50
lines changed

5 files changed

+156
-50
lines changed

.vscode/launch.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"name": "Jest Debug Current File",
3535
"type": "node",
3636
"request": "launch",
37+
"runtimeArgs": [ "--experimental-vm-modules" ],
3738
"program": "${workspaceFolder}/node_modules/jest/bin/jest.js",
3839
"args": [
3940
"--runInBand",

lib/json-util.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@ export function fromJSON<T>(input: string): T {
55
}
66

77
export function toJSON<T>(input: T): string {
8-
return stringify(input);
8+
const result = stringify(input);
9+
if (typeof result !== "string") throw new Error(`Could not convert ${input} to JSON`);
10+
return result;
911
}
1012

1113
export function toPrettyJSON<T>(input: T): string {
12-
return stringify(input, { space: 4 });
14+
const result = stringify(input, { space: 4 });
15+
if (typeof result !== "string") throw new Error(`Could not convert ${input} to JSON`);
16+
return result;
1317
}

package-lock.json

Lines changed: 139 additions & 46 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
"commander": "^12.1.0",
8181
"dugite": "^2.7.1",
8282
"html-to-text": "^9.0.5",
83-
"json-stable-stringify": "^1.1.1",
83+
"json-stable-stringify": "^1.2.1",
8484
"jsonwebtoken": "^9.0.2",
8585
"mailparser": "^3.7.2",
8686
"marked": "^15.0.4",

tests/git-notes.test.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect, jest, test } from "@jest/globals";
22
import { fileURLToPath } from "url";
33
import { isDirectory } from "../lib/fs-util.js";
4-
import { git, revParse } from "../lib/git.js";
4+
import { emptyBlobName, git, revParse } from "../lib/git.js";
55
import { GitNotes } from "../lib/git-notes.js";
66
import { IPatchSeriesMetadata } from "../lib/patch-series-metadata.js";
77
import { testCreateRepo } from "./test-lib.js";
@@ -23,6 +23,14 @@ test("set/get notes", async () => {
2323
expect(await git(["log", "-p", "refs/notes/gitgitgadget"], { workDir: repo.workDir })).toMatch(/\n\+hello$/);
2424

2525
const gitURL = "https://github.com/gitgitgadget/git";
26+
// avoid network calls during tests
27+
const fakeRemote = `${repo.workDir}/.git/fake-remote`;
28+
await git(["init", "--bare", fakeRemote]);
29+
await git([`--git-dir=${fakeRemote}`, "notes", "--ref=gitgitgadget", "add", "-m", "{}", emptyBlobName]);
30+
await git([`--git-dir=${fakeRemote}`, "notes", "--ref=mail-to-commit", "add", "-m", "1", emptyBlobName]);
31+
await git([`--git-dir=${fakeRemote}`, "notes", "--ref=commit-to-mail", "add", "-m", "1", emptyBlobName]);
32+
await git(["config", `url.${fakeRemote}.insteadof`, gitURL], { workDir: repo.workDir });
33+
2634
const pullRequestURL = `${gitURL}/git/pull/1`;
2735
const metadata: IPatchSeriesMetadata = {
2836
baseCommit: "0123456789012345678901234567890123456789",

0 commit comments

Comments
 (0)