Fix debug message logic (don't suggest --debug if it is already being used)

Change-type: patch
This commit is contained in:
Paulo Castro 2020-11-18 00:34:16 +00:00
parent 65f053dd6e
commit a4fd7d6118
3 changed files with 6 additions and 6 deletions

View File

@ -224,7 +224,7 @@ export const printErrorMessage = function (message: string) {
console.error(line); console.error(line);
}); });
console.error(`\n${getHelp}\n`); console.error(`\n${getHelp()}\n`);
}; };
export const printExpectedErrorMessage = function (message: string) { export const printExpectedErrorMessage = function (message: string) {

View File

@ -15,8 +15,6 @@
* limitations under the License. * limitations under the License.
*/ */
const DEBUG_MODE = !!process.env.DEBUG;
export const reachingOut = `\ export const reachingOut = `\
If you need help, or just want to say hi, don't hesitate in reaching out If you need help, or just want to say hi, don't hesitate in reaching out
through our discussion and support forums at https://forums.balena.io through our discussion and support forums at https://forums.balena.io
@ -27,14 +25,16 @@ create a new one at: https://github.com/balena-io/balena-cli/issues/\
const debugHint = `\ const debugHint = `\
Additional information may be available with the \`--debug\` flag. Additional information may be available with the \`--debug\` flag.
`; \n`;
export const help = `\ export const help = `\
For help, visit our support forums: https://forums.balena.io For help, visit our support forums: https://forums.balena.io
For bug reports or feature requests, see: https://github.com/balena-io/balena-cli/issues/ For bug reports or feature requests, see: https://github.com/balena-io/balena-cli/issues/
`; `;
export const getHelp = (DEBUG_MODE ? '' : debugHint) + help; // Note that the value of process.env.DEBUG may change after the --debug flag
// is parsed, so its evaluation cannot happen at module loading time.
export const getHelp = () => (process.env.DEBUG ? '' : debugHint) + help;
export const balenaAsciiArt = `\ export const balenaAsciiArt = `\
_ _ _ _

View File

@ -187,7 +187,7 @@ describe('printErrorMessage() function', () => {
expect(consoleError.getCall(0).args[0]).to.equal(expectedOutputMessages[0]); expect(consoleError.getCall(0).args[0]).to.equal(expectedOutputMessages[0]);
expect(consoleError.getCall(1).args[0]).to.equal(expectedOutputMessages[1]); expect(consoleError.getCall(1).args[0]).to.equal(expectedOutputMessages[1]);
expect(consoleError.getCall(2).args[0]).to.equal(expectedOutputMessages[2]); expect(consoleError.getCall(2).args[0]).to.equal(expectedOutputMessages[2]);
expect(consoleError.getCall(3).args[0]).to.equal(`\n${getHelp}\n`); expect(consoleError.getCall(3).args[0]).to.equal(`\n${getHelp()}\n`);
consoleError.restore(); consoleError.restore();
}); });