Fixed error with output

This commit is contained in:
Tonye Jack 2023-05-22 22:13:04 -06:00
parent 7f23de0848
commit e04f5bc36a
7 changed files with 10 additions and 38 deletions

View File

@ -92,10 +92,6 @@ inputs:
description: "Output list of changed files in a JSON formatted string which can be used for matrix jobs." description: "Output list of changed files in a JSON formatted string which can be used for matrix jobs."
required: false required: false
default: "false" default: "false"
json_raw_format:
description: "Output list of changed files in [jq](https://devdocs.io/jq/) raw output format which means that the output will not be surrounded by quotes and special characters will not be escaped."
required: false
default: "false"
fetch_depth: fetch_depth:
description: "Depth of additional branch history fetched. **NOTE**: This can be adjusted to resolve errors with insufficient history." description: "Depth of additional branch history fetched. **NOTE**: This can be adjusted to resolve errors with insufficient history."
required: false required: false

17
dist/index.js generated vendored
View File

@ -83,7 +83,7 @@ const getRenamedFiles = ({ inputs, workingDirectory, hasSubmodule, shaResult })
})); }));
} }
if (inputs.json) { if (inputs.json) {
return (0, utils_1.jsonOutput)({ value: renamedFiles, rawFormat: inputs.jsonRawFormat }); return (0, utils_1.jsonOutput)({ value: renamedFiles });
} }
return renamedFiles.join(inputs.oldNewFilesSeparator); return renamedFiles.join(inputs.oldNewFilesSeparator);
}); });
@ -131,7 +131,7 @@ const getDiffFiles = ({ inputs, workingDirectory, hasSubmodule, shaResult, diffF
})); }));
} }
if (inputs.json) { if (inputs.json) {
return (0, utils_1.jsonOutput)({ value: files, rawFormat: inputs.jsonRawFormat }); return (0, utils_1.jsonOutput)({ value: files });
} }
return files.join(inputs.separator); return files.join(inputs.separator);
}); });
@ -633,9 +633,6 @@ const getInputs = () => {
required: false required: false
}); });
const json = core.getBooleanInput('json', { required: false }); const json = core.getBooleanInput('json', { required: false });
const jsonRawFormat = core.getBooleanInput('json_raw_format', {
required: false
});
const fetchDepth = core.getInput('fetch_depth', { required: false }); const fetchDepth = core.getInput('fetch_depth', { required: false });
const sinceLastRemoteCommit = core.getBooleanInput('since_last_remote_commit', { required: false }); const sinceLastRemoteCommit = core.getBooleanInput('since_last_remote_commit', { required: false });
const writeOutputFiles = core.getBooleanInput('write_output_files', { const writeOutputFiles = core.getBooleanInput('write_output_files', {
@ -668,7 +665,6 @@ const getInputs = () => {
dirNames, dirNames,
dirNamesExcludeRoot, dirNamesExcludeRoot,
json, json,
jsonRawFormat,
sinceLastRemoteCommit, sinceLastRemoteCommit,
writeOutputFiles, writeOutputFiles,
outputDir, outputDir,
@ -1513,13 +1509,8 @@ const getDirnameMaxDepth = ({ pathStr, dirNamesMaxDepth, excludeRoot }) => {
return output; return output;
}; };
exports.getDirnameMaxDepth = getDirnameMaxDepth; exports.getDirnameMaxDepth = getDirnameMaxDepth;
const jsonOutput = ({ value, rawFormat }) => { const jsonOutput = ({ value }) => {
if (rawFormat) { return JSON.stringify(value);
return JSON.stringify(value);
}
else {
return JSON.stringify(value, null, 2);
}
}; };
exports.jsonOutput = jsonOutput; exports.jsonOutput = jsonOutput;
const getFilePatterns = ({ inputs }) => __awaiter(void 0, void 0, void 0, function* () { const getFilePatterns = ({ inputs }) => __awaiter(void 0, void 0, void 0, function* () {

2
dist/index.js.map generated vendored

File diff suppressed because one or more lines are too long

View File

@ -14,7 +14,7 @@
"lint:fix": "eslint --fix src/**/*.ts", "lint:fix": "eslint --fix src/**/*.ts",
"package": "ncc build lib/main.js --source-map --license licenses.txt", "package": "ncc build lib/main.js --source-map --license licenses.txt",
"test": "jest --coverage", "test": "jest --coverage",
"all": "yarn build && yarn format && yarn lint && yarn package && yarn test" "all": "yarn build && yarn format && yarn lint:fix && yarn lint && yarn package && yarn test"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -73,7 +73,7 @@ export const getRenamedFiles = async ({
} }
if (inputs.json) { if (inputs.json) {
return jsonOutput({value: renamedFiles, rawFormat: inputs.jsonRawFormat}) return jsonOutput({value: renamedFiles})
} }
return renamedFiles.join(inputs.oldNewFilesSeparator) return renamedFiles.join(inputs.oldNewFilesSeparator)
@ -146,7 +146,7 @@ export const getDiffFiles = async ({
} }
if (inputs.json) { if (inputs.json) {
return jsonOutput({value: files, rawFormat: inputs.jsonRawFormat}) return jsonOutput({value: files})
} }
return files.join(inputs.separator) return files.join(inputs.separator)

View File

@ -24,7 +24,6 @@ export type Inputs = {
dirNamesMaxDepth?: number dirNamesMaxDepth?: number
dirNamesExcludeRoot: boolean dirNamesExcludeRoot: boolean
json: boolean json: boolean
jsonRawFormat: boolean
fetchDepth?: number fetchDepth?: number
sinceLastRemoteCommit: boolean sinceLastRemoteCommit: boolean
writeOutputFiles: boolean writeOutputFiles: boolean
@ -95,9 +94,6 @@ export const getInputs = (): Inputs => {
required: false required: false
}) })
const json = core.getBooleanInput('json', {required: false}) const json = core.getBooleanInput('json', {required: false})
const jsonRawFormat = core.getBooleanInput('json_raw_format', {
required: false
})
const fetchDepth = core.getInput('fetch_depth', {required: false}) const fetchDepth = core.getInput('fetch_depth', {required: false})
const sinceLastRemoteCommit = core.getBooleanInput( const sinceLastRemoteCommit = core.getBooleanInput(
'since_last_remote_commit', 'since_last_remote_commit',
@ -134,7 +130,6 @@ export const getInputs = (): Inputs => {
dirNames, dirNames,
dirNamesExcludeRoot, dirNamesExcludeRoot,
json, json,
jsonRawFormat,
sinceLastRemoteCommit, sinceLastRemoteCommit,
writeOutputFiles, writeOutputFiles,
outputDir, outputDir,

View File

@ -650,18 +650,8 @@ export const getDirnameMaxDepth = ({
return output return output
} }
export const jsonOutput = ({ export const jsonOutput = ({value}: {value: string | string[]}): string => {
value, return JSON.stringify(value)
rawFormat
}: {
value: string | string[]
rawFormat: boolean
}): string => {
if (rawFormat) {
return JSON.stringify(value)
} else {
return JSON.stringify(value, null, 2)
}
} }
export const getFilePatterns = async ({ export const getFilePatterns = async ({