fix: changed_keys and modified_keys output to handle json and escape_json inputs (#1585)
Co-authored-by: Arthur Volant <arthur.volant@adevinta.com> Co-authored-by: Tonye Jack <jtonye@ymail.com> Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
This commit is contained in:
parent
dbf0700c7a
commit
951140b94a
12
dist/index.js
generated
vendored
12
dist/index.js
generated
vendored
@ -101,21 +101,25 @@ const processChangedFiles = ({ filePatterns, allDiffFiles, inputs, yamlFilePatte
|
|||||||
core.endGroup();
|
core.endGroup();
|
||||||
}
|
}
|
||||||
if (modifiedKeys.length > 0) {
|
if (modifiedKeys.length > 0) {
|
||||||
|
core.debug(`All modifiedKeys: ${JSON.stringify(modifiedKeys)}`);
|
||||||
yield (0, utils_1.setOutput)({
|
yield (0, utils_1.setOutput)({
|
||||||
key: 'modified_keys',
|
key: 'modified_keys',
|
||||||
value: modifiedKeys.join(inputs.separator),
|
value: inputs.json ? modifiedKeys : modifiedKeys.join(inputs.separator),
|
||||||
writeOutputFiles: inputs.writeOutputFiles,
|
writeOutputFiles: inputs.writeOutputFiles,
|
||||||
outputDir: inputs.outputDir,
|
outputDir: inputs.outputDir,
|
||||||
json: inputs.json
|
json: inputs.json,
|
||||||
|
shouldEscape: inputs.escapeJson
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (changedKeys.length > 0) {
|
if (changedKeys.length > 0) {
|
||||||
|
core.debug(`All changedKeys: ${JSON.stringify(changedKeys)}`);
|
||||||
yield (0, utils_1.setOutput)({
|
yield (0, utils_1.setOutput)({
|
||||||
key: 'changed_keys',
|
key: 'changed_keys',
|
||||||
value: changedKeys.join(inputs.separator),
|
value: inputs.json ? changedKeys : changedKeys.join(inputs.separator),
|
||||||
writeOutputFiles: inputs.writeOutputFiles,
|
writeOutputFiles: inputs.writeOutputFiles,
|
||||||
outputDir: inputs.outputDir,
|
outputDir: inputs.outputDir,
|
||||||
json: inputs.json
|
json: inputs.json,
|
||||||
|
shouldEscape: inputs.escapeJson
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
2
dist/index.js.map
generated
vendored
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
@ -17,7 +17,7 @@ import {
|
|||||||
gitSubmoduleDiffSHA,
|
gitSubmoduleDiffSHA,
|
||||||
isWindows,
|
isWindows,
|
||||||
jsonOutput,
|
jsonOutput,
|
||||||
setOutput
|
setArrayOutput
|
||||||
} from './utils'
|
} from './utils'
|
||||||
|
|
||||||
export const processChangedFiles = async ({
|
export const processChangedFiles = async ({
|
||||||
@ -85,22 +85,18 @@ export const processChangedFiles = async ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (modifiedKeys.length > 0) {
|
if (modifiedKeys.length > 0) {
|
||||||
await setOutput({
|
await setArrayOutput({
|
||||||
key: 'modified_keys',
|
key: 'modified_keys',
|
||||||
value: modifiedKeys.join(inputs.separator),
|
inputs,
|
||||||
writeOutputFiles: inputs.writeOutputFiles,
|
value: modifiedKeys
|
||||||
outputDir: inputs.outputDir,
|
|
||||||
json: inputs.json
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changedKeys.length > 0) {
|
if (changedKeys.length > 0) {
|
||||||
await setOutput({
|
await setArrayOutput({
|
||||||
key: 'changed_keys',
|
key: 'changed_keys',
|
||||||
value: changedKeys.join(inputs.separator),
|
inputs,
|
||||||
writeOutputFiles: inputs.writeOutputFiles,
|
value: changedKeys
|
||||||
outputDir: inputs.outputDir,
|
|
||||||
json: inputs.json
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,7 @@ import {
|
|||||||
getChangeTypeFiles
|
getChangeTypeFiles
|
||||||
} from './changedFiles'
|
} from './changedFiles'
|
||||||
import {Inputs} from './inputs'
|
import {Inputs} from './inputs'
|
||||||
import {setOutput} from './utils'
|
import {getOutputKey, setArrayOutput, setOutput} from './utils'
|
||||||
|
|
||||||
const getOutputKey = (key: string, outputPrefix: string): string => {
|
|
||||||
return outputPrefix ? `${outputPrefix}_${key}` : key
|
|
||||||
}
|
|
||||||
|
|
||||||
const getArrayFromPaths = (
|
const getArrayFromPaths = (
|
||||||
paths: string | string[],
|
paths: string | string[],
|
||||||
@ -283,15 +279,11 @@ export const setOutputsAndGetModifiedAndChangedFilesStatus = async ({
|
|||||||
json: inputs.json
|
json: inputs.json
|
||||||
})
|
})
|
||||||
|
|
||||||
await setOutput({
|
await setArrayOutput({
|
||||||
key: getOutputKey('other_changed_files', outputPrefix),
|
key: 'other_changed_files',
|
||||||
value: inputs.json
|
inputs,
|
||||||
? otherChangedFiles
|
value: otherChangedFiles,
|
||||||
: otherChangedFiles.join(inputs.separator),
|
outputPrefix
|
||||||
writeOutputFiles: inputs.writeOutputFiles,
|
|
||||||
outputDir: inputs.outputDir,
|
|
||||||
json: inputs.json,
|
|
||||||
shouldEscape: inputs.escapeJson
|
|
||||||
})
|
})
|
||||||
|
|
||||||
await setOutput({
|
await setOutput({
|
||||||
@ -376,15 +368,11 @@ export const setOutputsAndGetModifiedAndChangedFilesStatus = async ({
|
|||||||
json: inputs.json
|
json: inputs.json
|
||||||
})
|
})
|
||||||
|
|
||||||
await setOutput({
|
await setArrayOutput({
|
||||||
key: getOutputKey('other_modified_files', outputPrefix),
|
key: 'other_modified_files',
|
||||||
value: inputs.json
|
inputs,
|
||||||
? otherModifiedFiles
|
value: otherModifiedFiles,
|
||||||
: otherModifiedFiles.join(inputs.separator),
|
outputPrefix
|
||||||
writeOutputFiles: inputs.writeOutputFiles,
|
|
||||||
outputDir: inputs.outputDir,
|
|
||||||
json: inputs.json,
|
|
||||||
shouldEscape: inputs.escapeJson
|
|
||||||
})
|
})
|
||||||
|
|
||||||
await setOutput({
|
await setOutput({
|
||||||
@ -457,15 +445,11 @@ export const setOutputsAndGetModifiedAndChangedFilesStatus = async ({
|
|||||||
json: inputs.json
|
json: inputs.json
|
||||||
})
|
})
|
||||||
|
|
||||||
await setOutput({
|
await setArrayOutput({
|
||||||
key: getOutputKey('other_deleted_files', outputPrefix),
|
key: 'other_deleted_files',
|
||||||
value: inputs.json
|
inputs,
|
||||||
? otherDeletedFiles
|
value: otherDeletedFiles,
|
||||||
: otherDeletedFiles.join(inputs.separator),
|
outputPrefix
|
||||||
writeOutputFiles: inputs.writeOutputFiles,
|
|
||||||
outputDir: inputs.outputDir,
|
|
||||||
json: inputs.json,
|
|
||||||
shouldEscape: inputs.escapeJson
|
|
||||||
})
|
})
|
||||||
|
|
||||||
await setOutput({
|
await setOutput({
|
||||||
|
26
src/utils.ts
26
src/utils.ts
@ -1222,6 +1222,32 @@ export const getRecoverFilePatterns = ({
|
|||||||
return filePatterns.filter(Boolean)
|
return filePatterns.filter(Boolean)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getOutputKey = (key: string, outputPrefix: string): string => {
|
||||||
|
return outputPrefix ? `${outputPrefix}_${key}` : key
|
||||||
|
}
|
||||||
|
|
||||||
|
export const setArrayOutput = async ({
|
||||||
|
key,
|
||||||
|
inputs,
|
||||||
|
value,
|
||||||
|
outputPrefix
|
||||||
|
}: {
|
||||||
|
key: string
|
||||||
|
inputs: Inputs
|
||||||
|
value: string[]
|
||||||
|
outputPrefix?: string
|
||||||
|
}): Promise<void> => {
|
||||||
|
core.debug(`${key}: ${JSON.stringify(value)}`)
|
||||||
|
await setOutput({
|
||||||
|
key: outputPrefix ? getOutputKey(key, outputPrefix) : key,
|
||||||
|
value: inputs.json ? value : value.join(inputs.separator),
|
||||||
|
writeOutputFiles: inputs.writeOutputFiles,
|
||||||
|
outputDir: inputs.outputDir,
|
||||||
|
json: inputs.json,
|
||||||
|
shouldEscape: inputs.escapeJson
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export const setOutput = async ({
|
export const setOutput = async ({
|
||||||
key,
|
key,
|
||||||
value,
|
value,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user