mirror of
https://github.com/golangci/golangci-lint-action.git
synced 2025-12-14 15:01:15 +00:00
Explicitly check workingDirectory presence
This commit is contained in:
parent
b2c945497a
commit
b577819d42
3 changed files with 29 additions and 16 deletions
14
dist/post_run/index.js
vendored
14
dist/post_run/index.js
vendored
|
|
@ -2398,15 +2398,19 @@ function runLint(lintPath) {
|
|||
if (args.includes(`-out-format`)) {
|
||||
throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`);
|
||||
}
|
||||
const workingDirectory = path.resolve(core.getInput(`working-directory`));
|
||||
if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) {
|
||||
throw new Error(`working-directory (${workingDirectory}) was not a path`);
|
||||
const workingDirectory = core.getInput(`working-directory`);
|
||||
const cmdArgs = {};
|
||||
if (workingDirectory != ``) {
|
||||
if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) {
|
||||
throw new Error(`working-directory (${workingDirectory}) was not a path`);
|
||||
}
|
||||
cmdArgs.cwd = path.resolve(workingDirectory);
|
||||
}
|
||||
const cmd = `${lintPath} run --out-format=github-actions ${args}`.trimRight();
|
||||
core.info(`Running [${cmd}] in [${workingDirectory}] ...`);
|
||||
core.info(`Running [${cmd}] in [${cmdArgs.cwd}] ...`);
|
||||
const startedAt = Date.now();
|
||||
try {
|
||||
const res = yield execShellCommand(cmd, { cwd: workingDirectory });
|
||||
const res = yield execShellCommand(cmd, cmdArgs);
|
||||
printOutput(res);
|
||||
core.info(`golangci-lint found no issues`);
|
||||
}
|
||||
|
|
|
|||
14
dist/run/index.js
vendored
14
dist/run/index.js
vendored
|
|
@ -2410,15 +2410,19 @@ function runLint(lintPath) {
|
|||
if (args.includes(`-out-format`)) {
|
||||
throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`);
|
||||
}
|
||||
const workingDirectory = path.resolve(core.getInput(`working-directory`));
|
||||
if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) {
|
||||
throw new Error(`working-directory (${workingDirectory}) was not a path`);
|
||||
const workingDirectory = core.getInput(`working-directory`);
|
||||
const cmdArgs = {};
|
||||
if (workingDirectory != ``) {
|
||||
if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) {
|
||||
throw new Error(`working-directory (${workingDirectory}) was not a path`);
|
||||
}
|
||||
cmdArgs.cwd = path.resolve(workingDirectory);
|
||||
}
|
||||
const cmd = `${lintPath} run --out-format=github-actions ${args}`.trimRight();
|
||||
core.info(`Running [${cmd}] in [${workingDirectory}] ...`);
|
||||
core.info(`Running [${cmd}] in [${cmdArgs.cwd}] ...`);
|
||||
const startedAt = Date.now();
|
||||
try {
|
||||
const res = yield execShellCommand(cmd, { cwd: workingDirectory });
|
||||
const res = yield execShellCommand(cmd, cmdArgs);
|
||||
printOutput(res);
|
||||
core.info(`golangci-lint found no issues`);
|
||||
}
|
||||
|
|
|
|||
17
src/run.ts
17
src/run.ts
|
|
@ -1,5 +1,5 @@
|
|||
import * as core from "@actions/core"
|
||||
import { exec } from "child_process"
|
||||
import { exec, ExecOptions } from "child_process"
|
||||
import * as fs from "fs"
|
||||
import * as path from "path"
|
||||
import { promisify } from "util"
|
||||
|
|
@ -57,16 +57,21 @@ async function runLint(lintPath: string): Promise<void> {
|
|||
throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`)
|
||||
}
|
||||
|
||||
const workingDirectory = path.resolve(core.getInput(`working-directory`))
|
||||
if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) {
|
||||
throw new Error(`working-directory (${workingDirectory}) was not a path`)
|
||||
const workingDirectory = core.getInput(`working-directory`)
|
||||
const cmdArgs: ExecOptions = {}
|
||||
if (workingDirectory != ``) {
|
||||
if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) {
|
||||
throw new Error(`working-directory (${workingDirectory}) was not a path`)
|
||||
}
|
||||
|
||||
cmdArgs.cwd = path.resolve(workingDirectory)
|
||||
}
|
||||
|
||||
const cmd = `${lintPath} run --out-format=github-actions ${args}`.trimRight()
|
||||
core.info(`Running [${cmd}] in [${workingDirectory}] ...`)
|
||||
core.info(`Running [${cmd}] in [${cmdArgs.cwd}] ...`)
|
||||
const startedAt = Date.now()
|
||||
try {
|
||||
const res = await execShellCommand(cmd, { cwd: workingDirectory })
|
||||
const res = await execShellCommand(cmd, cmdArgs)
|
||||
printOutput(res)
|
||||
core.info(`golangci-lint found no issues`)
|
||||
} catch (exc) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue