diff --git a/src/actions.ts b/src/actions.ts index 31e7a4fe..85e89dd7 100644 --- a/src/actions.ts +++ b/src/actions.ts @@ -1,4 +1,7 @@ -import { getInput, setOutput } from "@actions/core"; +import { + getInput, + setOutput, +} from "@actions/core"; import { format } from "./dotnet"; diff --git a/src/dotnet.ts b/src/dotnet.ts index 49557600..bba24f57 100644 --- a/src/dotnet.ts +++ b/src/dotnet.ts @@ -1,4 +1,8 @@ -import { debug, info, warning } from "@actions/core"; +import { + debug, + info, + warning, +} from "@actions/core"; import { exec } from "@actions/exec"; import { context } from "@actions/github"; import { which } from "@actions/io"; @@ -27,9 +31,7 @@ function formatOnlyChangedFiles(onlyChangedFiles: boolean): boolean { } export async function format(options: FormatOptions): Promise { - const execOptions: ExecOptions = { - ignoreReturnCode: true, - }; + const execOptions: ExecOptions = { ignoreReturnCode: true }; const dotnetFormatOptions = ["format", "--check"]; diff --git a/src/files.ts b/src/files.ts index 0008e744..aa0fb30d 100644 --- a/src/files.ts +++ b/src/files.ts @@ -1,33 +1,36 @@ import { extname } from "path"; import { getInput } from "@actions/core"; -import { context, getOctokit } from "@actions/github"; +import { + context, + getOctokit, +} from "@actions/github"; -enum fileStatus { +enum FileStatus { /** * The file was added. */ - added = "added", + Added = "added", /** * The mode of the file was changed or there are unknown changes because the diff was truncated. */ - changed = "changed", + Changed = "changed", /** * The content of the file was modified. */ - modified = "modified", + Modified = "modified", /** * The file was removed. */ - removed = "removed", + Removed = "removed", /** * The file was renamed. */ - renamed = "renamed", + Renamed = "renamed", } const fileTypes = [ @@ -49,7 +52,7 @@ export async function getPullRequestFiles(): Promise { }); return files - .filter(file => file.status !== fileStatus.removed) - .filter(file => fileTypes.includes(extname(file.filename))) - .map(file => file.filename); + .filter((file) => file.status !== FileStatus.Removed) + .filter((file) => fileTypes.includes(extname(file.filename))) + .map((file) => file.filename); } diff --git a/src/main.ts b/src/main.ts index 1e6e2d5e..fbe1433b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,6 +1,12 @@ -import { getInput, setFailed } from "@actions/core"; +import { + getInput, + setFailed, +} from "@actions/core"; -import { check, fix } from "./actions"; +import { + check, + fix, +} from "./actions"; export async function run(): Promise { try { @@ -19,9 +25,12 @@ export async function run(): Promise { throw Error(`Unsupported action "${action}"`); } } catch (error) { - setFailed(error.message); - throw error; + if (error instanceof Error) { + setFailed(error.message); + } else { + throw error; + } } } -run(); +void run();