Skip to content
This repository has been archived by the owner on Oct 9, 2024. It is now read-only.

Commit

Permalink
Add env variable to remove color from command result stdout (#579)
Browse files Browse the repository at this point in the history
* add env variable to remove color from command result stdout

* remove color (proper way)
  • Loading branch information
priyamsahoo authored Jun 16, 2023
1 parent 959ad90 commit b989459
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/utils/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export function withInterpreter(
let command = `${executable} ${args}`; // base case

const newEnv = Object.assign({}, process.env, {
NO_COLOR: "1", // ensure none of the output produce color characters
ANSIBLE_FORCE_COLOR: "0", // ensure output is parseable (no ANSI)
PYTHONBREAKPOINT: "0", // We want to be sure that python debugger is never
// triggered, even if we mistakenly left a breakpoint() there while
Expand Down
7 changes: 6 additions & 1 deletion test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@ if (isWindows()) {
process.exit(PRETEST_ERR_RC);
}

// We don't require colors in the stdout of the command results.
process.env["NO_COLOR"] = "1";

const command = "ansible-lint --version";
const env = process.env;

try {
const result = execSync(command);
const result = execSync(command, { env: env });
console.info(`Detected: ${result}`);
} catch (e) {
console.error(`error: test requisites not met, '${command}' returned ${e}`);
Expand Down

0 comments on commit b989459

Please sign in to comment.