diff --git a/bin/options.js b/bin/options.js index 09c91db..bb09bda 100644 --- a/bin/options.js +++ b/bin/options.js @@ -51,6 +51,10 @@ const yargs = require('yargs') describe: 'skip publishing', type: 'boolean' }) + .option('debug', { + describe: 'output debugging information', + type: 'boolean' + }) .option('cwd', { requiresArg: true, alias: 'c', @@ -62,4 +66,9 @@ const yargs = require('yargs') .alias('help', 'h') .demandOption(['prefix', 'message', 'branch']); +if (yargs.argv.debug) { + // Debug must be enabled before other requires in order to work + require('debug').enable('git-snapshot:*'); +} + module.exports = yargs; diff --git a/index.js b/index.js index f1e0f73..9f7a1eb 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ const path = require('path'); const chalk = require('chalk'); -const debug = require('debug')('git-snapshot'); +const debug = require('debug')('git-snapshot:'); const fs = require('fs-extra'); const tempy = require('tempy'); const git = require('./lib/git'); diff --git a/lib/git.js b/lib/git.js index 6597796..cda5240 100644 --- a/lib/git.js +++ b/lib/git.js @@ -1,5 +1,5 @@ const chalk = require('chalk'); -const debug = require('debug')('git'); +const debug = require('debug')('git-snapshot:git'); const execa = require('execa'); /**