Repository: microsoft/TypeScript
File: src/compiler/executeCommandLine.ts (TypeScript)

Code before:
    else if (fileExtensionIsOneOf(path, supportedJSExtensionsFlat)) {
        return "JavaScript";
    }
    else if (fileExtensionIs(path, Extension.Json)) {
        return "JSON";
    }
    else {
        return "Other";
    }
}

function updateReportDiagnostic(
    sys: System,
    existing: DiagnosticReporter,
    options: CompilerOptions | BuildOptions,
): DiagnosticReporter {
    return shouldBePretty(sys, options) ?
        createDiagnosticReporter(sys, /*pretty*/ true) :
        existing;
}

function defaultIsPretty(sys: System) {
    return !!sys.writeOutputIsTTY && sys.writeOutputIsTTY() && !sys.getEnvironmentVariable("NO_COLOR");
}

function shouldBePretty(sys: System, options: CompilerOptions | BuildOptions) {
    if (!options || typeof options.pretty === "undefined") {
        return defaultIsPretty(sys);
    }
    return options.pretty;
}

function getOptionsForHelp(commandLine: ParsedCommandLine) {
    // Sort our options by their names, (e.g. "--noImplicitAny" comes before "--watch")
    return !!commandLine.options.all ?
        toSorted(optionDeclarations.concat(tscBuildOption), (a, b) => compareStringsCaseInsensitive(a.name, b.name)) :
        filter(optionDeclarations.concat(tscBuildOption), v => !!v.showInSimplifiedHelpView);
}

function printVersion(sys: System) {
    sys.write(getDiagnosticText(Diagnostics.Version_0, version) + sys.newLine);
}

function createColors(sys: System) {
    const showColors = defaultIsPretty(sys);
    if (!showColors) {
        return {
            bold: (str: string) => str,
            blue: (str: string) => str,
            blueBackground: (str: string) => str,
            brightWhite: (str: string) => str,

Review comment (bug):
`FORCE_COLOR` is treated as enabled for any non-empty value, but in common FORCE_COLOR semantics a value of "0" explicitly disables color. With the current check, `FORCE_COLOR=0` will incorrectly force pretty output on. Consider parsing the value and treating "0" (and possibly "false") as disabling, while still allowing "1"/"2"/"3" to force-enable.
```suggestion
    const forceColor = sys.getEnvironmentVariable("FORCE_COLOR");
    if (forceColor !== undefined) {
        const normalized = forceColor.trim().toLowerCase();
        if (normalized === "0" || normalized === "false") {
            return false;
        }
```

Code after:
    else if (fileExtensionIsOneOf(path, supportedJSExtensionsFlat)) {
        return "JavaScript";
    }
    else if (fileExtensionIs(path, Extension.Json)) {
        return "JSON";
    }
    else {
        return "Other";
    }
}

function updateReportDiagnostic(
    sys: System,
    existing: DiagnosticReporter,
    options: CompilerOptions | BuildOptions,
): DiagnosticReporter {
    return shouldBePretty(sys, options) ?
        createDiagnosticReporter(sys, /*pretty*/ true) :
        existing;
}

function defaultIsPretty(sys: System) {
    if (sys.getEnvironmentVariable("NO_COLOR")) {
        return false;
    }
    if (sys.getEnvironmentVariable("FORCE_COLOR")) {
        return true;
    }
    return !!sys.writeOutputIsTTY && sys.writeOutputIsTTY();
}

function shouldBePretty(sys: System, options: CompilerOptions | BuildOptions) {
    if (!options || typeof options.pretty === "undefined") {
        return defaultIsPretty(sys);
    }
    return options.pretty;
}

function getOptionsForHelp(commandLine: ParsedCommandLine) {
    // Sort our options by their names, (e.g. "--noImplicitAny" comes before "--watch")
    return !!commandLine.options.all ?
        toSorted(optionDeclarations.concat(tscBuildOption), (a, b) => compareStringsCaseInsensitive(a.name, b.name)) :
        filter(optionDeclarations.concat(tscBuildOption), v => !!v.showInSimplifiedHelpView);
}

function printVersion(sys: System) {
    sys.write(getDiagnosticText(Diagnostics.Version_0, version) + sys.newLine);
}

function createColors(sys: System) {
    const showColors = defaultIsPretty(sys);