Debug mode can now be disabled with DEBUG=0 env var

Added assignment to `process.env.DEBUG` if `process.env.DEBUG` is negative string to `lib/app.ts` and `automation/run.ts` entrypoints

Resolves: #1502
Change-type: patch
Signed-off-by: Thomas Manning <thomasm@balena.io>
This commit is contained in:
Thomas Manning 2020-02-04 02:27:06 +09:00
parent f53a69feb1
commit b3948d538c
2 changed files with 14 additions and 0 deletions

View File

@ -28,6 +28,13 @@ import {
} from './deploy-bin';
import { fixPathForMsys, ROOT, runUnderMsys } from './utils';
// DEBUG set to falsy for negative values else is truthy
process.env.DEBUG = ['0', 'no', 'false', '', undefined].includes(
process.env.DEBUG?.toLowerCase(),
)
? ''
: '1';
function exitWithError(error: Error | string): never {
console.error(`Error: ${error}`);
process.exit(1);

View File

@ -23,6 +23,13 @@ export async function run(
cliArgs = process.argv,
options: import('./preparser').AppOptions = {},
) {
// DEBUG set to falsy for negative values else is truthy
process.env.DEBUG = ['0', 'no', 'false', '', undefined].includes(
process.env.DEBUG?.toLowerCase(),
)
? ''
: '1';
// The 'pkgExec' special/internal command provides a Node.js interpreter
// for use of the standalone zip package. See pkgExec function.
if (cliArgs.length > 3 && cliArgs[2] === 'pkgExec') {