From 2557f7239ce25ddd509205110f399dcd6afdc0b1 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 14 May 2018 11:59:34 -0400 Subject: [PATCH] debug new classes --- .vscode/launch.json | 11 +++++++---- src/bw.js | 3 +-- src/main.ts | 5 ++++- src/program.ts | 4 +++- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index a67268c429..4878666cf0 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,11 +9,14 @@ "cwd": "${workspaceRoot}", "program": "${workspaceFolder}/node_modules/ts-node/dist/bin.js", "args": [ + "-r", + "tsconfig-paths/register", "${workspaceFolder}/src/main.ts", - "login", - "kyle@sdfdf.com", - "mypassword" - ] + "sync" + ], + "env": { + "NODE_ENV": "debug" + }, } ] } diff --git a/src/bw.js b/src/bw.js index 56fc04e9f9..0c59bd2b08 100644 --- a/src/bw.js +++ b/src/bw.js @@ -3,5 +3,4 @@ require('tsconfig-paths').register(); require('ts-node').register(); const main = require('./main.ts'); -const m = new main.Main(); -m.run(); +new main.Main().run(); diff --git a/src/main.ts b/src/main.ts index 5014e99205..04f31470e5 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,4 +1,3 @@ - import { AuthService } from 'jslib/services/auth.service'; import { LoginCommand } from './commands/login.command'; @@ -101,3 +100,7 @@ export class Main { this.program.run(); } } + +if (process.env.NODE_ENV === 'debug') { + new Main().run(); +} diff --git a/src/program.ts b/src/program.ts index 557bb6991e..69865b827c 100644 --- a/src/program.ts +++ b/src/program.ts @@ -20,6 +20,7 @@ export class Program { .action(async (email: string, password: string, cmd: program.Command) => { const command = new LoginCommand(this.main.authService); await command.run(email, password, cmd); + process.exit(); }); program @@ -27,6 +28,7 @@ export class Program { .description('Log out of the current Bitwarden user account.') .action((cmd) => { console.log('Logging out...'); + process.exit(); }); program @@ -37,6 +39,7 @@ export class Program { console.log('Syncing...'); const command = new SyncCommand(this.main.syncService); await command.run(cmd); + process.exit(); }); program @@ -74,7 +77,6 @@ export class Program { console.log(id); }); - program .parse(process.argv); }