1
0
Fork 0
mirror of https://github.com/imjasonh/govulncheck-action synced 2026-07-15 04:35:28 +00:00
govulncheck-action/lib/govulncheck.js
Jason Hall c4a3cd53b0 build: migrate to ESM and esbuild
Updates the project to use ESM modules and replaces ncc with esbuild. This fixes build failures caused by newer @actions/core versions which use strict ESM exports that ncc cannot resolve.

Also updates tests to use ESM and dependency injection.

Signed-off-by: Jason Hall <imjasonh@gmail.com>
2026-02-21 02:54:49 -05:00

46 lines
1 KiB
JavaScript

import * as exec from '@actions/exec';
class GovulncheckRunner {
constructor(execModule = exec) {
this.exec = execModule;
}
async install() {
// Check if govulncheck is already installed
try {
await this.exec.exec('govulncheck', ['-version']);
console.log('govulncheck is already installed');
return;
} catch (e) {
console.log('govulncheck not found, installing...');
await this.exec.exec('go', ['install', 'golang.org/x/vuln/cmd/govulncheck@latest']);
}
}
async run() {
let output = '';
let errorOutput = '';
const options = {
listeners: {
stdout: (data) => {
output += data.toString();
},
stderr: (data) => {
errorOutput += data.toString();
},
},
ignoreReturnCode: true,
};
const exitCode = await this.exec.exec('govulncheck', ['-json', './...'], options);
return {
output,
errorOutput,
exitCode,
};
}
}
export default GovulncheckRunner;