Fixed error with output
This commit is contained in:
parent
d499479423
commit
0557d055c4
@ -92,6 +92,10 @@ 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"
|
||||||
|
escape_json:
|
||||||
|
description: "Escape JSON output."
|
||||||
|
required: false
|
||||||
|
default: "true"
|
||||||
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
|
||||||
|
18
dist/index.js
generated
vendored
18
dist/index.js
generated
vendored
@ -83,7 +83,7 @@ const getRenamedFiles = ({ inputs, workingDirectory, hasSubmodule, shaResult })
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
if (inputs.json) {
|
if (inputs.json) {
|
||||||
return (0, utils_1.jsonOutput)({ value: renamedFiles });
|
return (0, utils_1.jsonOutput)({ value: renamedFiles, escape: inputs.escape_json });
|
||||||
}
|
}
|
||||||
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 });
|
return (0, utils_1.jsonOutput)({ value: files, escape: inputs.escape_json });
|
||||||
}
|
}
|
||||||
return files.join(inputs.separator);
|
return files.join(inputs.separator);
|
||||||
});
|
});
|
||||||
@ -633,6 +633,7 @@ const getInputs = () => {
|
|||||||
required: false
|
required: false
|
||||||
});
|
});
|
||||||
const json = core.getBooleanInput('json', { required: false });
|
const json = core.getBooleanInput('json', { required: false });
|
||||||
|
const escape_json = core.getBooleanInput('escape_json', { 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', {
|
||||||
@ -665,6 +666,7 @@ const getInputs = () => {
|
|||||||
dirNames,
|
dirNames,
|
||||||
dirNamesExcludeRoot,
|
dirNamesExcludeRoot,
|
||||||
json,
|
json,
|
||||||
|
escape_json,
|
||||||
sinceLastRemoteCommit,
|
sinceLastRemoteCommit,
|
||||||
writeOutputFiles,
|
writeOutputFiles,
|
||||||
outputDir,
|
outputDir,
|
||||||
@ -736,7 +738,9 @@ function run() {
|
|||||||
var _a;
|
var _a;
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const env = (0, env_1.getEnv)();
|
const env = (0, env_1.getEnv)();
|
||||||
|
core.debug(`Env: ${JSON.stringify(env, null, 2)}`);
|
||||||
const inputs = (0, inputs_1.getInputs)();
|
const inputs = (0, inputs_1.getInputs)();
|
||||||
|
core.debug(`Inputs: ${JSON.stringify(inputs, null, 2)}`);
|
||||||
yield (0, utils_1.verifyMinimumGitVersion)();
|
yield (0, utils_1.verifyMinimumGitVersion)();
|
||||||
let quotePathValue = 'on';
|
let quotePathValue = 'on';
|
||||||
if (!inputs.quotePath) {
|
if (!inputs.quotePath) {
|
||||||
@ -1502,8 +1506,14 @@ const getDirnameMaxDepth = ({ pathStr, dirNamesMaxDepth, excludeRoot }) => {
|
|||||||
return output;
|
return output;
|
||||||
};
|
};
|
||||||
exports.getDirnameMaxDepth = getDirnameMaxDepth;
|
exports.getDirnameMaxDepth = getDirnameMaxDepth;
|
||||||
const jsonOutput = ({ value }) => {
|
const jsonOutput = ({ value, escape }) => {
|
||||||
return JSON.stringify(value);
|
return JSON.stringify(value, (key, value) => {
|
||||||
|
if (typeof value === 'string') {
|
||||||
|
// if escape is true, escape quotes and backslashes
|
||||||
|
return escape ? value.replace(/\\/g, '\\\\').replace(/"/g, '\\"') : value;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
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
2
dist/index.js.map
generated
vendored
File diff suppressed because one or more lines are too long
@ -73,7 +73,7 @@ export const getRenamedFiles = async ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (inputs.json) {
|
if (inputs.json) {
|
||||||
return jsonOutput({value: renamedFiles})
|
return jsonOutput({value: renamedFiles, escape: inputs.escape_json})
|
||||||
}
|
}
|
||||||
|
|
||||||
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})
|
return jsonOutput({value: files, escape: inputs.escape_json})
|
||||||
}
|
}
|
||||||
|
|
||||||
return files.join(inputs.separator)
|
return files.join(inputs.separator)
|
||||||
|
@ -24,6 +24,7 @@ export type Inputs = {
|
|||||||
dirNamesMaxDepth?: number
|
dirNamesMaxDepth?: number
|
||||||
dirNamesExcludeRoot: boolean
|
dirNamesExcludeRoot: boolean
|
||||||
json: boolean
|
json: boolean
|
||||||
|
escape_json: boolean
|
||||||
fetchDepth?: number
|
fetchDepth?: number
|
||||||
sinceLastRemoteCommit: boolean
|
sinceLastRemoteCommit: boolean
|
||||||
writeOutputFiles: boolean
|
writeOutputFiles: boolean
|
||||||
@ -94,6 +95,7 @@ export const getInputs = (): Inputs => {
|
|||||||
required: false
|
required: false
|
||||||
})
|
})
|
||||||
const json = core.getBooleanInput('json', {required: false})
|
const json = core.getBooleanInput('json', {required: false})
|
||||||
|
const escape_json = core.getBooleanInput('escape_json', {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',
|
||||||
@ -130,6 +132,7 @@ export const getInputs = (): Inputs => {
|
|||||||
dirNames,
|
dirNames,
|
||||||
dirNamesExcludeRoot,
|
dirNamesExcludeRoot,
|
||||||
json,
|
json,
|
||||||
|
escape_json,
|
||||||
sinceLastRemoteCommit,
|
sinceLastRemoteCommit,
|
||||||
writeOutputFiles,
|
writeOutputFiles,
|
||||||
outputDir,
|
outputDir,
|
||||||
|
@ -19,7 +19,9 @@ import {
|
|||||||
|
|
||||||
export async function run(): Promise<void> {
|
export async function run(): Promise<void> {
|
||||||
const env = getEnv()
|
const env = getEnv()
|
||||||
|
core.debug(`Env: ${JSON.stringify(env, null, 2)}`)
|
||||||
const inputs = getInputs()
|
const inputs = getInputs()
|
||||||
|
core.debug(`Inputs: ${JSON.stringify(inputs, null, 2)}`)
|
||||||
|
|
||||||
await verifyMinimumGitVersion()
|
await verifyMinimumGitVersion()
|
||||||
|
|
||||||
|
16
src/utils.ts
16
src/utils.ts
@ -641,8 +641,20 @@ export const getDirnameMaxDepth = ({
|
|||||||
return output
|
return output
|
||||||
}
|
}
|
||||||
|
|
||||||
export const jsonOutput = ({value}: {value: string | string[]}): string => {
|
export const jsonOutput = ({
|
||||||
return JSON.stringify(value)
|
value,
|
||||||
|
escape
|
||||||
|
}: {
|
||||||
|
value: string | string[]
|
||||||
|
escape: boolean
|
||||||
|
}): string => {
|
||||||
|
return JSON.stringify(value, (key, value) => {
|
||||||
|
if (typeof value === 'string') {
|
||||||
|
// if escape is true, escape quotes and backslashes
|
||||||
|
return escape ? value.replace(/\\/g, '\\\\').replace(/"/g, '\\"') : value
|
||||||
|
}
|
||||||
|
return value
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getFilePatterns = async ({
|
export const getFilePatterns = async ({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user