Skip to content

Commit b19bffa

Browse files
committed
Repackage action following bump of @actions/core dependency
1 parent 78fdd6a commit b19bffa

File tree

1 file changed

+36
-21
lines changed

1 file changed

+36
-21
lines changed

dist/index.js

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,6 @@ const file_command_1 = __nccwpck_require__(717);
419419
const utils_1 = __nccwpck_require__(5278);
420420
const os = __importStar(__nccwpck_require__(2037));
421421
const path = __importStar(__nccwpck_require__(1017));
422-
const uuid_1 = __nccwpck_require__(8974);
423422
const oidc_utils_1 = __nccwpck_require__(8041);
424423
/**
425424
* The code to exit an action
@@ -449,20 +448,9 @@ function exportVariable(name, val) {
449448
process.env[name] = convertedVal;
450449
const filePath = process.env['GITHUB_ENV'] || '';
451450
if (filePath) {
452-
const delimiter = `ghadelimiter_${uuid_1.v4()}`;
453-
// These should realistically never happen, but just in case someone finds a way to exploit uuid generation let's not allow keys or values that contain the delimiter.
454-
if (name.includes(delimiter)) {
455-
throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
456-
}
457-
if (convertedVal.includes(delimiter)) {
458-
throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
459-
}
460-
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
461-
file_command_1.issueCommand('ENV', commandValue);
462-
}
463-
else {
464-
command_1.issueCommand('set-env', { name }, convertedVal);
451+
return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val));
465452
}
453+
command_1.issueCommand('set-env', { name }, convertedVal);
466454
}
467455
exports.exportVariable = exportVariable;
468456
/**
@@ -480,7 +468,7 @@ exports.setSecret = setSecret;
480468
function addPath(inputPath) {
481469
const filePath = process.env['GITHUB_PATH'] || '';
482470
if (filePath) {
483-
file_command_1.issueCommand('PATH', inputPath);
471+
file_command_1.issueFileCommand('PATH', inputPath);
484472
}
485473
else {
486474
command_1.issueCommand('add-path', {}, inputPath);
@@ -520,7 +508,10 @@ function getMultilineInput(name, options) {
520508
const inputs = getInput(name, options)
521509
.split('\n')
522510
.filter(x => x !== '');
523-
return inputs;
511+
if (options && options.trimWhitespace === false) {
512+
return inputs;
513+
}
514+
return inputs.map(input => input.trim());
524515
}
525516
exports.getMultilineInput = getMultilineInput;
526517
/**
@@ -553,8 +544,12 @@ exports.getBooleanInput = getBooleanInput;
553544
*/
554545
// eslint-disable-next-line @typescript-eslint/no-explicit-any
555546
function setOutput(name, value) {
547+
const filePath = process.env['GITHUB_OUTPUT'] || '';
548+
if (filePath) {
549+
return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value));
550+
}
556551
process.stdout.write(os.EOL);
557-
command_1.issueCommand('set-output', { name }, value);
552+
command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value));
558553
}
559554
exports.setOutput = setOutput;
560555
/**
@@ -683,7 +678,11 @@ exports.group = group;
683678
*/
684679
// eslint-disable-next-line @typescript-eslint/no-explicit-any
685680
function saveState(name, value) {
686-
command_1.issueCommand('save-state', { name }, value);
681+
const filePath = process.env['GITHUB_STATE'] || '';
682+
if (filePath) {
683+
return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value));
684+
}
685+
command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value));
687686
}
688687
exports.saveState = saveState;
689688
/**
@@ -749,13 +748,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
749748
return result;
750749
};
751750
Object.defineProperty(exports, "__esModule", ({ value: true }));
752-
exports.issueCommand = void 0;
751+
exports.prepareKeyValueMessage = exports.issueFileCommand = void 0;
753752
// We use any as a valid input type
754753
/* eslint-disable @typescript-eslint/no-explicit-any */
755754
const fs = __importStar(__nccwpck_require__(7147));
756755
const os = __importStar(__nccwpck_require__(2037));
756+
const uuid_1 = __nccwpck_require__(8974);
757757
const utils_1 = __nccwpck_require__(5278);
758-
function issueCommand(command, message) {
758+
function issueFileCommand(command, message) {
759759
const filePath = process.env[`GITHUB_${command}`];
760760
if (!filePath) {
761761
throw new Error(`Unable to find environment variable for file command ${command}`);
@@ -767,7 +767,22 @@ function issueCommand(command, message) {
767767
encoding: 'utf8'
768768
});
769769
}
770-
exports.issueCommand = issueCommand;
770+
exports.issueFileCommand = issueFileCommand;
771+
function prepareKeyValueMessage(key, value) {
772+
const delimiter = `ghadelimiter_${uuid_1.v4()}`;
773+
const convertedValue = utils_1.toCommandValue(value);
774+
// These should realistically never happen, but just in case someone finds a
775+
// way to exploit uuid generation let's not allow keys or values that contain
776+
// the delimiter.
777+
if (key.includes(delimiter)) {
778+
throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
779+
}
780+
if (convertedValue.includes(delimiter)) {
781+
throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
782+
}
783+
return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`;
784+
}
785+
exports.prepareKeyValueMessage = prepareKeyValueMessage;
771786
//# sourceMappingURL=file-command.js.map
772787

773788
/***/ }),

0 commit comments

Comments
 (0)