@@ -5129,14 +5129,28 @@ class Command {
5129
5129
return cmdStr;
5130
5130
}
5131
5131
}
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;
5132
5146
function escapeData(s) {
5133
- return (s || '' )
5147
+ return toCommandValue(s )
5134
5148
.replace(/%/g, '%25')
5135
5149
.replace(/\r/g, '%0D')
5136
5150
.replace(/\n/g, '%0A');
5137
5151
}
5138
5152
function escapeProperty(s) {
5139
- return (s || '' )
5153
+ return toCommandValue(s )
5140
5154
.replace(/%/g, '%25')
5141
5155
.replace(/\r/g, '%0D')
5142
5156
.replace(/\n/g, '%0A')
@@ -7145,11 +7159,13 @@ var ExitCode;
7145
7159
/**
7146
7160
* Sets env variable for this action and future actions in the job
7147
7161
* @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
7149
7163
*/
7164
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
7150
7165
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);
7153
7169
}
7154
7170
exports.exportVariable = exportVariable;
7155
7171
/**
@@ -7188,12 +7204,22 @@ exports.getInput = getInput;
7188
7204
* Sets the value of an output.
7189
7205
*
7190
7206
* @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
7192
7208
*/
7209
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
7193
7210
function setOutput(name, value) {
7194
7211
command_1.issueCommand('set-output', { name }, value);
7195
7212
}
7196
7213
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;
7197
7223
//-----------------------------------------------------------------------
7198
7224
// Results
7199
7225
//-----------------------------------------------------------------------
@@ -7227,18 +7253,18 @@ function debug(message) {
7227
7253
exports.debug = debug;
7228
7254
/**
7229
7255
* Adds an error issue
7230
- * @param message error issue message
7256
+ * @param message error issue message. Errors will be converted to string via toString()
7231
7257
*/
7232
7258
function error(message) {
7233
- command_1.issue('error', message);
7259
+ command_1.issue('error', message instanceof Error ? message.toString() : message );
7234
7260
}
7235
7261
exports.error = error;
7236
7262
/**
7237
7263
* Adds an warning issue
7238
- * @param message warning issue message
7264
+ * @param message warning issue message. Errors will be converted to string via toString()
7239
7265
*/
7240
7266
function warning(message) {
7241
- command_1.issue('warning', message);
7267
+ command_1.issue('warning', message instanceof Error ? message.toString() : message );
7242
7268
}
7243
7269
exports.warning = warning;
7244
7270
/**
@@ -7296,8 +7322,9 @@ exports.group = group;
7296
7322
* Saves state for current action, the state can only be retrieved by this action's post job execution.
7297
7323
*
7298
7324
* @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
7300
7326
*/
7327
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
7301
7328
function saveState(name, value) {
7302
7329
command_1.issueCommand('save-state', { name }, value);
7303
7330
}
0 commit comments