Skip to content

Commit c350c39

Browse files
committed
Adds a test to cover NO_COLOR
1 parent 1485f11 commit c350c39

File tree

3 files changed

+161
-2
lines changed

3 files changed

+161
-2
lines changed

src/executeCommandLine/executeCommandLine.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ namespace ts {
6868
}
6969

7070
function defaultIsPretty(sys: System) {
71-
return !!sys.writeOutputIsTTY && sys.writeOutputIsTTY();
71+
return !!sys.writeOutputIsTTY && sys.writeOutputIsTTY() && !sys.getEnvironmentVariable("NO_COLOR");
7272
}
7373

7474
function shouldBePretty(sys: System, options: CompilerOptions | BuildOptions) {
@@ -90,7 +90,7 @@ namespace ts {
9090
}
9191

9292
function createColors(sys: System) {
93-
const showColors = defaultIsPretty(sys) && !sys.getEnvironmentVariable("NO_COLOR");
93+
const showColors = defaultIsPretty(sys);
9494
if (!showColors) {
9595
return {
9696
bold: (str: string) => str,

src/testRunner/unittests/tsc/runWithoutArgs.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,14 @@ namespace ts {
1414
fs: () => loadProjectFromFiles({}),
1515
commandLineArgs: [],
1616
});
17+
18+
verifyTsc({
19+
scenario: "runWithoutArgs",
20+
subScenario: "does not add color when NO_COLOR is set",
21+
fs: () => loadProjectFromFiles({}),
22+
commandLineArgs: [],
23+
environmentVariables: { NO_COLOR: "true" }
24+
});
25+
1726
});
1827
}
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
Input::
2+
//// [/lib/lib.d.ts]
3+
4+
5+
6+
7+
Output::
8+
/lib/tsc
9+
Version FakeTSVersion
10+
tsc: The TypeScript Compiler - Version FakeTSVersion
11+
12+
COMMON COMMANDS
13+
14+
tsc
15+
Compiles the current project (tsconfig.json in the working directory.)
16+
17+
tsc app.ts util.ts
18+
Ignoring tsconfig.json, compiles the specified files with default compiler options.
19+
20+
tsc -b
21+
Build a composite project in the working directory.
22+
23+
tsc --init
24+
Creates a tsconfig.json with the recommended settings in the working directory.
25+
26+
tsc -p ./path/to/tsconfig.json
27+
Compiles the TypeScript project located at the specified path.
28+
29+
tsc --help --all
30+
An expanded version of this information, showing all possible compiler options
31+
32+
tsc --noEmit
33+
tsc --target esnext
34+
Compiles the current project, with additional settings.
35+
36+
COMMAND LINE FLAGS
37+
38+
--help, -h
39+
Print this message.
40+
41+
--watch, -w
42+
Watch input files.
43+
44+
--all
45+
Show all compiler options.
46+
47+
--version, -v
48+
Print the compiler's version.
49+
50+
--init
51+
Initializes a TypeScript project and creates a tsconfig.json file.
52+
53+
--project, -p
54+
Compile the project given the path to its configuration file, or to a folder with a 'tsconfig.json'.
55+
56+
--build, -b
57+
Build one or more projects and their dependencies, if out of date
58+
59+
--showConfig
60+
Print the final configuration instead of building.
61+
62+
COMMON COMPILER OPTIONS
63+
64+
--pretty
65+
Enable color and formatting in the output to make compiler errors easier to read
66+
type: boolean
67+
default: true
68+
69+
--target, -t
70+
Set the JavaScript language version for emitted JavaScript and include compatible library declarations.
71+
one of: es3, es5, es6, es2015, es2016, es2017, es2018, es2019, es2020, es2021, esnext
72+
default: ES3
73+
74+
--module, -m
75+
Specify what module code is generated.
76+
one of: none, commonjs, amd, system, umd, es6, es2015, es2020, esnext
77+
78+
--lib
79+
Specify a set of bundled library declaration files that describe the target runtime environment.
80+
one or more: es5, es6, es2015, es7, es2016, es2017, es2018, es2019, es2020, es2021, esnext, dom, dom.iterable, webworker, webworker.importscripts, webworker.iterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol, es2020.bigint, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2021.promise, es2021.string, es2021.weakref, esnext.array, esnext.symbol, esnext.asynciterable, esnext.intl, esnext.bigint, esnext.string, esnext.promise, esnext.weakref
81+
82+
--allowJs
83+
Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files.
84+
type: boolean
85+
default: false
86+
87+
--checkJs
88+
Enable error reporting in type-checked JavaScript files.
89+
type: boolean
90+
default: false
91+
92+
--jsx
93+
Specify what JSX code is generated.
94+
one of: preserve, react-native, react, react-jsx, react-jsxdev
95+
default: undefined
96+
97+
--declaration, -d
98+
Generate .d.ts files from TypeScript and JavaScript files in your project.
99+
type: boolean
100+
default: `false`, unless `composite` is set
101+
102+
--declarationMap
103+
Create sourcemaps for d.ts files.
104+
type: boolean
105+
default: false
106+
107+
--emitDeclarationOnly
108+
Only output d.ts files and not JavaScript files.
109+
type: boolean
110+
default: false
111+
112+
--sourceMap
113+
Create source map files for emitted JavaScript files.
114+
type: boolean
115+
default: false
116+
117+
--outFile
118+
Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output.
119+
120+
--outDir
121+
Specify an output folder for all emitted files.
122+
123+
--removeComments
124+
Disable emitting comments.
125+
type: boolean
126+
default: false
127+
128+
--noEmit
129+
Disable emitting files from a compilation.
130+
type: boolean
131+
default: false
132+
133+
--strict
134+
Enable all strict type-checking options.
135+
type: boolean
136+
default: false
137+
138+
--types
139+
Specify type package names to be included without being referenced in a source file.
140+
141+
--esModuleInterop
142+
Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility.
143+
type: boolean
144+
default: false
145+
146+
You can learn about all of the compiler options at https://aka.ms/tsconfig-reference
147+
148+
exitCode:: ExitStatus.DiagnosticsPresent_OutputsSkipped
149+
150+

0 commit comments

Comments
 (0)