fix: bug with outputs when json is set to true (#1531)

Co-authored-by: GitHub Action <action@github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
Tonye Jack
2023-09-04 14:03:32 -06:00
committed by GitHub
parent fd460fa3ba
commit 8d335b7b7d
7 changed files with 362 additions and 150 deletions

View File

@@ -892,7 +892,7 @@ export const jsonOutput = ({
value,
shouldEscape
}: {
value: string | string[]
value: string | string[] | boolean
shouldEscape: boolean
}): string => {
const result = JSON.stringify(value)
@@ -1226,18 +1226,29 @@ export const getRecoverFilePatterns = ({
export const setOutput = async ({
key,
value,
inputs
writeOutputFiles,
outputDir,
json = false,
shouldEscape = false
}: {
key: string
value: string | boolean
inputs: Inputs
value: string | string[] | boolean
writeOutputFiles: boolean
outputDir: string
json?: boolean
shouldEscape?: boolean
}): Promise<void> => {
const cleanedValue = value.toString().trim()
let cleanedValue
if (json) {
cleanedValue = jsonOutput({value, shouldEscape})
} else {
cleanedValue = value.toString().trim()
}
core.setOutput(key, cleanedValue)
if (inputs.writeOutputFiles) {
const outputDir = inputs.outputDir
const extension = inputs.json ? 'json' : 'txt'
if (writeOutputFiles) {
const extension = json ? 'json' : 'txt'
const outputFilePath = path.join(outputDir, `${key}.${extension}`)
if (!(await exists(outputDir))) {