Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix broken snyk help #566

Merged
merged 1 commit into from
Jun 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/cli/commands/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand All @@ -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}`;
}
}
};
4 changes: 4 additions & 0 deletions test/acceptance/cli.acceptance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down