Skip to content

Commit

Permalink
gh-actions/jq: Cleanup tmpfile (#947)
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Northey <ryan@synca.io>
  • Loading branch information
phlax authored Nov 5, 2023
1 parent 3e73bc4 commit f4694e2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion gh-actions/jq/jq.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,21 @@ const run = async (): Promise<void> => {
if (decode) {
decodePipe = '| base64 -d'
}
let tmpFile
let shellCommand = `printf '%s' '${input}' ${decodePipe} | jq ${options} '${filter}' ${encodePipe}`
if (os.platform() === 'win32' || useTmpFile) {
const script = `#!/bin/bash
${shellCommand}
`
const tmpFile = tmp.fileSync()
tmpFile = tmp.fileSync()
fs.writeFileSync(tmpFile.name, script)
shellCommand = `bash ${tmpFile.name}`
}
core.debug(`Running shell command: ${shellCommand}`)
const proc = exec(shellCommand, (error, stdout, stderr) => {
if (tmpFile) {
tmpFile.removeCallback()
}
if (error) {
console.error(`Error: ${error}`)
return
Expand Down

0 comments on commit f4694e2

Please sign in to comment.