Skip to content

Commit

Permalink
feat: convert init flag to subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
adelkahomolova committed Jan 22, 2020
1 parent 569725a commit 9594d3a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
30 changes: 30 additions & 0 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Command, flags } from '@oclif/command';
import { createRootContainer } from '../inversify.config';
import { Scanner } from '../scanner';

export default class Init extends Command {
static description = 'Initialize DX Scanner configuration.';

static examples = [`$ dx-scanner init`];

static flags = {
help: flags.help({ char: 'h' }),
};

async run() {
const scanPath = process.cwd();

const container = createRootContainer({
uri: scanPath,
json: false,
auth: undefined,
ci: false,
recursive: false,
fail: 'all',
});
const scanner = container.get(Scanner);

await scanner.init(scanPath);
process.exit(0);
}
}
6 changes: 0 additions & 6 deletions src/commands/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class DXScannerCommand extends Command {
}),
json: flags.boolean({ char: 'j', description: 'Print report in JSON' }),
recursive: flags.boolean({ char: 'r', description: 'Scan all components recursively in all sub folders' }),
init: flags.boolean({ char: 'i', description: 'Initialize DX Scanner configuration' }),
ci: flags.boolean({
description: 'CI mode',
default: () => process.env.CI === 'true',
Expand Down Expand Up @@ -67,11 +66,6 @@ class DXScannerCommand extends Command {
});
const scanner = container.get(Scanner);

if (flags.init) {
await scanner.init(scanPath);
process.exit(0);
}

let scanResult = await scanner.scan();

if (scanResult.needsAuth && !flags.ci) {
Expand Down

0 comments on commit 9594d3a

Please sign in to comment.