Skip to content
This repository has been archived by the owner on Nov 4, 2022. It is now read-only.

Commit

Permalink
Adding logger.debug method and --verbose mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
henvic committed Mar 4, 2015
1 parent a697020 commit e30e697
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bin/gh.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,18 @@ var path = require('path'),
pkg = require('../package.json'),
semver = require('semver'),
tracker = require('../lib/tracker'),
configs = require('../lib/configs');
configs = require('../lib/configs'),
verbose = process.argv.indexOf('--verbose') === true;

// Check node version
function isCompatibleNodeVersion() {
return semver.satisfies(process.version, pkg.engines.node);
}

if (verbose) {
process.env.GH_VERBOSE = true;
}

if (!isCompatibleNodeVersion()) {
logger.error('Please update your NodeJS version: http://nodejs.org/download');
}
Expand Down
6 changes: 6 additions & 0 deletions lib/cmd-anonymizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ CmdAnonymizer.prototype.isValueInOptions = function(options, value) {
CmdAnonymizer.prototype.classify = function(word) {
var arg = this.extractArgument(word);

if (arg === 'verbose') {
this.invoked.push(word);
this.last = 'verbose';
return;
}

if (this.shorthands && this.shorthands[arg]) {
this.invoked.push(word);
this.last = this.shorthands[arg];
Expand Down
7 changes: 7 additions & 0 deletions lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ var slice = Array.prototype.slice,
function logger() {
}

logger.debug = function() {
if (process.env.GH_VERBOSE) {
arguments[0] = 'DEBUG: ' + arguments[0];
console.log.apply(this, arguments);
}
};

logger.error = function() {
arguments[0] = 'fatal: ' + arguments[0];
console.error.apply(this, arguments);
Expand Down

0 comments on commit e30e697

Please sign in to comment.