Skip to content

Commit fa3e57c

Browse files
authored
Merge pull request #8 from peter-evans/update-distribution
Update distribution
2 parents 89bb9a7 + 1705e4f commit fa3e57c

File tree

1 file changed

+38
-11
lines changed

1 file changed

+38
-11
lines changed

dist/index.js

+38-11
Original file line numberDiff line numberDiff line change
@@ -5129,14 +5129,28 @@ class Command {
51295129
return cmdStr;
51305130
}
51315131
}
5132+
/**
5133+
* Sanitizes an input into a string so it can be passed into issueCommand safely
5134+
* @param input input to sanitize into a string
5135+
*/
5136+
function toCommandValue(input) {
5137+
if (input === null || input === undefined) {
5138+
return '';
5139+
}
5140+
else if (typeof input === 'string' || input instanceof String) {
5141+
return input;
5142+
}
5143+
return JSON.stringify(input);
5144+
}
5145+
exports.toCommandValue = toCommandValue;
51325146
function escapeData(s) {
5133-
return (s || '')
5147+
return toCommandValue(s)
51345148
.replace(/%/g, '%25')
51355149
.replace(/\r/g, '%0D')
51365150
.replace(/\n/g, '%0A');
51375151
}
51385152
function escapeProperty(s) {
5139-
return (s || '')
5153+
return toCommandValue(s)
51405154
.replace(/%/g, '%25')
51415155
.replace(/\r/g, '%0D')
51425156
.replace(/\n/g, '%0A')
@@ -7145,11 +7159,13 @@ var ExitCode;
71457159
/**
71467160
* Sets env variable for this action and future actions in the job
71477161
* @param name the name of the variable to set
7148-
* @param val the value of the variable
7162+
* @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify
71497163
*/
7164+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
71507165
function exportVariable(name, val) {
7151-
process.env[name] = val;
7152-
command_1.issueCommand('set-env', { name }, val);
7166+
const convertedVal = command_1.toCommandValue(val);
7167+
process.env[name] = convertedVal;
7168+
command_1.issueCommand('set-env', { name }, convertedVal);
71537169
}
71547170
exports.exportVariable = exportVariable;
71557171
/**
@@ -7188,12 +7204,22 @@ exports.getInput = getInput;
71887204
* Sets the value of an output.
71897205
*
71907206
* @param name name of the output to set
7191-
* @param value value to store
7207+
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
71927208
*/
7209+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
71937210
function setOutput(name, value) {
71947211
command_1.issueCommand('set-output', { name }, value);
71957212
}
71967213
exports.setOutput = setOutput;
7214+
/**
7215+
* Enables or disables the echoing of commands into stdout for the rest of the step.
7216+
* Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.
7217+
*
7218+
*/
7219+
function setCommandEcho(enabled) {
7220+
command_1.issue('echo', enabled ? 'on' : 'off');
7221+
}
7222+
exports.setCommandEcho = setCommandEcho;
71977223
//-----------------------------------------------------------------------
71987224
// Results
71997225
//-----------------------------------------------------------------------
@@ -7227,18 +7253,18 @@ function debug(message) {
72277253
exports.debug = debug;
72287254
/**
72297255
* Adds an error issue
7230-
* @param message error issue message
7256+
* @param message error issue message. Errors will be converted to string via toString()
72317257
*/
72327258
function error(message) {
7233-
command_1.issue('error', message);
7259+
command_1.issue('error', message instanceof Error ? message.toString() : message);
72347260
}
72357261
exports.error = error;
72367262
/**
72377263
* Adds an warning issue
7238-
* @param message warning issue message
7264+
* @param message warning issue message. Errors will be converted to string via toString()
72397265
*/
72407266
function warning(message) {
7241-
command_1.issue('warning', message);
7267+
command_1.issue('warning', message instanceof Error ? message.toString() : message);
72427268
}
72437269
exports.warning = warning;
72447270
/**
@@ -7296,8 +7322,9 @@ exports.group = group;
72967322
* Saves state for current action, the state can only be retrieved by this action's post job execution.
72977323
*
72987324
* @param name name of the state to store
7299-
* @param value value to store
7325+
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
73007326
*/
7327+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
73017328
function saveState(name, value) {
73027329
command_1.issueCommand('save-state', { name }, value);
73037330
}

0 commit comments

Comments
 (0)