From 3c4402129b95e9cda64ba8a20704e8b4457291db Mon Sep 17 00:00:00 2001 From: silverwind Date: Wed, 26 Oct 2022 15:36:46 +0200 Subject: [PATCH] don't raise error when no packages present - fixes #58 --- fixtures/empty.json | 1 + test.js | 8 ++++++++ updates.js | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 fixtures/empty.json diff --git a/fixtures/empty.json b/fixtures/empty.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/fixtures/empty.json @@ -0,0 +1 @@ +{} diff --git a/test.js b/test.js index 4fb8c95..b05523c 100644 --- a/test.js +++ b/test.js @@ -8,6 +8,7 @@ import {tmpdir} from "os"; const __dirname = dirname(fileURLToPath(import.meta.url)); const testFile = resolve(__dirname, "fixtures/test.json"); +const emptyFile = resolve(__dirname, "fixtures/empty.json"); const testPkg = JSON.parse(readFileSync(testFile, "utf8")); const testDir = mkdtempSync(join(tmpdir(), "updates-")); const script = join(__dirname, "bin/updates.js"); @@ -121,6 +122,13 @@ test("simple", async () => { expect(exitCode).toEqual(0); }); +test("empty", async () => { + const {stdout, stderr, exitCode} = await execa(script, ["-C", "-G", githubUrl, "-f", emptyFile]); + expect(stderr).toEqual(""); + expect(stdout).toContain("No packages"); + expect(exitCode).toEqual(0); +}); + test("version", async () => { const {stdout, stderr, exitCode} = await execa(script, ["-v"]); expect(stderr).toEqual(""); diff --git a/updates.js b/updates.js index e5a97b3..d8332f8 100755 --- a/updates.js +++ b/updates.js @@ -657,7 +657,7 @@ async function main() { } if (!Object.keys(deps).length && !Object.keys(maybeUrlDeps).length) { - finish(new Error(`No packages ${include || exclude ? "match the given filters" : "found"}`)); + finish(`No packages ${include || exclude ? "match the given filters" : "present"}`); } const entries = await Promise.all(Object.keys(deps).map(key => {