Skip to content

Commit

Permalink
Wrap command on try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
Manel Eljishi authored and Manel Eljishi committed Sep 12, 2024
1 parent f51fbe5 commit 55a54b7
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions plugin/src/lib/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,19 @@ import { MixAuditResultType } from "../types/audit.result.type.js";
export async function executeRunner(): Promise<void>{
await ensureDirectoryExists(dirname(RUNNER_OUTPUT_PATH));
const projectPath = await readJsonFile<string>(PLUGIN_CONFIG_PATH);
let {stdout, stderr} = await executeProcess({

try{
let {stdout, stderr} = await executeProcess({
command: 'mix deps.audit',
args: ['--format=json'],
cwd: projectPath,
ignoreExitCode: false
})

if (stderr) {
throw new Error(`Elixir audit plugin error: ${stderr}`)
}

if (typeof stdout !== 'object'){
stdout = JSON.parse(stdout);
}

const resp = transformMixAuditOutput(stdout as any);
await writeFile(RUNNER_OUTPUT_PATH, JSON.stringify(resp));

}catch(err){
throw new Error(`Elixir audit plugin error: ${err}`)
}
}

function transformMixAuditOutput(output: MixAuditResultType): AuditOutputs{
Expand Down

0 comments on commit 55a54b7

Please sign in to comment.