don't raise error when no packages present - fixes #58

This commit is contained in:
silverwind 2022-10-26 15:36:46 +02:00
parent caf2043fa1
commit 3c4402129b
Signed by: silverwind
GPG Key ID: 2E62B41C93869443
3 changed files with 10 additions and 1 deletions

1
fixtures/empty.json Normal file

@ -0,0 +1 @@
{}

@ -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("");

@ -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 => {