-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Intercept calls to console.{warn,error,log}
This clears the tests output and will allow smarter debug later
- Loading branch information
Showing
9 changed files
with
68 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
'use strict'; | ||
|
||
const chalk = require('chalk'); | ||
const debug = require('../utils/debug'); | ||
|
||
module.exports = function showHelp (commands, tarecPkg) { | ||
|
||
const version = tarecPkg.version; | ||
console.log(`Tarec ${chalk.blue(version)}`); | ||
console.log("\nAvailable commands:"); | ||
debug.log(`Tarec ${chalk.blue(version)}`); | ||
debug.log("\nAvailable commands:"); | ||
const availableCommands = commands.commands; | ||
Object.keys(availableCommands).forEach(commandName => { | ||
console.log(" * " + chalk.blue(commandName)); | ||
debug.log(" * " + chalk.blue(commandName)); | ||
const command = availableCommands[commandName]; | ||
if (command.help) { | ||
console.log(" " + command.help) | ||
debug.log(" " + command.help) | ||
} | ||
}) | ||
console.log(`\nType ${chalk.blue('tarec <command> --help')} for more information on a specific command`); | ||
}); | ||
debug.log(`\nType ${chalk.blue('tarec <command> --help')} for more information on a specific command`); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
class Debugger { | ||
|
||
constructor() { | ||
this.enabled = false; | ||
} | ||
|
||
enable() { | ||
this.enabled = true; | ||
} | ||
|
||
log(...args) { | ||
if (!this.enabled) { | ||
return; | ||
} | ||
console.log(...args); | ||
} | ||
|
||
error(...args) { | ||
// always show errors | ||
console.error(...args); | ||
} | ||
|
||
warn(...args) { | ||
if (!this.enabled) { | ||
return; | ||
} | ||
console.warn(...args); | ||
} | ||
} | ||
|
||
module.exports = new Debugger(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters