-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support NCU_VERBOSITY=debug environment variable
Support NCU_VERBOSITY=debug which tells ncu to log CLI commands and HTTP requests to the command line for debugging.
- Loading branch information
1 parent
55c780e
commit 4f84166
Showing
9 changed files
with
90 additions
and
8 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
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
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,29 @@ | ||
'use strict'; | ||
|
||
const chalk = require('chalk'); | ||
const util = require('util'); | ||
|
||
const VERBOSITY = { | ||
NONE: 0, | ||
DEBUG: 2 | ||
}; | ||
|
||
let verbosity = VERBOSITY.NONE; | ||
|
||
exports.isDebugVerbosity = function() { | ||
return verbosity === VERBOSITY.DEBUG; | ||
}; | ||
|
||
exports.setVerbosityFromEnv = function() { | ||
const env = (process.env.NCU_VERBOSITY || '').toUpperCase(); | ||
if (Object.keys(VERBOSITY).includes(env)) { | ||
verbosity = VERBOSITY[env]; | ||
} | ||
}; | ||
|
||
exports.debuglog = function(...args) { | ||
// Prepend a line break in case it's logged while the spinner is running | ||
console.error(chalk.green(util.format('\n[DEBUG]', ...args))); | ||
}; | ||
|
||
exports.VERBOSITY = VERBOSITY; |