From 4e126ad7b33a287604c6c941d526a6306b22330a Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Fri, 20 Nov 2020 20:32:47 -0500 Subject: [PATCH] Added explicit error for TSLint not being found --- src/input/findTSLintConfiguration.ts | 7 +++++++ src/input/findTslintConfiguration.test.ts | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/input/findTSLintConfiguration.ts b/src/input/findTSLintConfiguration.ts index 24e3d52a9..b39240f50 100644 --- a/src/input/findTSLintConfiguration.ts +++ b/src/input/findTSLintConfiguration.ts @@ -19,6 +19,13 @@ export type FindTSLintConfigurationDependencies = { }; const knownErrors = [ + [ + "command not found", + () => + new Error( + "The 'tslint' command was not found. Either install it globally or add it as a devDependency of this repository.", + ), + ], [ "unknown option `--print-config", () => new Error("TSLint v5.18 required. Please update your version."), diff --git a/src/input/findTslintConfiguration.test.ts b/src/input/findTslintConfiguration.test.ts index cf0e9b4f9..fd6958614 100644 --- a/src/input/findTslintConfiguration.test.ts +++ b/src/input/findTslintConfiguration.test.ts @@ -49,6 +49,25 @@ describe("findTSLintConfiguration", () => { ); }); + it("replaces an error with a v5.18 request when the tslint command is not found", async () => { + // Arrange + const stderr = "/bin/sh tslint: command not found"; + const dependencies = createStubDependencies({ + exec: createStubThrowingExec({ stderr }), + }); + + // Act + const result = await findTSLintConfiguration(dependencies, undefined); + + // Assert + expect(result).toEqual( + expect.objectContaining({ + message: + "The 'tslint' command was not found. Either install it globally or add it as a devDependency of this repository.", + }), + ); + }); + it("replaces an error with a v5.18 request when the --print-config option is unsupported", async () => { // Arrange const stderr = "unknown option `--print-config";