@@ -137,6 +137,32 @@ function onceStrict (fn) {
137
137
}
138
138
139
139
140
+ /***/ } ) ,
141
+
142
+ /***/ 82 :
143
+ /***/ ( function ( __unusedmodule , exports ) {
144
+
145
+ "use strict" ;
146
+
147
+ // We use any as a valid input type
148
+ /* eslint-disable @typescript-eslint/no-explicit-any */
149
+ Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
150
+ /**
151
+ * Sanitizes an input into a string so it can be passed into issueCommand safely
152
+ * @param input input to sanitize into a string
153
+ */
154
+ function toCommandValue ( input ) {
155
+ if ( input === null || input === undefined ) {
156
+ return '' ;
157
+ }
158
+ else if ( typeof input === 'string' || input instanceof String ) {
159
+ return input ;
160
+ }
161
+ return JSON . stringify ( input ) ;
162
+ }
163
+ exports . toCommandValue = toCommandValue ;
164
+ //# sourceMappingURL=utils.js.map
165
+
140
166
/***/ } ) ,
141
167
142
168
/***/ 87 :
@@ -1074,6 +1100,42 @@ function regExpEscape (s) {
1074
1100
}
1075
1101
1076
1102
1103
+ /***/ } ) ,
1104
+
1105
+ /***/ 102 :
1106
+ /***/ ( function ( __unusedmodule , exports , __webpack_require__ ) {
1107
+
1108
+ "use strict" ;
1109
+
1110
+ // For internal use, subject to change.
1111
+ var __importStar = ( this && this . __importStar ) || function ( mod ) {
1112
+ if ( mod && mod . __esModule ) return mod ;
1113
+ var result = { } ;
1114
+ if ( mod != null ) for ( var k in mod ) if ( Object . hasOwnProperty . call ( mod , k ) ) result [ k ] = mod [ k ] ;
1115
+ result [ "default" ] = mod ;
1116
+ return result ;
1117
+ } ;
1118
+ Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
1119
+ // We use any as a valid input type
1120
+ /* eslint-disable @typescript-eslint/no-explicit-any */
1121
+ const fs = __importStar ( __webpack_require__ ( 747 ) ) ;
1122
+ const os = __importStar ( __webpack_require__ ( 87 ) ) ;
1123
+ const utils_1 = __webpack_require__ ( 82 ) ;
1124
+ function issueCommand ( command , message ) {
1125
+ const filePath = process . env [ `GITHUB_${ command } ` ] ;
1126
+ if ( ! filePath ) {
1127
+ throw new Error ( `Unable to find environment variable for file command ${ command } ` ) ;
1128
+ }
1129
+ if ( ! fs . existsSync ( filePath ) ) {
1130
+ throw new Error ( `Missing file at path: ${ filePath } ` ) ;
1131
+ }
1132
+ fs . appendFileSync ( filePath , `${ utils_1 . toCommandValue ( message ) } ${ os . EOL } ` , {
1133
+ encoding : 'utf8'
1134
+ } ) ;
1135
+ }
1136
+ exports . issueCommand = issueCommand ;
1137
+ //# sourceMappingURL=file-command.js.map
1138
+
1077
1139
/***/ } ) ,
1078
1140
1079
1141
/***/ 117 :
@@ -4917,6 +4979,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
4917
4979
} ;
4918
4980
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
4919
4981
const os = __importStar ( __webpack_require__ ( 87 ) ) ;
4982
+ const utils_1 = __webpack_require__ ( 82 ) ;
4920
4983
/**
4921
4984
* Commands
4922
4985
*
@@ -4971,13 +5034,13 @@ class Command {
4971
5034
}
4972
5035
}
4973
5036
function escapeData ( s ) {
4974
- return ( s || '' )
5037
+ return utils_1 . toCommandValue ( s )
4975
5038
. replace ( / % / g, '%25' )
4976
5039
. replace ( / \r / g, '%0D' )
4977
5040
. replace ( / \n / g, '%0A' ) ;
4978
5041
}
4979
5042
function escapeProperty ( s ) {
4980
- return ( s || '' )
5043
+ return utils_1 . toCommandValue ( s )
4981
5044
. replace ( / % / g, '%25' )
4982
5045
. replace ( / \r / g, '%0D' )
4983
5046
. replace ( / \n / g, '%0A' )
@@ -5049,6 +5112,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
5049
5112
} ;
5050
5113
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
5051
5114
const command_1 = __webpack_require__ ( 431 ) ;
5115
+ const file_command_1 = __webpack_require__ ( 102 ) ;
5116
+ const utils_1 = __webpack_require__ ( 82 ) ;
5052
5117
const os = __importStar ( __webpack_require__ ( 87 ) ) ;
5053
5118
const path = __importStar ( __webpack_require__ ( 622 ) ) ;
5054
5119
/**
@@ -5071,11 +5136,21 @@ var ExitCode;
5071
5136
/**
5072
5137
* Sets env variable for this action and future actions in the job
5073
5138
* @param name the name of the variable to set
5074
- * @param val the value of the variable
5139
+ * @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify
5075
5140
*/
5141
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5076
5142
function exportVariable ( name , val ) {
5077
- process . env [ name ] = val ;
5078
- command_1 . issueCommand ( 'set-env' , { name } , val ) ;
5143
+ const convertedVal = utils_1 . toCommandValue ( val ) ;
5144
+ process . env [ name ] = convertedVal ;
5145
+ const filePath = process . env [ 'GITHUB_ENV' ] || '' ;
5146
+ if ( filePath ) {
5147
+ const delimiter = '_GitHubActionsFileCommandDelimeter_' ;
5148
+ const commandValue = `${ name } <<${ delimiter } ${ os . EOL } ${ convertedVal } ${ os . EOL } ${ delimiter } ` ;
5149
+ file_command_1 . issueCommand ( 'ENV' , commandValue ) ;
5150
+ }
5151
+ else {
5152
+ command_1 . issueCommand ( 'set-env' , { name } , convertedVal ) ;
5153
+ }
5079
5154
}
5080
5155
exports . exportVariable = exportVariable ;
5081
5156
/**
@@ -5091,7 +5166,13 @@ exports.setSecret = setSecret;
5091
5166
* @param inputPath
5092
5167
*/
5093
5168
function addPath ( inputPath ) {
5094
- command_1 . issueCommand ( 'add-path' , { } , inputPath ) ;
5169
+ const filePath = process . env [ 'GITHUB_PATH' ] || '' ;
5170
+ if ( filePath ) {
5171
+ file_command_1 . issueCommand ( 'PATH' , inputPath ) ;
5172
+ }
5173
+ else {
5174
+ command_1 . issueCommand ( 'add-path' , { } , inputPath ) ;
5175
+ }
5095
5176
process . env [ 'PATH' ] = `${ inputPath } ${ path . delimiter } ${ process . env [ 'PATH' ] } ` ;
5096
5177
}
5097
5178
exports . addPath = addPath ;
@@ -5114,12 +5195,22 @@ exports.getInput = getInput;
5114
5195
* Sets the value of an output.
5115
5196
*
5116
5197
* @param name name of the output to set
5117
- * @param value value to store
5198
+ * @param value value to store. Non-string values will be converted to a string via JSON.stringify
5118
5199
*/
5200
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5119
5201
function setOutput ( name , value ) {
5120
5202
command_1 . issueCommand ( 'set-output' , { name } , value ) ;
5121
5203
}
5122
5204
exports . setOutput = setOutput ;
5205
+ /**
5206
+ * Enables or disables the echoing of commands into stdout for the rest of the step.
5207
+ * Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.
5208
+ *
5209
+ */
5210
+ function setCommandEcho ( enabled ) {
5211
+ command_1 . issue ( 'echo' , enabled ? 'on' : 'off' ) ;
5212
+ }
5213
+ exports . setCommandEcho = setCommandEcho ;
5123
5214
//-----------------------------------------------------------------------
5124
5215
// Results
5125
5216
//-----------------------------------------------------------------------
@@ -5153,18 +5244,18 @@ function debug(message) {
5153
5244
exports . debug = debug ;
5154
5245
/**
5155
5246
* Adds an error issue
5156
- * @param message error issue message
5247
+ * @param message error issue message. Errors will be converted to string via toString()
5157
5248
*/
5158
5249
function error ( message ) {
5159
- command_1 . issue ( 'error' , message ) ;
5250
+ command_1 . issue ( 'error' , message instanceof Error ? message . toString ( ) : message ) ;
5160
5251
}
5161
5252
exports . error = error ;
5162
5253
/**
5163
5254
* Adds an warning issue
5164
- * @param message warning issue message
5255
+ * @param message warning issue message. Errors will be converted to string via toString()
5165
5256
*/
5166
5257
function warning ( message ) {
5167
- command_1 . issue ( 'warning' , message ) ;
5258
+ command_1 . issue ( 'warning' , message instanceof Error ? message . toString ( ) : message ) ;
5168
5259
}
5169
5260
exports . warning = warning ;
5170
5261
/**
@@ -5222,8 +5313,9 @@ exports.group = group;
5222
5313
* Saves state for current action, the state can only be retrieved by this action's post job execution.
5223
5314
*
5224
5315
* @param name name of the state to store
5225
- * @param value value to store
5316
+ * @param value value to store. Non-string values will be converted to a string via JSON.stringify
5226
5317
*/
5318
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5227
5319
function saveState ( name , value ) {
5228
5320
command_1 . issueCommand ( 'save-state' , { name } , value ) ;
5229
5321
}
0 commit comments