diff --git a/dist/index.js b/dist/index.js index 47ebd739..7cde3de9 100644 Binary files a/dist/index.js and b/dist/index.js differ diff --git a/dist/index.js.map b/dist/index.js.map index 3b6d5aed..58bd710e 100644 Binary files a/dist/index.js.map and b/dist/index.js.map differ diff --git a/src/changedFiles.ts b/src/changedFiles.ts index 29b5ee12..251c8829 100644 --- a/src/changedFiles.ts +++ b/src/changedFiles.ts @@ -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 }) } } diff --git a/src/changedFilesOutput.ts b/src/changedFilesOutput.ts index 5cdc7742..8905fc9d 100644 --- a/src/changedFilesOutput.ts +++ b/src/changedFilesOutput.ts @@ -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({ diff --git a/src/utils.ts b/src/utils.ts index 2fe25192..65975e0e 100644 --- a/src/utils.ts +++ b/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 => { + 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,