Skip to content

Commit

Permalink
revert: add update-notifier back
Browse files Browse the repository at this point in the history
  • Loading branch information
prokopsimek committed Jan 30, 2020
1 parent 72980a8 commit cec2fde
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
26 changes: 13 additions & 13 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import { PracticeImpact } from './model';
import Init from './commands/init';
import Practices from './commands/practices';
import _ from 'lodash';
import updateNotifier from 'update-notifier';
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
const pjson = require('../package.json');

class DXScannerCommand {
static async run() {
const cmder = new commander.Command();
cmder.version(pjson.version);

// cmd: init
cmder.name('dx-scanner');
// default cmd config
cmder.version(pjson.version).name('dx-scanner');

// cmd: run
cmder
Expand All @@ -41,6 +41,7 @@ class DXScannerCommand {
.option('-j --json', 'print report in JSON', false)
.option('-r --recursive', 'scan all components recursively in all sub folders', false)
.action(Run.run)
.action(this.notifyUpdate)
.on('--help', () => {
console.log('');
console.log('Aliases:');
Expand All @@ -57,14 +58,16 @@ class DXScannerCommand {
cmder
.command('init')
.description('Initialize DX Scanner configuration')
.action(Init.run);
.action(Init.run)
.action(this.notifyUpdate);

// cmd: practices
cmder
.command('practices')
.description('List all practices id with name and impact')
// .description('List all practices id with name and impact')
.option('-j --json', 'print practices in JSON')
.action(Practices.run);
.action(Practices.run)
.action(this.notifyUpdate);

if (!process.argv.slice(2).length) {
cmder.help();
Expand All @@ -76,13 +79,6 @@ class DXScannerCommand {
process.exit(1);
});

// error on unknown commands
cmder.on('*', () => {
// const notifier = updateNotifier({ pkg: 'dx-scanner' });

console.log('ahojjjj');
});

await cmder.parseAsync(process.argv);
}

Expand All @@ -98,6 +94,10 @@ class DXScannerCommand {
process.exit(1);
}
};

private static notifyUpdate = () => {
updateNotifier({ pkg: pjson, updateCheckInterval: 0, shouldNotifyInNpmScript: true }).notify();
};
}

export = DXScannerCommand;
2 changes: 1 addition & 1 deletion src/scanner/Scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export class Scanner {
if (!yamlExists && !fileExists && !ymlExists && !jsonExists) {
await this.createConfiguration(filePath);
} else {
console.log(`You already have a dx-scanner config.`);
cli.warn('You already have a dx-scanner config.');
}

cli.action.stop();
Expand Down

0 comments on commit cec2fde

Please sign in to comment.