From 19ff58fde96bfc2b996a66b9119cd317661c0e28 Mon Sep 17 00:00:00 2001 From: Konstantin Yegupov Date: Mon, 10 Jun 2019 11:16:39 +0100 Subject: [PATCH] fix: fix broken `snyk help` --- src/cli/commands/help.ts | 6 +++--- test/acceptance/cli.acceptance.test.ts | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cli/commands/help.ts b/src/cli/commands/help.ts index 60aabe7b5fe..42e28866343 100644 --- a/src/cli/commands/help.ts +++ b/src/cli/commands/help.ts @@ -3,7 +3,7 @@ import * as path from 'path'; import * as Debug from 'debug'; const debug = Debug('snyk'); -export async function help(item: string | boolean) { +export = async function help(item: string | boolean) { if (!item || item === true || typeof item !== 'string') { item = 'usage'; } @@ -14,9 +14,9 @@ export async function help(item: string | boolean) { const filename = path.resolve(__dirname, '../../../help', item + '.txt'); try { - await fs.readFile(filename, 'utf8'); + return await fs.readFile(filename, 'utf8'); } catch (error) { debug(error); return `'${item}' help can't be found at location: ${filename}`; } -} +}; diff --git a/test/acceptance/cli.acceptance.test.ts b/test/acceptance/cli.acceptance.test.ts index d790fc57524..9a53adbb3bc 100644 --- a/test/acceptance/cli.acceptance.test.ts +++ b/test/acceptance/cli.acceptance.test.ts @@ -2801,6 +2801,10 @@ test('`test --insecure`', async (t) => { }); }); +test("snyk help doesn't crash", async (t) => { + t.match(await cli.help(), /Usage/); +}); + /** * We can't expect all test environments to have Maven installed * So, hijack the system exec call and return the expected output