Skip to content

Commit 01f6242

Browse files
author
Josh Goldberg
authored
Added an explicit error message for TSLint versions too low (#121)
1 parent 0c95c3f commit 01f6242

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

src/input/findTSLintConfiguration.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,16 @@ export const findTSLintConfiguration = async (
2929
config || "./tslint.json",
3030
);
3131

32-
return rawConfiguration instanceof Error
33-
? rawConfiguration
34-
: {
35-
...defaultTSLintConfiguration,
36-
...rawConfiguration,
37-
};
32+
if (rawConfiguration instanceof Error) {
33+
if (rawConfiguration.message.includes("unknown option `--print-config")) {
34+
return new Error("TSLint v5.18 required. Please update your version.");
35+
}
36+
37+
return rawConfiguration;
38+
}
39+
40+
return {
41+
...defaultTSLintConfiguration,
42+
...rawConfiguration,
43+
};
3844
};

src/input/findTslintConfiguration.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,22 @@ describe("findTSLintConfiguration", () => {
1818
);
1919
});
2020

21+
it("replaces an error with a v5.18 request when the --print-config option is unsupported", async () => {
22+
// Arrange
23+
const stderr = "unknown option `--print-config";
24+
const dependencies = { exec: createStubThrowingExec({ stderr }) };
25+
26+
// Act
27+
const result = await findTSLintConfiguration(dependencies, undefined);
28+
29+
// Assert
30+
expect(result).toEqual(
31+
expect.objectContaining({
32+
message: "TSLint v5.18 required. Please update your version.",
33+
}),
34+
);
35+
});
36+
2137
it("defaults the configuration file when one isn't provided", async () => {
2238
// Arrange
2339
const dependencies = { exec: createStubExec() };

0 commit comments

Comments
 (0)