mirror of
https://github.com/tj-actions/changed-files
synced 2024-09-18 23:10:39 +02:00
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
BIN
dist/index.js
generated
vendored
BIN
dist/index.js
generated
vendored
Binary file not shown.
BIN
dist/index.js.map
generated
vendored
BIN
dist/index.js.map
generated
vendored
Binary file not shown.
|
@ -17,7 +17,7 @@ import {
|
|||
gitSubmoduleDiffSHA,
|
||||
isWindows,
|
||||
jsonOutput,
|
||||
setOutput
|
||||
setArrayOutput
|
||||
} from './utils'
|
||||
|
||||
export const processChangedFiles = async ({
|
||||
|
@ -85,22 +85,18 @@ export const processChangedFiles = async ({
|
|||
}
|
||||
|
||||
if (modifiedKeys.length > 0) {
|
||||
await setOutput({
|
||||
await setArrayOutput({
|
||||
key: 'modified_keys',
|
||||
value: modifiedKeys.join(inputs.separator),
|
||||
writeOutputFiles: inputs.writeOutputFiles,
|
||||
outputDir: inputs.outputDir,
|
||||
json: inputs.json
|
||||
inputs,
|
||||
value: modifiedKeys
|
||||
})
|
||||
}
|
||||
|
||||
if (changedKeys.length > 0) {
|
||||
await setOutput({
|
||||
await setArrayOutput({
|
||||
key: 'changed_keys',
|
||||
value: changedKeys.join(inputs.separator),
|
||||
writeOutputFiles: inputs.writeOutputFiles,
|
||||
outputDir: inputs.outputDir,
|
||||
json: inputs.json
|
||||
inputs,
|
||||
value: changedKeys
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,7 @@ import {
|
|||
getChangeTypeFiles
|
||||
} from './changedFiles'
|
||||
import {Inputs} from './inputs'
|
||||
import {setOutput} from './utils'
|
||||
|
||||
const getOutputKey = (key: string, outputPrefix: string): string => {
|
||||
return outputPrefix ? `${outputPrefix}_${key}` : key
|
||||
}
|
||||
import {getOutputKey, setArrayOutput, setOutput} from './utils'
|
||||
|
||||
const getArrayFromPaths = (
|
||||
paths: string | string[],
|
||||
|
@ -283,15 +279,11 @@ export const setOutputsAndGetModifiedAndChangedFilesStatus = async ({
|
|||
json: inputs.json
|
||||
})
|
||||
|
||||
await setOutput({
|
||||
key: getOutputKey('other_changed_files', outputPrefix),
|
||||
value: inputs.json
|
||||
? otherChangedFiles
|
||||
: otherChangedFiles.join(inputs.separator),
|
||||
writeOutputFiles: inputs.writeOutputFiles,
|
||||
outputDir: inputs.outputDir,
|
||||
json: inputs.json,
|
||||
shouldEscape: inputs.escapeJson
|
||||
await setArrayOutput({
|
||||
key: 'other_changed_files',
|
||||
inputs,
|
||||
value: otherChangedFiles,
|
||||
outputPrefix
|
||||
})
|
||||
|
||||
await setOutput({
|
||||
|
@ -376,15 +368,11 @@ export const setOutputsAndGetModifiedAndChangedFilesStatus = async ({
|
|||
json: inputs.json
|
||||
})
|
||||
|
||||
await setOutput({
|
||||
key: getOutputKey('other_modified_files', outputPrefix),
|
||||
value: inputs.json
|
||||
? otherModifiedFiles
|
||||
: otherModifiedFiles.join(inputs.separator),
|
||||
writeOutputFiles: inputs.writeOutputFiles,
|
||||
outputDir: inputs.outputDir,
|
||||
json: inputs.json,
|
||||
shouldEscape: inputs.escapeJson
|
||||
await setArrayOutput({
|
||||
key: 'other_modified_files',
|
||||
inputs,
|
||||
value: otherModifiedFiles,
|
||||
outputPrefix
|
||||
})
|
||||
|
||||
await setOutput({
|
||||
|
@ -457,15 +445,11 @@ export const setOutputsAndGetModifiedAndChangedFilesStatus = async ({
|
|||
json: inputs.json
|
||||
})
|
||||
|
||||
await setOutput({
|
||||
key: getOutputKey('other_deleted_files', outputPrefix),
|
||||
value: inputs.json
|
||||
? otherDeletedFiles
|
||||
: otherDeletedFiles.join(inputs.separator),
|
||||
writeOutputFiles: inputs.writeOutputFiles,
|
||||
outputDir: inputs.outputDir,
|
||||
json: inputs.json,
|
||||
shouldEscape: inputs.escapeJson
|
||||
await setArrayOutput({
|
||||
key: 'other_deleted_files',
|
||||
inputs,
|
||||
value: otherDeletedFiles,
|
||||
outputPrefix
|
||||
})
|
||||
|
||||
await setOutput({
|
||||
|
|
26
src/utils.ts
26
src/utils.ts
|
@ -1222,6 +1222,32 @@ export const getRecoverFilePatterns = ({
|
|||
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 ({
|
||||
key,
|
||||
value,
|
||||
|
|
Loading…
Reference in a new issue