Skip to content

Commit

Permalink
feat: add -W --why option for debug
Browse files Browse the repository at this point in the history
  • Loading branch information
PopGoesTheWza committed Mar 16, 2021
1 parent 12f3aad commit 4fc2062
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 2 deletions.
47 changes: 46 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@
"strip-bom": "^4.0.0",
"ts2gas": "^3.6.4",
"typescript": "^4.2.3",
"watch": "^1.0.2"
"watch": "^1.0.2",
"why-is-node-running": "^2.2.0"
},
"devDependencies": {
"@types/chai": "^4.2.15",
Expand Down
13 changes: 13 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env node

const log = require('why-is-node-running'); // should be your first require

/**
* @license
* Copyright Google Inc.
Expand Down Expand Up @@ -50,6 +52,8 @@ import {Conf} from './conf';
import {PROJECT_NAME} from './constants';
import {spinner, stopSpinner} from './utils';

let onExit = () => {};

// instantiate the config singleton (and loads environment variables as a side effect)
const {auth, ignore, project} = Conf.get();

Expand Down Expand Up @@ -98,6 +102,13 @@ commander
project.path = commander['project'];
});

/**
* Display some debugging info upon exit.
*/
commander.option('-W, --why', `Display some debugging info upon exit.`).on('option:why', () => {
onExit = log;
});

/**
* Logs the user in. Saves the client credentials to an rc file.
* @name login
Expand Down Expand Up @@ -412,3 +423,5 @@ if (args.length === 0) {
}
}
})();

onExit();

0 comments on commit 4fc2062

Please sign in to comment.