Skip to content

Added explicit error for TSLint not being found #837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/input/findTSLintConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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."),
Expand Down
19 changes: 19 additions & 0 deletions src/input/findTslintConfiguration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down