mirror of
https://github.com/golangci/golangci-lint-action.git
synced 2026-02-25 17:11:55 +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`)) {
|
if (args.includes(`-out-format`)) {
|
||||||
throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`);
|
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`));
|
const workingDirectory = core.getInput(`working-directory`);
|
||||||
if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) {
|
const cmdArgs = {};
|
||||||
throw new Error(`working-directory (${workingDirectory}) was not a path`);
|
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();
|
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();
|
const startedAt = Date.now();
|
||||||
try {
|
try {
|
||||||
const res = yield execShellCommand(cmd, { cwd: workingDirectory });
|
const res = yield execShellCommand(cmd, cmdArgs);
|
||||||
printOutput(res);
|
printOutput(res);
|
||||||
core.info(`golangci-lint found no issues`);
|
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`)) {
|
if (args.includes(`-out-format`)) {
|
||||||
throw new Error(`please, don't change out-format for golangci-lint: it can be broken in a future`);
|
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`));
|
const workingDirectory = core.getInput(`working-directory`);
|
||||||
if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) {
|
const cmdArgs = {};
|
||||||
throw new Error(`working-directory (${workingDirectory}) was not a path`);
|
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();
|
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();
|
const startedAt = Date.now();
|
||||||
try {
|
try {
|
||||||
const res = yield execShellCommand(cmd, { cwd: workingDirectory });
|
const res = yield execShellCommand(cmd, cmdArgs);
|
||||||
printOutput(res);
|
printOutput(res);
|
||||||
core.info(`golangci-lint found no issues`);
|
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 * as core from "@actions/core"
|
||||||
import { exec } from "child_process"
|
import { exec, ExecOptions } from "child_process"
|
||||||
import * as fs from "fs"
|
import * as fs from "fs"
|
||||||
import * as path from "path"
|
import * as path from "path"
|
||||||
import { promisify } from "util"
|
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`)
|
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`))
|
const workingDirectory = core.getInput(`working-directory`)
|
||||||
if (!fs.existsSync(workingDirectory) || !fs.lstatSync(workingDirectory).isDirectory()) {
|
const cmdArgs: ExecOptions = {}
|
||||||
throw new Error(`working-directory (${workingDirectory}) was not a path`)
|
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()
|
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()
|
const startedAt = Date.now()
|
||||||
try {
|
try {
|
||||||
const res = await execShellCommand(cmd, { cwd: workingDirectory })
|
const res = await execShellCommand(cmd, cmdArgs)
|
||||||
printOutput(res)
|
printOutput(res)
|
||||||
core.info(`golangci-lint found no issues`)
|
core.info(`golangci-lint found no issues`)
|
||||||
} catch (exc) {
|
} catch (exc) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue