@@ -4116,128 +4116,118 @@ exports["default"] = _default;
4116
4116
4117
4117
/***/ } ) ,
4118
4118
4119
- /***/ 207 :
4119
+ /***/ 143 :
4120
4120
/***/ ( ( module , __unused_webpack_exports , __nccwpck_require__ ) => {
4121
4121
4122
- const isWindows = process . platform === 'win32' ||
4123
- process . env . OSTYPE === 'cygwin' ||
4124
- process . env . OSTYPE === 'msys'
4125
-
4126
- const path = __nccwpck_require__ ( 17 )
4127
- const COLON = isWindows ? ';' : ':'
4128
4122
const isexe = __nccwpck_require__ ( 126 )
4123
+ const { join, delimiter, sep, posix } = __nccwpck_require__ ( 17 )
4124
+
4125
+ const isWindows = process . platform === 'win32'
4126
+
4127
+ // used to check for slashed in commands passed in. always checks for the posix
4128
+ // seperator on all platforms, and checks for the current separator when not on
4129
+ // a posix platform. don't use the isWindows check for this since that is mocked
4130
+ // in tests but we still need the code to actually work when called. that is also
4131
+ // why it is ignored from coverage.
4132
+ /* istanbul ignore next */
4133
+ const rSlash = new RegExp ( `[${ posix . sep } ${ sep === posix . sep ? '' : sep } ]` . replace ( / ( \\ ) / g, '\\$1' ) )
4134
+ const rRel = new RegExp ( `^\\.${ rSlash . source } ` )
4129
4135
4130
4136
const getNotFoundError = ( cmd ) =>
4131
4137
Object . assign ( new Error ( `not found: ${ cmd } ` ) , { code : 'ENOENT' } )
4132
4138
4133
- const getPathInfo = ( cmd , opt ) => {
4134
- const colon = opt . colon || COLON
4135
-
4139
+ const getPathInfo = ( cmd , {
4140
+ path : optPath = process . env . PATH ,
4141
+ pathExt : optPathExt = process . env . PATHEXT ,
4142
+ delimiter : optDelimiter = delimiter ,
4143
+ } ) => {
4136
4144
// If it has a slash, then we don't bother searching the pathenv.
4137
4145
// just check the file itself, and that's it.
4138
- const pathEnv = cmd . match ( / \/ / ) || isWindows && cmd . match ( / \\ / ) ? [ '' ]
4139
- : (
4140
- [
4141
- // windows always checks the cwd first
4142
- ...( isWindows ? [ process . cwd ( ) ] : [ ] ) ,
4143
- ...( opt . path || process . env . PATH ||
4144
- /* istanbul ignore next: very unusual */ '' ) . split ( colon ) ,
4145
- ]
4146
- )
4147
- const pathExtExe = isWindows
4148
- ? opt . pathExt || process . env . PATHEXT || '.EXE;.CMD;.BAT;.COM'
4149
- : ''
4150
- const pathExt = isWindows ? pathExtExe . split ( colon ) : [ '' ]
4146
+ const pathEnv = cmd . match ( rSlash ) ? [ '' ] : [
4147
+ // windows always checks the cwd first
4148
+ ...( isWindows ? [ process . cwd ( ) ] : [ ] ) ,
4149
+ ...( optPath || /* istanbul ignore next: very unusual */ '' ) . split ( optDelimiter ) ,
4150
+ ]
4151
4151
4152
4152
if ( isWindows ) {
4153
- if ( cmd . indexOf ( '.' ) !== - 1 && pathExt [ 0 ] !== '' )
4153
+ const pathExtExe = optPathExt ||
4154
+ [ '.EXE' , '.CMD' , '.BAT' , '.COM' ] . join ( optDelimiter )
4155
+ const pathExt = pathExtExe . split ( optDelimiter ) . reduce ( ( acc , item ) => {
4156
+ acc . push ( item )
4157
+ acc . push ( item . toLowerCase ( ) )
4158
+ return acc
4159
+ } , [ ] )
4160
+ if ( cmd . includes ( '.' ) && pathExt [ 0 ] !== '' ) {
4154
4161
pathExt . unshift ( '' )
4162
+ }
4163
+ return { pathEnv, pathExt, pathExtExe }
4155
4164
}
4156
4165
4157
- return {
4158
- pathEnv,
4159
- pathExt,
4160
- pathExtExe,
4161
- }
4166
+ return { pathEnv, pathExt : [ '' ] }
4162
4167
}
4163
4168
4164
- const which = ( cmd , opt , cb ) => {
4165
- if ( typeof opt === 'function' ) {
4166
- cb = opt
4167
- opt = { }
4168
- }
4169
- if ( ! opt )
4170
- opt = { }
4169
+ const getPathPart = ( raw , cmd ) => {
4170
+ const pathPart = / ^ " .* " $ / . test ( raw ) ? raw . slice ( 1 , - 1 ) : raw
4171
+ const prefix = ! pathPart && rRel . test ( cmd ) ? cmd . slice ( 0 , 2 ) : ''
4172
+ return prefix + join ( pathPart , cmd )
4173
+ }
4171
4174
4175
+ const which = async ( cmd , opt = { } ) => {
4172
4176
const { pathEnv, pathExt, pathExtExe } = getPathInfo ( cmd , opt )
4173
4177
const found = [ ]
4174
4178
4175
- const step = i => new Promise ( ( resolve , reject ) => {
4176
- if ( i === pathEnv . length )
4177
- return opt . all && found . length ? resolve ( found )
4178
- : reject ( getNotFoundError ( cmd ) )
4179
+ for ( const envPart of pathEnv ) {
4180
+ const p = getPathPart ( envPart , cmd )
4179
4181
4180
- const ppRaw = pathEnv [ i ]
4181
- const pathPart = / ^ " .* " $ / . test ( ppRaw ) ? ppRaw . slice ( 1 , - 1 ) : ppRaw
4182
-
4183
- const pCmd = path . join ( pathPart , cmd )
4184
- const p = ! pathPart && / ^ \. [ \\ \/ ] / . test ( cmd ) ? cmd . slice ( 0 , 2 ) + pCmd
4185
- : pCmd
4182
+ for ( const ext of pathExt ) {
4183
+ const withExt = p + ext
4184
+ const is = await isexe ( withExt , { pathExt : pathExtExe , ignoreErrors : true } )
4185
+ if ( is ) {
4186
+ if ( ! opt . all ) {
4187
+ return withExt
4188
+ }
4189
+ found . push ( withExt )
4190
+ }
4191
+ }
4192
+ }
4186
4193
4187
- resolve ( subStep ( p , i , 0 ) )
4188
- } )
4194
+ if ( opt . all && found . length ) {
4195
+ return found
4196
+ }
4189
4197
4190
- const subStep = ( p , i , ii ) => new Promise ( ( resolve , reject ) => {
4191
- if ( ii === pathExt . length )
4192
- return resolve ( step ( i + 1 ) )
4193
- const ext = pathExt [ ii ]
4194
- isexe ( p + ext , { pathExt : pathExtExe } , ( er , is ) => {
4195
- if ( ! er && is ) {
4196
- if ( opt . all )
4197
- found . push ( p + ext )
4198
- else
4199
- return resolve ( p + ext )
4200
- }
4201
- return resolve ( subStep ( p , i , ii + 1 ) )
4202
- } )
4203
- } )
4198
+ if ( opt . nothrow ) {
4199
+ return null
4200
+ }
4204
4201
4205
- return cb ? step ( 0 ) . then ( res => cb ( null , res ) , cb ) : step ( 0 )
4202
+ throw getNotFoundError ( cmd )
4206
4203
}
4207
4204
4208
- const whichSync = ( cmd , opt ) => {
4209
- opt = opt || { }
4210
-
4205
+ const whichSync = ( cmd , opt = { } ) => {
4211
4206
const { pathEnv, pathExt, pathExtExe } = getPathInfo ( cmd , opt )
4212
4207
const found = [ ]
4213
4208
4214
- for ( let i = 0 ; i < pathEnv . length ; i ++ ) {
4215
- const ppRaw = pathEnv [ i ]
4216
- const pathPart = / ^ " .* " $ / . test ( ppRaw ) ? ppRaw . slice ( 1 , - 1 ) : ppRaw
4217
-
4218
- const pCmd = path . join ( pathPart , cmd )
4219
- const p = ! pathPart && / ^ \. [ \\ \/ ] / . test ( cmd ) ? cmd . slice ( 0 , 2 ) + pCmd
4220
- : pCmd
4221
-
4222
- for ( let j = 0 ; j < pathExt . length ; j ++ ) {
4223
- const cur = p + pathExt [ j ]
4224
- try {
4225
- const is = isexe . sync ( cur , { pathExt : pathExtExe } )
4226
- if ( is ) {
4227
- if ( opt . all )
4228
- found . push ( cur )
4229
- else
4230
- return cur
4209
+ for ( const pathEnvPart of pathEnv ) {
4210
+ const p = getPathPart ( pathEnvPart , cmd )
4211
+
4212
+ for ( const ext of pathExt ) {
4213
+ const withExt = p + ext
4214
+ const is = isexe . sync ( withExt , { pathExt : pathExtExe , ignoreErrors : true } )
4215
+ if ( is ) {
4216
+ if ( ! opt . all ) {
4217
+ return withExt
4231
4218
}
4232
- } catch ( ex ) { }
4219
+ found . push ( withExt )
4220
+ }
4233
4221
}
4234
4222
}
4235
4223
4236
- if ( opt . all && found . length )
4224
+ if ( opt . all && found . length ) {
4237
4225
return found
4226
+ }
4238
4227
4239
- if ( opt . nothrow )
4228
+ if ( opt . nothrow ) {
4240
4229
return null
4230
+ }
4241
4231
4242
4232
throw getNotFoundError ( cmd )
4243
4233
}
@@ -4255,7 +4245,11 @@ which.sync = whichSync
4255
4245
4256
4246
var __createBinding = ( this && this . __createBinding ) || ( Object . create ? ( function ( o , m , k , k2 ) {
4257
4247
if ( k2 === undefined ) k2 = k ;
4258
- Object . defineProperty ( o , k2 , { enumerable : true , get : function ( ) { return m [ k ] ; } } ) ;
4248
+ var desc = Object . getOwnPropertyDescriptor ( m , k ) ;
4249
+ if ( ! desc || ( "get" in desc ? ! m . __esModule : desc . writable || desc . configurable ) ) {
4250
+ desc = { enumerable : true , get : function ( ) { return m [ k ] ; } } ;
4251
+ }
4252
+ Object . defineProperty ( o , k2 , desc ) ;
4259
4253
} ) : ( function ( o , m , k , k2 ) {
4260
4254
if ( k2 === undefined ) k2 = k ;
4261
4255
o [ k2 ] = m [ k ] ;
@@ -4268,7 +4262,7 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
4268
4262
var __importStar = ( this && this . __importStar ) || function ( mod ) {
4269
4263
if ( mod && mod . __esModule ) return mod ;
4270
4264
var result = { } ;
4271
- if ( mod != null ) for ( var k in mod ) if ( k !== "default" && Object . hasOwnProperty . call ( mod , k ) ) __createBinding ( result , mod , k ) ;
4265
+ if ( mod != null ) for ( var k in mod ) if ( k !== "default" && Object . prototype . hasOwnProperty . call ( mod , k ) ) __createBinding ( result , mod , k ) ;
4272
4266
__setModuleDefault ( result , mod ) ;
4273
4267
return result ;
4274
4268
} ;
@@ -4288,7 +4282,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
4288
4282
exports . IsPost = void 0 ;
4289
4283
const core = __importStar ( __nccwpck_require__ ( 186 ) ) ;
4290
4284
const exec = __importStar ( __nccwpck_require__ ( 514 ) ) ;
4291
- const which_1 = __importDefault ( __nccwpck_require__ ( 207 ) ) ;
4285
+ const which_1 = __importDefault ( __nccwpck_require__ ( 143 ) ) ;
4292
4286
exports . IsPost = ! ! process . env [ 'STATE_isPost' ] ;
4293
4287
// inputs
4294
4288
const name = core . getInput ( 'name' , { required : true } ) ;
0 commit comments