@@ -21232,14 +21232,28 @@ class Command {
21232
21232
return cmdStr;
21233
21233
}
21234
21234
}
21235
+ /**
21236
+ * Sanitizes an input into a string so it can be passed into issueCommand safely
21237
+ * @param input input to sanitize into a string
21238
+ */
21239
+ function toCommandValue(input) {
21240
+ if (input === null || input === undefined) {
21241
+ return '';
21242
+ }
21243
+ else if (typeof input === 'string' || input instanceof String) {
21244
+ return input;
21245
+ }
21246
+ return JSON.stringify(input);
21247
+ }
21248
+ exports.toCommandValue = toCommandValue;
21235
21249
function escapeData(s) {
21236
- return (s || '' )
21250
+ return toCommandValue(s )
21237
21251
.replace(/%/g, '%25')
21238
21252
.replace(/\r/g, '%0D')
21239
21253
.replace(/\n/g, '%0A');
21240
21254
}
21241
21255
function escapeProperty(s) {
21242
- return (s || '' )
21256
+ return toCommandValue(s )
21243
21257
.replace(/%/g, '%25')
21244
21258
.replace(/\r/g, '%0D')
21245
21259
.replace(/\n/g, '%0A')
@@ -29066,11 +29080,13 @@ var ExitCode;
29066
29080
/**
29067
29081
* Sets env variable for this action and future actions in the job
29068
29082
* @param name the name of the variable to set
29069
- * @param val the value of the variable
29083
+ * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify
29070
29084
*/
29085
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
29071
29086
function exportVariable(name, val) {
29072
- process.env[name] = val;
29073
- command_1.issueCommand('set-env', { name }, val);
29087
+ const convertedVal = command_1.toCommandValue(val);
29088
+ process.env[name] = convertedVal;
29089
+ command_1.issueCommand('set-env', { name }, convertedVal);
29074
29090
}
29075
29091
exports.exportVariable = exportVariable;
29076
29092
/**
@@ -29109,12 +29125,22 @@ exports.getInput = getInput;
29109
29125
* Sets the value of an output.
29110
29126
*
29111
29127
* @param name name of the output to set
29112
- * @param value value to store
29128
+ * @param value value to store. Non-string values will be converted to a string via JSON.stringify
29113
29129
*/
29130
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
29114
29131
function setOutput(name, value) {
29115
29132
command_1.issueCommand('set-output', { name }, value);
29116
29133
}
29117
29134
exports.setOutput = setOutput;
29135
+ /**
29136
+ * Enables or disables the echoing of commands into stdout for the rest of the step.
29137
+ * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.
29138
+ *
29139
+ */
29140
+ function setCommandEcho(enabled) {
29141
+ command_1.issue('echo', enabled ? 'on' : 'off');
29142
+ }
29143
+ exports.setCommandEcho = setCommandEcho;
29118
29144
//-----------------------------------------------------------------------
29119
29145
// Results
29120
29146
//-----------------------------------------------------------------------
@@ -29148,18 +29174,18 @@ function debug(message) {
29148
29174
exports.debug = debug;
29149
29175
/**
29150
29176
* Adds an error issue
29151
- * @param message error issue message
29177
+ * @param message error issue message. Errors will be converted to string via toString()
29152
29178
*/
29153
29179
function error(message) {
29154
- command_1.issue('error', message);
29180
+ command_1.issue('error', message instanceof Error ? message.toString() : message );
29155
29181
}
29156
29182
exports.error = error;
29157
29183
/**
29158
29184
* Adds an warning issue
29159
- * @param message warning issue message
29185
+ * @param message warning issue message. Errors will be converted to string via toString()
29160
29186
*/
29161
29187
function warning(message) {
29162
- command_1.issue('warning', message);
29188
+ command_1.issue('warning', message instanceof Error ? message.toString() : message );
29163
29189
}
29164
29190
exports.warning = warning;
29165
29191
/**
@@ -29217,8 +29243,9 @@ exports.group = group;
29217
29243
* Saves state for current action, the state can only be retrieved by this action's post job execution.
29218
29244
*
29219
29245
* @param name name of the state to store
29220
- * @param value value to store
29246
+ * @param value value to store. Non-string values will be converted to a string via JSON.stringify
29221
29247
*/
29248
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
29222
29249
function saveState(name, value) {
29223
29250
command_1.issueCommand('save-state', { name }, value);
29224
29251
}
0 commit comments