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

chore: Convert help command handling to typescript #547

Merged
merged 1 commit into from
Jun 3, 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
20 changes: 0 additions & 20 deletions src/cli/commands/help.js

This file was deleted.

22 changes: 22 additions & 0 deletions src/cli/commands/help.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as fs from 'then-fs';
import * as path from 'path';
import * as Debug from 'debug';
const debug = Debug('snyk');
lili2311 marked this conversation as resolved.
Show resolved Hide resolved

export async function help(item: string | boolean) {
if (!item || item === true || typeof item !== 'string') {
item = 'usage';
}

// cleanse the filename to only contain letters
// aka: /\W/g but figured this was easier to read
item = item.replace(/[^a-z-]/gi, '');

const filename = path.resolve(__dirname, '../../../help', item + '.txt');
try {
await fs.readFile(filename, 'utf8');
} catch (error) {
debug(error);
return `'${item}' help can't be found at location: ${filename}`;
}
}
2 changes: 1 addition & 1 deletion src/cli/commands/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {SEVERITIES, WIZARD_SUPPORTED_PMS} from '../../lib/snyk-test/common';
import * as Debug from 'debug';
import {TestOptions} from '../../lib/types';
import {isLocalFolder} from '../../lib/detect';
import { MethodArgs, ArgsOptions } from '../args';
import { MethodArgs } from '../args';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused import


const debug = Debug('snyk');
const SEPARATOR = '\n-------------------------------------------------------\n';
Expand Down