├── .gitignore ├── README.md ├── action.yml ├── dist └── index.js ├── index.js ├── package-lock.json ├── package.json └── util.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # render-json-action 2 | 3 | This action render json file with environment variables 4 | and return rendered json file path 5 | 6 | ## Example usage 7 | 8 | ```yaml 9 | - uses: loveloper44/render-json-action@v2.0.2 10 | id: render 11 | with: 12 | json: jsonFilePath 13 | 14 | - name: Get the output 15 | run: echo "${{ steps.render.outputs.result }}" 16 | ``` 17 | 18 | ## Json file 19 | 20 | Create input json file 21 | 22 | ```json 23 | { 24 | "app": { 25 | "service_id": "%s ENV_SERVICE_ID" 26 | }, 27 | "db":{ 28 | "host": "%s ENV_DB_HOST", 29 | "port": "%d ENV_DB_PORT", 30 | "user_name": "%s ENV_DB_USER_NAME", 31 | "user_password": "%s ENV_DB_USER_PASSWORD", 32 | } 33 | } 34 | ``` 35 | 36 | You can use 4 types like below 37 | 38 | - %d number 39 | - %s string 40 | - %b boolean 41 | - %f float 42 | 43 | Action will render json file with environment variables 44 | and return rendered json file path 45 | 46 | ```json 47 | { 48 | "app": { 49 | "service_id": "TestService" 50 | }, 51 | "db":{ 52 | "host": "localhost", 53 | "port": 3306, 54 | "user_name": "user", 55 | "user_password": "password", 56 | } 57 | } 58 | ``` 59 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: Render json 2 | description: "render json file with environment variables" 3 | inputs: 4 | json: # id of input 5 | description: "Json file path" 6 | required: true 7 | outputs: 8 | result: # id of output 9 | description: "Result" 10 | runs: 11 | using: "node12" 12 | main: "dist/index.js" 13 | -------------------------------------------------------------------------------- /dist/index.js: -------------------------------------------------------------------------------- 1 | module.exports = 2 | /******/ (function(modules, runtime) { // webpackBootstrap 3 | /******/ "use strict"; 4 | /******/ // The module cache 5 | /******/ var installedModules = {}; 6 | /******/ 7 | /******/ // The require function 8 | /******/ function __webpack_require__(moduleId) { 9 | /******/ 10 | /******/ // Check if module is in cache 11 | /******/ if(installedModules[moduleId]) { 12 | /******/ return installedModules[moduleId].exports; 13 | /******/ } 14 | /******/ // Create a new module (and put it into the cache) 15 | /******/ var module = installedModules[moduleId] = { 16 | /******/ i: moduleId, 17 | /******/ l: false, 18 | /******/ exports: {} 19 | /******/ }; 20 | /******/ 21 | /******/ // Execute the module function 22 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 23 | /******/ 24 | /******/ // Flag the module as loaded 25 | /******/ module.l = true; 26 | /******/ 27 | /******/ // Return the exports of the module 28 | /******/ return module.exports; 29 | /******/ } 30 | /******/ 31 | /******/ 32 | /******/ __webpack_require__.ab = __dirname + "/"; 33 | /******/ 34 | /******/ // the startup function 35 | /******/ function startup() { 36 | /******/ // Load entry module and return exports 37 | /******/ return __webpack_require__(622); 38 | /******/ }; 39 | /******/ // initialize runtime 40 | /******/ runtime(__webpack_require__); 41 | /******/ 42 | /******/ // run startup 43 | /******/ return startup(); 44 | /******/ }) 45 | /************************************************************************/ 46 | /******/ ({ 47 | 48 | /***/ 18: 49 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 50 | 51 | exports.alphasort = alphasort 52 | exports.alphasorti = alphasorti 53 | exports.setopts = setopts 54 | exports.ownProp = ownProp 55 | exports.makeAbs = makeAbs 56 | exports.finish = finish 57 | exports.mark = mark 58 | exports.isIgnored = isIgnored 59 | exports.childrenIgnored = childrenIgnored 60 | 61 | function ownProp (obj, field) { 62 | return Object.prototype.hasOwnProperty.call(obj, field) 63 | } 64 | 65 | var path = __webpack_require__(277) 66 | var minimatch = __webpack_require__(689) 67 | var isAbsolute = __webpack_require__(829) 68 | var Minimatch = minimatch.Minimatch 69 | 70 | function alphasorti (a, b) { 71 | return a.toLowerCase().localeCompare(b.toLowerCase()) 72 | } 73 | 74 | function alphasort (a, b) { 75 | return a.localeCompare(b) 76 | } 77 | 78 | function setupIgnores (self, options) { 79 | self.ignore = options.ignore || [] 80 | 81 | if (!Array.isArray(self.ignore)) 82 | self.ignore = [self.ignore] 83 | 84 | if (self.ignore.length) { 85 | self.ignore = self.ignore.map(ignoreMap) 86 | } 87 | } 88 | 89 | // ignore patterns are always in dot:true mode. 90 | function ignoreMap (pattern) { 91 | var gmatcher = null 92 | if (pattern.slice(-3) === '/**') { 93 | var gpattern = pattern.replace(/(\/\*\*)+$/, '') 94 | gmatcher = new Minimatch(gpattern, { dot: true }) 95 | } 96 | 97 | return { 98 | matcher: new Minimatch(pattern, { dot: true }), 99 | gmatcher: gmatcher 100 | } 101 | } 102 | 103 | function setopts (self, pattern, options) { 104 | if (!options) 105 | options = {} 106 | 107 | // base-matching: just use globstar for that. 108 | if (options.matchBase && -1 === pattern.indexOf("/")) { 109 | if (options.noglobstar) { 110 | throw new Error("base matching requires globstar") 111 | } 112 | pattern = "**/" + pattern 113 | } 114 | 115 | self.silent = !!options.silent 116 | self.pattern = pattern 117 | self.strict = options.strict !== false 118 | self.realpath = !!options.realpath 119 | self.realpathCache = options.realpathCache || Object.create(null) 120 | self.follow = !!options.follow 121 | self.dot = !!options.dot 122 | self.mark = !!options.mark 123 | self.nodir = !!options.nodir 124 | if (self.nodir) 125 | self.mark = true 126 | self.sync = !!options.sync 127 | self.nounique = !!options.nounique 128 | self.nonull = !!options.nonull 129 | self.nosort = !!options.nosort 130 | self.nocase = !!options.nocase 131 | self.stat = !!options.stat 132 | self.noprocess = !!options.noprocess 133 | self.absolute = !!options.absolute 134 | 135 | self.maxLength = options.maxLength || Infinity 136 | self.cache = options.cache || Object.create(null) 137 | self.statCache = options.statCache || Object.create(null) 138 | self.symlinks = options.symlinks || Object.create(null) 139 | 140 | setupIgnores(self, options) 141 | 142 | self.changedCwd = false 143 | var cwd = process.cwd() 144 | if (!ownProp(options, "cwd")) 145 | self.cwd = cwd 146 | else { 147 | self.cwd = path.resolve(options.cwd) 148 | self.changedCwd = self.cwd !== cwd 149 | } 150 | 151 | self.root = options.root || path.resolve(self.cwd, "/") 152 | self.root = path.resolve(self.root) 153 | if (process.platform === "win32") 154 | self.root = self.root.replace(/\\/g, "/") 155 | 156 | // TODO: is an absolute `cwd` supposed to be resolved against `root`? 157 | // e.g. { cwd: '/test', root: __dirname } === path.join(__dirname, '/test') 158 | self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd) 159 | if (process.platform === "win32") 160 | self.cwdAbs = self.cwdAbs.replace(/\\/g, "/") 161 | self.nomount = !!options.nomount 162 | 163 | // disable comments and negation in Minimatch. 164 | // Note that they are not supported in Glob itself anyway. 165 | options.nonegate = true 166 | options.nocomment = true 167 | 168 | self.minimatch = new Minimatch(pattern, options) 169 | self.options = self.minimatch.options 170 | } 171 | 172 | function finish (self) { 173 | var nou = self.nounique 174 | var all = nou ? [] : Object.create(null) 175 | 176 | for (var i = 0, l = self.matches.length; i < l; i ++) { 177 | var matches = self.matches[i] 178 | if (!matches || Object.keys(matches).length === 0) { 179 | if (self.nonull) { 180 | // do like the shell, and spit out the literal glob 181 | var literal = self.minimatch.globSet[i] 182 | if (nou) 183 | all.push(literal) 184 | else 185 | all[literal] = true 186 | } 187 | } else { 188 | // had matches 189 | var m = Object.keys(matches) 190 | if (nou) 191 | all.push.apply(all, m) 192 | else 193 | m.forEach(function (m) { 194 | all[m] = true 195 | }) 196 | } 197 | } 198 | 199 | if (!nou) 200 | all = Object.keys(all) 201 | 202 | if (!self.nosort) 203 | all = all.sort(self.nocase ? alphasorti : alphasort) 204 | 205 | // at *some* point we statted all of these 206 | if (self.mark) { 207 | for (var i = 0; i < all.length; i++) { 208 | all[i] = self._mark(all[i]) 209 | } 210 | if (self.nodir) { 211 | all = all.filter(function (e) { 212 | var notDir = !(/\/$/.test(e)) 213 | var c = self.cache[e] || self.cache[makeAbs(self, e)] 214 | if (notDir && c) 215 | notDir = c !== 'DIR' && !Array.isArray(c) 216 | return notDir 217 | }) 218 | } 219 | } 220 | 221 | if (self.ignore.length) 222 | all = all.filter(function(m) { 223 | return !isIgnored(self, m) 224 | }) 225 | 226 | self.found = all 227 | } 228 | 229 | function mark (self, p) { 230 | var abs = makeAbs(self, p) 231 | var c = self.cache[abs] 232 | var m = p 233 | if (c) { 234 | var isDir = c === 'DIR' || Array.isArray(c) 235 | var slash = p.slice(-1) === '/' 236 | 237 | if (isDir && !slash) 238 | m += '/' 239 | else if (!isDir && slash) 240 | m = m.slice(0, -1) 241 | 242 | if (m !== p) { 243 | var mabs = makeAbs(self, m) 244 | self.statCache[mabs] = self.statCache[abs] 245 | self.cache[mabs] = self.cache[abs] 246 | } 247 | } 248 | 249 | return m 250 | } 251 | 252 | // lotta situps... 253 | function makeAbs (self, f) { 254 | var abs = f 255 | if (f.charAt(0) === '/') { 256 | abs = path.join(self.root, f) 257 | } else if (isAbsolute(f) || f === '') { 258 | abs = f 259 | } else if (self.changedCwd) { 260 | abs = path.resolve(self.cwd, f) 261 | } else { 262 | abs = path.resolve(f) 263 | } 264 | 265 | if (process.platform === 'win32') 266 | abs = abs.replace(/\\/g, '/') 267 | 268 | return abs 269 | } 270 | 271 | 272 | // Return true, if pattern ends with globstar '**', for the accompanying parent directory. 273 | // Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents 274 | function isIgnored (self, path) { 275 | if (!self.ignore.length) 276 | return false 277 | 278 | return self.ignore.some(function(item) { 279 | return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path)) 280 | }) 281 | } 282 | 283 | function childrenIgnored (self, path) { 284 | if (!self.ignore.length) 285 | return false 286 | 287 | return self.ignore.some(function(item) { 288 | return !!(item.gmatcher && item.gmatcher.match(path)) 289 | }) 290 | } 291 | 292 | 293 | /***/ }), 294 | 295 | /***/ 87: 296 | /***/ (function(module) { 297 | 298 | module.exports = require("os"); 299 | 300 | /***/ }), 301 | 302 | /***/ 133: 303 | /***/ (function(module, __unusedexports, __webpack_require__) { 304 | 305 | module.exports = globSync 306 | globSync.GlobSync = GlobSync 307 | 308 | var fs = __webpack_require__(747) 309 | var rp = __webpack_require__(544) 310 | var minimatch = __webpack_require__(689) 311 | var Minimatch = minimatch.Minimatch 312 | var Glob = __webpack_require__(696).Glob 313 | var util = __webpack_require__(669) 314 | var path = __webpack_require__(277) 315 | var assert = __webpack_require__(357) 316 | var isAbsolute = __webpack_require__(829) 317 | var common = __webpack_require__(18) 318 | var alphasort = common.alphasort 319 | var alphasorti = common.alphasorti 320 | var setopts = common.setopts 321 | var ownProp = common.ownProp 322 | var childrenIgnored = common.childrenIgnored 323 | var isIgnored = common.isIgnored 324 | 325 | function globSync (pattern, options) { 326 | if (typeof options === 'function' || arguments.length === 3) 327 | throw new TypeError('callback provided to sync glob\n'+ 328 | 'See: https://github.com/isaacs/node-glob/issues/167') 329 | 330 | return new GlobSync(pattern, options).found 331 | } 332 | 333 | function GlobSync (pattern, options) { 334 | if (!pattern) 335 | throw new Error('must provide pattern') 336 | 337 | if (typeof options === 'function' || arguments.length === 3) 338 | throw new TypeError('callback provided to sync glob\n'+ 339 | 'See: https://github.com/isaacs/node-glob/issues/167') 340 | 341 | if (!(this instanceof GlobSync)) 342 | return new GlobSync(pattern, options) 343 | 344 | setopts(this, pattern, options) 345 | 346 | if (this.noprocess) 347 | return this 348 | 349 | var n = this.minimatch.set.length 350 | this.matches = new Array(n) 351 | for (var i = 0; i < n; i ++) { 352 | this._process(this.minimatch.set[i], i, false) 353 | } 354 | this._finish() 355 | } 356 | 357 | GlobSync.prototype._finish = function () { 358 | assert(this instanceof GlobSync) 359 | if (this.realpath) { 360 | var self = this 361 | this.matches.forEach(function (matchset, index) { 362 | var set = self.matches[index] = Object.create(null) 363 | for (var p in matchset) { 364 | try { 365 | p = self._makeAbs(p) 366 | var real = rp.realpathSync(p, self.realpathCache) 367 | set[real] = true 368 | } catch (er) { 369 | if (er.syscall === 'stat') 370 | set[self._makeAbs(p)] = true 371 | else 372 | throw er 373 | } 374 | } 375 | }) 376 | } 377 | common.finish(this) 378 | } 379 | 380 | 381 | GlobSync.prototype._process = function (pattern, index, inGlobStar) { 382 | assert(this instanceof GlobSync) 383 | 384 | // Get the first [n] parts of pattern that are all strings. 385 | var n = 0 386 | while (typeof pattern[n] === 'string') { 387 | n ++ 388 | } 389 | // now n is the index of the first one that is *not* a string. 390 | 391 | // See if there's anything else 392 | var prefix 393 | switch (n) { 394 | // if not, then this is rather simple 395 | case pattern.length: 396 | this._processSimple(pattern.join('/'), index) 397 | return 398 | 399 | case 0: 400 | // pattern *starts* with some non-trivial item. 401 | // going to readdir(cwd), but not include the prefix in matches. 402 | prefix = null 403 | break 404 | 405 | default: 406 | // pattern has some string bits in the front. 407 | // whatever it starts with, whether that's 'absolute' like /foo/bar, 408 | // or 'relative' like '../baz' 409 | prefix = pattern.slice(0, n).join('/') 410 | break 411 | } 412 | 413 | var remain = pattern.slice(n) 414 | 415 | // get the list of entries. 416 | var read 417 | if (prefix === null) 418 | read = '.' 419 | else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) { 420 | if (!prefix || !isAbsolute(prefix)) 421 | prefix = '/' + prefix 422 | read = prefix 423 | } else 424 | read = prefix 425 | 426 | var abs = this._makeAbs(read) 427 | 428 | //if ignored, skip processing 429 | if (childrenIgnored(this, read)) 430 | return 431 | 432 | var isGlobStar = remain[0] === minimatch.GLOBSTAR 433 | if (isGlobStar) 434 | this._processGlobStar(prefix, read, abs, remain, index, inGlobStar) 435 | else 436 | this._processReaddir(prefix, read, abs, remain, index, inGlobStar) 437 | } 438 | 439 | 440 | GlobSync.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar) { 441 | var entries = this._readdir(abs, inGlobStar) 442 | 443 | // if the abs isn't a dir, then nothing can match! 444 | if (!entries) 445 | return 446 | 447 | // It will only match dot entries if it starts with a dot, or if 448 | // dot is set. Stuff like @(.foo|.bar) isn't allowed. 449 | var pn = remain[0] 450 | var negate = !!this.minimatch.negate 451 | var rawGlob = pn._glob 452 | var dotOk = this.dot || rawGlob.charAt(0) === '.' 453 | 454 | var matchedEntries = [] 455 | for (var i = 0; i < entries.length; i++) { 456 | var e = entries[i] 457 | if (e.charAt(0) !== '.' || dotOk) { 458 | var m 459 | if (negate && !prefix) { 460 | m = !e.match(pn) 461 | } else { 462 | m = e.match(pn) 463 | } 464 | if (m) 465 | matchedEntries.push(e) 466 | } 467 | } 468 | 469 | var len = matchedEntries.length 470 | // If there are no matched entries, then nothing matches. 471 | if (len === 0) 472 | return 473 | 474 | // if this is the last remaining pattern bit, then no need for 475 | // an additional stat *unless* the user has specified mark or 476 | // stat explicitly. We know they exist, since readdir returned 477 | // them. 478 | 479 | if (remain.length === 1 && !this.mark && !this.stat) { 480 | if (!this.matches[index]) 481 | this.matches[index] = Object.create(null) 482 | 483 | for (var i = 0; i < len; i ++) { 484 | var e = matchedEntries[i] 485 | if (prefix) { 486 | if (prefix.slice(-1) !== '/') 487 | e = prefix + '/' + e 488 | else 489 | e = prefix + e 490 | } 491 | 492 | if (e.charAt(0) === '/' && !this.nomount) { 493 | e = path.join(this.root, e) 494 | } 495 | this._emitMatch(index, e) 496 | } 497 | // This was the last one, and no stats were needed 498 | return 499 | } 500 | 501 | // now test all matched entries as stand-ins for that part 502 | // of the pattern. 503 | remain.shift() 504 | for (var i = 0; i < len; i ++) { 505 | var e = matchedEntries[i] 506 | var newPattern 507 | if (prefix) 508 | newPattern = [prefix, e] 509 | else 510 | newPattern = [e] 511 | this._process(newPattern.concat(remain), index, inGlobStar) 512 | } 513 | } 514 | 515 | 516 | GlobSync.prototype._emitMatch = function (index, e) { 517 | if (isIgnored(this, e)) 518 | return 519 | 520 | var abs = this._makeAbs(e) 521 | 522 | if (this.mark) 523 | e = this._mark(e) 524 | 525 | if (this.absolute) { 526 | e = abs 527 | } 528 | 529 | if (this.matches[index][e]) 530 | return 531 | 532 | if (this.nodir) { 533 | var c = this.cache[abs] 534 | if (c === 'DIR' || Array.isArray(c)) 535 | return 536 | } 537 | 538 | this.matches[index][e] = true 539 | 540 | if (this.stat) 541 | this._stat(e) 542 | } 543 | 544 | 545 | GlobSync.prototype._readdirInGlobStar = function (abs) { 546 | // follow all symlinked directories forever 547 | // just proceed as if this is a non-globstar situation 548 | if (this.follow) 549 | return this._readdir(abs, false) 550 | 551 | var entries 552 | var lstat 553 | var stat 554 | try { 555 | lstat = fs.lstatSync(abs) 556 | } catch (er) { 557 | if (er.code === 'ENOENT') { 558 | // lstat failed, doesn't exist 559 | return null 560 | } 561 | } 562 | 563 | var isSym = lstat && lstat.isSymbolicLink() 564 | this.symlinks[abs] = isSym 565 | 566 | // If it's not a symlink or a dir, then it's definitely a regular file. 567 | // don't bother doing a readdir in that case. 568 | if (!isSym && lstat && !lstat.isDirectory()) 569 | this.cache[abs] = 'FILE' 570 | else 571 | entries = this._readdir(abs, false) 572 | 573 | return entries 574 | } 575 | 576 | GlobSync.prototype._readdir = function (abs, inGlobStar) { 577 | var entries 578 | 579 | if (inGlobStar && !ownProp(this.symlinks, abs)) 580 | return this._readdirInGlobStar(abs) 581 | 582 | if (ownProp(this.cache, abs)) { 583 | var c = this.cache[abs] 584 | if (!c || c === 'FILE') 585 | return null 586 | 587 | if (Array.isArray(c)) 588 | return c 589 | } 590 | 591 | try { 592 | return this._readdirEntries(abs, fs.readdirSync(abs)) 593 | } catch (er) { 594 | this._readdirError(abs, er) 595 | return null 596 | } 597 | } 598 | 599 | GlobSync.prototype._readdirEntries = function (abs, entries) { 600 | // if we haven't asked to stat everything, then just 601 | // assume that everything in there exists, so we can avoid 602 | // having to stat it a second time. 603 | if (!this.mark && !this.stat) { 604 | for (var i = 0; i < entries.length; i ++) { 605 | var e = entries[i] 606 | if (abs === '/') 607 | e = abs + e 608 | else 609 | e = abs + '/' + e 610 | this.cache[e] = true 611 | } 612 | } 613 | 614 | this.cache[abs] = entries 615 | 616 | // mark and cache dir-ness 617 | return entries 618 | } 619 | 620 | GlobSync.prototype._readdirError = function (f, er) { 621 | // handle errors, and cache the information 622 | switch (er.code) { 623 | case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205 624 | case 'ENOTDIR': // totally normal. means it *does* exist. 625 | var abs = this._makeAbs(f) 626 | this.cache[abs] = 'FILE' 627 | if (abs === this.cwdAbs) { 628 | var error = new Error(er.code + ' invalid cwd ' + this.cwd) 629 | error.path = this.cwd 630 | error.code = er.code 631 | throw error 632 | } 633 | break 634 | 635 | case 'ENOENT': // not terribly unusual 636 | case 'ELOOP': 637 | case 'ENAMETOOLONG': 638 | case 'UNKNOWN': 639 | this.cache[this._makeAbs(f)] = false 640 | break 641 | 642 | default: // some unusual error. Treat as failure. 643 | this.cache[this._makeAbs(f)] = false 644 | if (this.strict) 645 | throw er 646 | if (!this.silent) 647 | console.error('glob error', er) 648 | break 649 | } 650 | } 651 | 652 | GlobSync.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar) { 653 | 654 | var entries = this._readdir(abs, inGlobStar) 655 | 656 | // no entries means not a dir, so it can never have matches 657 | // foo.txt/** doesn't match foo.txt 658 | if (!entries) 659 | return 660 | 661 | // test without the globstar, and with every child both below 662 | // and replacing the globstar. 663 | var remainWithoutGlobStar = remain.slice(1) 664 | var gspref = prefix ? [ prefix ] : [] 665 | var noGlobStar = gspref.concat(remainWithoutGlobStar) 666 | 667 | // the noGlobStar pattern exits the inGlobStar state 668 | this._process(noGlobStar, index, false) 669 | 670 | var len = entries.length 671 | var isSym = this.symlinks[abs] 672 | 673 | // If it's a symlink, and we're in a globstar, then stop 674 | if (isSym && inGlobStar) 675 | return 676 | 677 | for (var i = 0; i < len; i++) { 678 | var e = entries[i] 679 | if (e.charAt(0) === '.' && !this.dot) 680 | continue 681 | 682 | // these two cases enter the inGlobStar state 683 | var instead = gspref.concat(entries[i], remainWithoutGlobStar) 684 | this._process(instead, index, true) 685 | 686 | var below = gspref.concat(entries[i], remain) 687 | this._process(below, index, true) 688 | } 689 | } 690 | 691 | GlobSync.prototype._processSimple = function (prefix, index) { 692 | // XXX review this. Shouldn't it be doing the mounting etc 693 | // before doing stat? kinda weird? 694 | var exists = this._stat(prefix) 695 | 696 | if (!this.matches[index]) 697 | this.matches[index] = Object.create(null) 698 | 699 | // If it doesn't exist, then just mark the lack of results 700 | if (!exists) 701 | return 702 | 703 | if (prefix && isAbsolute(prefix) && !this.nomount) { 704 | var trail = /[\/\\]$/.test(prefix) 705 | if (prefix.charAt(0) === '/') { 706 | prefix = path.join(this.root, prefix) 707 | } else { 708 | prefix = path.resolve(this.root, prefix) 709 | if (trail) 710 | prefix += '/' 711 | } 712 | } 713 | 714 | if (process.platform === 'win32') 715 | prefix = prefix.replace(/\\/g, '/') 716 | 717 | // Mark this as a match 718 | this._emitMatch(index, prefix) 719 | } 720 | 721 | // Returns either 'DIR', 'FILE', or false 722 | GlobSync.prototype._stat = function (f) { 723 | var abs = this._makeAbs(f) 724 | var needDir = f.slice(-1) === '/' 725 | 726 | if (f.length > this.maxLength) 727 | return false 728 | 729 | if (!this.stat && ownProp(this.cache, abs)) { 730 | var c = this.cache[abs] 731 | 732 | if (Array.isArray(c)) 733 | c = 'DIR' 734 | 735 | // It exists, but maybe not how we need it 736 | if (!needDir || c === 'DIR') 737 | return c 738 | 739 | if (needDir && c === 'FILE') 740 | return false 741 | 742 | // otherwise we have to stat, because maybe c=true 743 | // if we know it exists, but not what it is. 744 | } 745 | 746 | var exists 747 | var stat = this.statCache[abs] 748 | if (!stat) { 749 | var lstat 750 | try { 751 | lstat = fs.lstatSync(abs) 752 | } catch (er) { 753 | if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) { 754 | this.statCache[abs] = false 755 | return false 756 | } 757 | } 758 | 759 | if (lstat && lstat.isSymbolicLink()) { 760 | try { 761 | stat = fs.statSync(abs) 762 | } catch (er) { 763 | stat = lstat 764 | } 765 | } else { 766 | stat = lstat 767 | } 768 | } 769 | 770 | this.statCache[abs] = stat 771 | 772 | var c = true 773 | if (stat) 774 | c = stat.isDirectory() ? 'DIR' : 'FILE' 775 | 776 | this.cache[abs] = this.cache[abs] || c 777 | 778 | if (needDir && c === 'FILE') 779 | return false 780 | 781 | return c 782 | } 783 | 784 | GlobSync.prototype._mark = function (p) { 785 | return common.mark(this, p) 786 | } 787 | 788 | GlobSync.prototype._makeAbs = function (f) { 789 | return common.makeAbs(this, f) 790 | } 791 | 792 | 793 | /***/ }), 794 | 795 | /***/ 190: 796 | /***/ (function(__unusedmodule, __webpack_exports__, __webpack_require__) { 797 | 798 | "use strict"; 799 | __webpack_require__.r(__webpack_exports__); 800 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "render", function() { return render; }); 801 | function render(item) { 802 | if (item === null || item === undefined) return null; 803 | 804 | if (typeof item === "object") { 805 | if (Array.isArray(item)) { 806 | return item.map(i => render(i)); 807 | } else { 808 | for (let [key, value] of Object.entries(item)) { 809 | item[key] = render(value); 810 | } 811 | return item; 812 | } 813 | } else { 814 | if (typeof item === "string" && item.match(/^\%d/)) { 815 | return process.env[item.substr(3)] 816 | ? parseInt(process.env[item.substr(3)], 10) 817 | : undefined; 818 | } 819 | 820 | if (typeof item === "string" && item.match(/^\%f/)) { 821 | return process.env[item.substr(3)] 822 | ? parseFloat(process.env[item.substr(3)]) 823 | : undefined; 824 | } 825 | 826 | if (typeof item === "string" && item.match(/^\%s/)) { 827 | return process.env[item.substr(3)]; 828 | } 829 | 830 | if (typeof item === "string" && item.match(/^\%b/)) { 831 | return process.env[item.substr(3)] === "true"; 832 | } 833 | 834 | return item; 835 | } 836 | } 837 | 838 | 839 | /***/ }), 840 | 841 | /***/ 215: 842 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 843 | 844 | "use strict"; 845 | 846 | Object.defineProperty(exports, "__esModule", { value: true }); 847 | const os = __webpack_require__(87); 848 | /** 849 | * Commands 850 | * 851 | * Command Format: 852 | * ##[name key=value;key=value]message 853 | * 854 | * Examples: 855 | * ##[warning]This is the user warning message 856 | * ##[set-secret name=mypassword]definitelyNotAPassword! 857 | */ 858 | function issueCommand(command, properties, message) { 859 | const cmd = new Command(command, properties, message); 860 | process.stdout.write(cmd.toString() + os.EOL); 861 | } 862 | exports.issueCommand = issueCommand; 863 | function issue(name, message = '') { 864 | issueCommand(name, {}, message); 865 | } 866 | exports.issue = issue; 867 | const CMD_STRING = '::'; 868 | class Command { 869 | constructor(command, properties, message) { 870 | if (!command) { 871 | command = 'missing.command'; 872 | } 873 | this.command = command; 874 | this.properties = properties; 875 | this.message = message; 876 | } 877 | toString() { 878 | let cmdStr = CMD_STRING + this.command; 879 | if (this.properties && Object.keys(this.properties).length > 0) { 880 | cmdStr += ' '; 881 | let first = true; 882 | for (const key in this.properties) { 883 | if (this.properties.hasOwnProperty(key)) { 884 | const val = this.properties[key]; 885 | if (val) { 886 | if (first) { 887 | first = false; 888 | } 889 | else { 890 | cmdStr += ','; 891 | } 892 | // safely append the val - avoid blowing up when attempting to 893 | // call .replace() if message is not a string for some reason 894 | cmdStr += `${key}=${escape(`${val || ''}`)}`; 895 | } 896 | } 897 | } 898 | } 899 | cmdStr += CMD_STRING; 900 | // safely append the message - avoid blowing up when attempting to 901 | // call .replace() if message is not a string for some reason 902 | const message = `${this.message || ''}`; 903 | cmdStr += escapeData(message); 904 | return cmdStr; 905 | } 906 | } 907 | function escapeData(s) { 908 | return s.replace(/\r/g, '%0D').replace(/\n/g, '%0A'); 909 | } 910 | function escape(s) { 911 | return s 912 | .replace(/\r/g, '%0D') 913 | .replace(/\n/g, '%0A') 914 | .replace(/]/g, '%5D') 915 | .replace(/;/g, '%3B'); 916 | } 917 | //# sourceMappingURL=command.js.map 918 | 919 | /***/ }), 920 | 921 | /***/ 276: 922 | /***/ (function(module, __unusedexports, __webpack_require__) { 923 | 924 | try { 925 | var util = __webpack_require__(669); 926 | /* istanbul ignore next */ 927 | if (typeof util.inherits !== 'function') throw ''; 928 | module.exports = util.inherits; 929 | } catch (e) { 930 | /* istanbul ignore next */ 931 | module.exports = __webpack_require__(851); 932 | } 933 | 934 | 935 | /***/ }), 936 | 937 | /***/ 277: 938 | /***/ (function(module) { 939 | 940 | module.exports = require("path"); 941 | 942 | /***/ }), 943 | 944 | /***/ 348: 945 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 946 | 947 | // Copyright Joyent, Inc. and other Node contributors. 948 | // 949 | // Permission is hereby granted, free of charge, to any person obtaining a 950 | // copy of this software and associated documentation files (the 951 | // "Software"), to deal in the Software without restriction, including 952 | // without limitation the rights to use, copy, modify, merge, publish, 953 | // distribute, sublicense, and/or sell copies of the Software, and to permit 954 | // persons to whom the Software is furnished to do so, subject to the 955 | // following conditions: 956 | // 957 | // The above copyright notice and this permission notice shall be included 958 | // in all copies or substantial portions of the Software. 959 | // 960 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 961 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 962 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN 963 | // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 964 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 965 | // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 966 | // USE OR OTHER DEALINGS IN THE SOFTWARE. 967 | 968 | var pathModule = __webpack_require__(277); 969 | var isWindows = process.platform === 'win32'; 970 | var fs = __webpack_require__(747); 971 | 972 | // JavaScript implementation of realpath, ported from node pre-v6 973 | 974 | var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG); 975 | 976 | function rethrow() { 977 | // Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and 978 | // is fairly slow to generate. 979 | var callback; 980 | if (DEBUG) { 981 | var backtrace = new Error; 982 | callback = debugCallback; 983 | } else 984 | callback = missingCallback; 985 | 986 | return callback; 987 | 988 | function debugCallback(err) { 989 | if (err) { 990 | backtrace.message = err.message; 991 | err = backtrace; 992 | missingCallback(err); 993 | } 994 | } 995 | 996 | function missingCallback(err) { 997 | if (err) { 998 | if (process.throwDeprecation) 999 | throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs 1000 | else if (!process.noDeprecation) { 1001 | var msg = 'fs: missing callback ' + (err.stack || err.message); 1002 | if (process.traceDeprecation) 1003 | console.trace(msg); 1004 | else 1005 | console.error(msg); 1006 | } 1007 | } 1008 | } 1009 | } 1010 | 1011 | function maybeCallback(cb) { 1012 | return typeof cb === 'function' ? cb : rethrow(); 1013 | } 1014 | 1015 | var normalize = pathModule.normalize; 1016 | 1017 | // Regexp that finds the next partion of a (partial) path 1018 | // result is [base_with_slash, base], e.g. ['somedir/', 'somedir'] 1019 | if (isWindows) { 1020 | var nextPartRe = /(.*?)(?:[\/\\]+|$)/g; 1021 | } else { 1022 | var nextPartRe = /(.*?)(?:[\/]+|$)/g; 1023 | } 1024 | 1025 | // Regex to find the device root, including trailing slash. E.g. 'c:\\'. 1026 | if (isWindows) { 1027 | var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/; 1028 | } else { 1029 | var splitRootRe = /^[\/]*/; 1030 | } 1031 | 1032 | exports.realpathSync = function realpathSync(p, cache) { 1033 | // make p is absolute 1034 | p = pathModule.resolve(p); 1035 | 1036 | if (cache && Object.prototype.hasOwnProperty.call(cache, p)) { 1037 | return cache[p]; 1038 | } 1039 | 1040 | var original = p, 1041 | seenLinks = {}, 1042 | knownHard = {}; 1043 | 1044 | // current character position in p 1045 | var pos; 1046 | // the partial path so far, including a trailing slash if any 1047 | var current; 1048 | // the partial path without a trailing slash (except when pointing at a root) 1049 | var base; 1050 | // the partial path scanned in the previous round, with slash 1051 | var previous; 1052 | 1053 | start(); 1054 | 1055 | function start() { 1056 | // Skip over roots 1057 | var m = splitRootRe.exec(p); 1058 | pos = m[0].length; 1059 | current = m[0]; 1060 | base = m[0]; 1061 | previous = ''; 1062 | 1063 | // On windows, check that the root exists. On unix there is no need. 1064 | if (isWindows && !knownHard[base]) { 1065 | fs.lstatSync(base); 1066 | knownHard[base] = true; 1067 | } 1068 | } 1069 | 1070 | // walk down the path, swapping out linked pathparts for their real 1071 | // values 1072 | // NB: p.length changes. 1073 | while (pos < p.length) { 1074 | // find the next part 1075 | nextPartRe.lastIndex = pos; 1076 | var result = nextPartRe.exec(p); 1077 | previous = current; 1078 | current += result[0]; 1079 | base = previous + result[1]; 1080 | pos = nextPartRe.lastIndex; 1081 | 1082 | // continue if not a symlink 1083 | if (knownHard[base] || (cache && cache[base] === base)) { 1084 | continue; 1085 | } 1086 | 1087 | var resolvedLink; 1088 | if (cache && Object.prototype.hasOwnProperty.call(cache, base)) { 1089 | // some known symbolic link. no need to stat again. 1090 | resolvedLink = cache[base]; 1091 | } else { 1092 | var stat = fs.lstatSync(base); 1093 | if (!stat.isSymbolicLink()) { 1094 | knownHard[base] = true; 1095 | if (cache) cache[base] = base; 1096 | continue; 1097 | } 1098 | 1099 | // read the link if it wasn't read before 1100 | // dev/ino always return 0 on windows, so skip the check. 1101 | var linkTarget = null; 1102 | if (!isWindows) { 1103 | var id = stat.dev.toString(32) + ':' + stat.ino.toString(32); 1104 | if (seenLinks.hasOwnProperty(id)) { 1105 | linkTarget = seenLinks[id]; 1106 | } 1107 | } 1108 | if (linkTarget === null) { 1109 | fs.statSync(base); 1110 | linkTarget = fs.readlinkSync(base); 1111 | } 1112 | resolvedLink = pathModule.resolve(previous, linkTarget); 1113 | // track this, if given a cache. 1114 | if (cache) cache[base] = resolvedLink; 1115 | if (!isWindows) seenLinks[id] = linkTarget; 1116 | } 1117 | 1118 | // resolve the link, then start over 1119 | p = pathModule.resolve(resolvedLink, p.slice(pos)); 1120 | start(); 1121 | } 1122 | 1123 | if (cache) cache[original] = p; 1124 | 1125 | return p; 1126 | }; 1127 | 1128 | 1129 | exports.realpath = function realpath(p, cache, cb) { 1130 | if (typeof cb !== 'function') { 1131 | cb = maybeCallback(cache); 1132 | cache = null; 1133 | } 1134 | 1135 | // make p is absolute 1136 | p = pathModule.resolve(p); 1137 | 1138 | if (cache && Object.prototype.hasOwnProperty.call(cache, p)) { 1139 | return process.nextTick(cb.bind(null, null, cache[p])); 1140 | } 1141 | 1142 | var original = p, 1143 | seenLinks = {}, 1144 | knownHard = {}; 1145 | 1146 | // current character position in p 1147 | var pos; 1148 | // the partial path so far, including a trailing slash if any 1149 | var current; 1150 | // the partial path without a trailing slash (except when pointing at a root) 1151 | var base; 1152 | // the partial path scanned in the previous round, with slash 1153 | var previous; 1154 | 1155 | start(); 1156 | 1157 | function start() { 1158 | // Skip over roots 1159 | var m = splitRootRe.exec(p); 1160 | pos = m[0].length; 1161 | current = m[0]; 1162 | base = m[0]; 1163 | previous = ''; 1164 | 1165 | // On windows, check that the root exists. On unix there is no need. 1166 | if (isWindows && !knownHard[base]) { 1167 | fs.lstat(base, function(err) { 1168 | if (err) return cb(err); 1169 | knownHard[base] = true; 1170 | LOOP(); 1171 | }); 1172 | } else { 1173 | process.nextTick(LOOP); 1174 | } 1175 | } 1176 | 1177 | // walk down the path, swapping out linked pathparts for their real 1178 | // values 1179 | function LOOP() { 1180 | // stop if scanned past end of path 1181 | if (pos >= p.length) { 1182 | if (cache) cache[original] = p; 1183 | return cb(null, p); 1184 | } 1185 | 1186 | // find the next part 1187 | nextPartRe.lastIndex = pos; 1188 | var result = nextPartRe.exec(p); 1189 | previous = current; 1190 | current += result[0]; 1191 | base = previous + result[1]; 1192 | pos = nextPartRe.lastIndex; 1193 | 1194 | // continue if not a symlink 1195 | if (knownHard[base] || (cache && cache[base] === base)) { 1196 | return process.nextTick(LOOP); 1197 | } 1198 | 1199 | if (cache && Object.prototype.hasOwnProperty.call(cache, base)) { 1200 | // known symbolic link. no need to stat again. 1201 | return gotResolvedLink(cache[base]); 1202 | } 1203 | 1204 | return fs.lstat(base, gotStat); 1205 | } 1206 | 1207 | function gotStat(err, stat) { 1208 | if (err) return cb(err); 1209 | 1210 | // if not a symlink, skip to the next path part 1211 | if (!stat.isSymbolicLink()) { 1212 | knownHard[base] = true; 1213 | if (cache) cache[base] = base; 1214 | return process.nextTick(LOOP); 1215 | } 1216 | 1217 | // stat & read the link if not read before 1218 | // call gotTarget as soon as the link target is known 1219 | // dev/ino always return 0 on windows, so skip the check. 1220 | if (!isWindows) { 1221 | var id = stat.dev.toString(32) + ':' + stat.ino.toString(32); 1222 | if (seenLinks.hasOwnProperty(id)) { 1223 | return gotTarget(null, seenLinks[id], base); 1224 | } 1225 | } 1226 | fs.stat(base, function(err) { 1227 | if (err) return cb(err); 1228 | 1229 | fs.readlink(base, function(err, target) { 1230 | if (!isWindows) seenLinks[id] = target; 1231 | gotTarget(err, target); 1232 | }); 1233 | }); 1234 | } 1235 | 1236 | function gotTarget(err, target, base) { 1237 | if (err) return cb(err); 1238 | 1239 | var resolvedLink = pathModule.resolve(previous, target); 1240 | if (cache) cache[base] = resolvedLink; 1241 | gotResolvedLink(resolvedLink); 1242 | } 1243 | 1244 | function gotResolvedLink(resolvedLink) { 1245 | // resolve the link, then start over 1246 | p = pathModule.resolve(resolvedLink, p.slice(pos)); 1247 | start(); 1248 | } 1249 | }; 1250 | 1251 | 1252 | /***/ }), 1253 | 1254 | /***/ 357: 1255 | /***/ (function(module) { 1256 | 1257 | module.exports = require("assert"); 1258 | 1259 | /***/ }), 1260 | 1261 | /***/ 416: 1262 | /***/ (function(module, __unusedexports, __webpack_require__) { 1263 | 1264 | var concatMap = __webpack_require__(812); 1265 | var balanced = __webpack_require__(502); 1266 | 1267 | module.exports = expandTop; 1268 | 1269 | var escSlash = '\0SLASH'+Math.random()+'\0'; 1270 | var escOpen = '\0OPEN'+Math.random()+'\0'; 1271 | var escClose = '\0CLOSE'+Math.random()+'\0'; 1272 | var escComma = '\0COMMA'+Math.random()+'\0'; 1273 | var escPeriod = '\0PERIOD'+Math.random()+'\0'; 1274 | 1275 | function numeric(str) { 1276 | return parseInt(str, 10) == str 1277 | ? parseInt(str, 10) 1278 | : str.charCodeAt(0); 1279 | } 1280 | 1281 | function escapeBraces(str) { 1282 | return str.split('\\\\').join(escSlash) 1283 | .split('\\{').join(escOpen) 1284 | .split('\\}').join(escClose) 1285 | .split('\\,').join(escComma) 1286 | .split('\\.').join(escPeriod); 1287 | } 1288 | 1289 | function unescapeBraces(str) { 1290 | return str.split(escSlash).join('\\') 1291 | .split(escOpen).join('{') 1292 | .split(escClose).join('}') 1293 | .split(escComma).join(',') 1294 | .split(escPeriod).join('.'); 1295 | } 1296 | 1297 | 1298 | // Basically just str.split(","), but handling cases 1299 | // where we have nested braced sections, which should be 1300 | // treated as individual members, like {a,{b,c},d} 1301 | function parseCommaParts(str) { 1302 | if (!str) 1303 | return ['']; 1304 | 1305 | var parts = []; 1306 | var m = balanced('{', '}', str); 1307 | 1308 | if (!m) 1309 | return str.split(','); 1310 | 1311 | var pre = m.pre; 1312 | var body = m.body; 1313 | var post = m.post; 1314 | var p = pre.split(','); 1315 | 1316 | p[p.length-1] += '{' + body + '}'; 1317 | var postParts = parseCommaParts(post); 1318 | if (post.length) { 1319 | p[p.length-1] += postParts.shift(); 1320 | p.push.apply(p, postParts); 1321 | } 1322 | 1323 | parts.push.apply(parts, p); 1324 | 1325 | return parts; 1326 | } 1327 | 1328 | function expandTop(str) { 1329 | if (!str) 1330 | return []; 1331 | 1332 | // I don't know why Bash 4.3 does this, but it does. 1333 | // Anything starting with {} will have the first two bytes preserved 1334 | // but *only* at the top level, so {},a}b will not expand to anything, 1335 | // but a{},b}c will be expanded to [a}c,abc]. 1336 | // One could argue that this is a bug in Bash, but since the goal of 1337 | // this module is to match Bash's rules, we escape a leading {} 1338 | if (str.substr(0, 2) === '{}') { 1339 | str = '\\{\\}' + str.substr(2); 1340 | } 1341 | 1342 | return expand(escapeBraces(str), true).map(unescapeBraces); 1343 | } 1344 | 1345 | function identity(e) { 1346 | return e; 1347 | } 1348 | 1349 | function embrace(str) { 1350 | return '{' + str + '}'; 1351 | } 1352 | function isPadded(el) { 1353 | return /^-?0\d/.test(el); 1354 | } 1355 | 1356 | function lte(i, y) { 1357 | return i <= y; 1358 | } 1359 | function gte(i, y) { 1360 | return i >= y; 1361 | } 1362 | 1363 | function expand(str, isTop) { 1364 | var expansions = []; 1365 | 1366 | var m = balanced('{', '}', str); 1367 | if (!m || /\$$/.test(m.pre)) return [str]; 1368 | 1369 | var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body); 1370 | var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body); 1371 | var isSequence = isNumericSequence || isAlphaSequence; 1372 | var isOptions = m.body.indexOf(',') >= 0; 1373 | if (!isSequence && !isOptions) { 1374 | // {a},b} 1375 | if (m.post.match(/,.*\}/)) { 1376 | str = m.pre + '{' + m.body + escClose + m.post; 1377 | return expand(str); 1378 | } 1379 | return [str]; 1380 | } 1381 | 1382 | var n; 1383 | if (isSequence) { 1384 | n = m.body.split(/\.\./); 1385 | } else { 1386 | n = parseCommaParts(m.body); 1387 | if (n.length === 1) { 1388 | // x{{a,b}}y ==> x{a}y x{b}y 1389 | n = expand(n[0], false).map(embrace); 1390 | if (n.length === 1) { 1391 | var post = m.post.length 1392 | ? expand(m.post, false) 1393 | : ['']; 1394 | return post.map(function(p) { 1395 | return m.pre + n[0] + p; 1396 | }); 1397 | } 1398 | } 1399 | } 1400 | 1401 | // at this point, n is the parts, and we know it's not a comma set 1402 | // with a single entry. 1403 | 1404 | // no need to expand pre, since it is guaranteed to be free of brace-sets 1405 | var pre = m.pre; 1406 | var post = m.post.length 1407 | ? expand(m.post, false) 1408 | : ['']; 1409 | 1410 | var N; 1411 | 1412 | if (isSequence) { 1413 | var x = numeric(n[0]); 1414 | var y = numeric(n[1]); 1415 | var width = Math.max(n[0].length, n[1].length) 1416 | var incr = n.length == 3 1417 | ? Math.abs(numeric(n[2])) 1418 | : 1; 1419 | var test = lte; 1420 | var reverse = y < x; 1421 | if (reverse) { 1422 | incr *= -1; 1423 | test = gte; 1424 | } 1425 | var pad = n.some(isPadded); 1426 | 1427 | N = []; 1428 | 1429 | for (var i = x; test(i, y); i += incr) { 1430 | var c; 1431 | if (isAlphaSequence) { 1432 | c = String.fromCharCode(i); 1433 | if (c === '\\') 1434 | c = ''; 1435 | } else { 1436 | c = String(i); 1437 | if (pad) { 1438 | var need = width - c.length; 1439 | if (need > 0) { 1440 | var z = new Array(need + 1).join('0'); 1441 | if (i < 0) 1442 | c = '-' + z + c.slice(1); 1443 | else 1444 | c = z + c; 1445 | } 1446 | } 1447 | } 1448 | N.push(c); 1449 | } 1450 | } else { 1451 | N = concatMap(n, function(el) { return expand(el, false) }); 1452 | } 1453 | 1454 | for (var j = 0; j < N.length; j++) { 1455 | for (var k = 0; k < post.length; k++) { 1456 | var expansion = pre + N[j] + post[k]; 1457 | if (!isTop || isSequence || expansion) 1458 | expansions.push(expansion); 1459 | } 1460 | } 1461 | 1462 | return expansions; 1463 | } 1464 | 1465 | 1466 | 1467 | /***/ }), 1468 | 1469 | /***/ 417: 1470 | /***/ (function(module) { 1471 | 1472 | module.exports = require("crypto"); 1473 | 1474 | /***/ }), 1475 | 1476 | /***/ 421: 1477 | /***/ (function(module, __unusedexports, __webpack_require__) { 1478 | 1479 | var wrappy = __webpack_require__(719) 1480 | var reqs = Object.create(null) 1481 | var once = __webpack_require__(870) 1482 | 1483 | module.exports = wrappy(inflight) 1484 | 1485 | function inflight (key, cb) { 1486 | if (reqs[key]) { 1487 | reqs[key].push(cb) 1488 | return null 1489 | } else { 1490 | reqs[key] = [cb] 1491 | return makeres(key) 1492 | } 1493 | } 1494 | 1495 | function makeres (key) { 1496 | return once(function RES () { 1497 | var cbs = reqs[key] 1498 | var len = cbs.length 1499 | var args = slice(arguments) 1500 | 1501 | // XXX It's somewhat ambiguous whether a new callback added in this 1502 | // pass should be queued for later execution if something in the 1503 | // list of callbacks throws, or if it should just be discarded. 1504 | // However, it's such an edge case that it hardly matters, and either 1505 | // choice is likely as surprising as the other. 1506 | // As it happens, we do go ahead and schedule it for later execution. 1507 | try { 1508 | for (var i = 0; i < len; i++) { 1509 | cbs[i].apply(null, args) 1510 | } 1511 | } finally { 1512 | if (cbs.length > len) { 1513 | // added more in the interim. 1514 | // de-zalgo, just in case, but don't call again. 1515 | cbs.splice(0, len) 1516 | process.nextTick(function () { 1517 | RES.apply(null, args) 1518 | }) 1519 | } else { 1520 | delete reqs[key] 1521 | } 1522 | } 1523 | }) 1524 | } 1525 | 1526 | function slice (args) { 1527 | var length = args.length 1528 | var array = [] 1529 | 1530 | for (var i = 0; i < length; i++) array[i] = args[i] 1531 | return array 1532 | } 1533 | 1534 | 1535 | /***/ }), 1536 | 1537 | /***/ 502: 1538 | /***/ (function(module) { 1539 | 1540 | "use strict"; 1541 | 1542 | module.exports = balanced; 1543 | function balanced(a, b, str) { 1544 | if (a instanceof RegExp) a = maybeMatch(a, str); 1545 | if (b instanceof RegExp) b = maybeMatch(b, str); 1546 | 1547 | var r = range(a, b, str); 1548 | 1549 | return r && { 1550 | start: r[0], 1551 | end: r[1], 1552 | pre: str.slice(0, r[0]), 1553 | body: str.slice(r[0] + a.length, r[1]), 1554 | post: str.slice(r[1] + b.length) 1555 | }; 1556 | } 1557 | 1558 | function maybeMatch(reg, str) { 1559 | var m = str.match(reg); 1560 | return m ? m[0] : null; 1561 | } 1562 | 1563 | balanced.range = range; 1564 | function range(a, b, str) { 1565 | var begs, beg, left, right, result; 1566 | var ai = str.indexOf(a); 1567 | var bi = str.indexOf(b, ai + 1); 1568 | var i = ai; 1569 | 1570 | if (ai >= 0 && bi > 0) { 1571 | begs = []; 1572 | left = str.length; 1573 | 1574 | while (i >= 0 && !result) { 1575 | if (i == ai) { 1576 | begs.push(i); 1577 | ai = str.indexOf(a, i + 1); 1578 | } else if (begs.length == 1) { 1579 | result = [ begs.pop(), bi ]; 1580 | } else { 1581 | beg = begs.pop(); 1582 | if (beg < left) { 1583 | left = beg; 1584 | right = bi; 1585 | } 1586 | 1587 | bi = str.indexOf(b, i + 1); 1588 | } 1589 | 1590 | i = ai < bi && ai >= 0 ? ai : bi; 1591 | } 1592 | 1593 | if (begs.length) { 1594 | result = [ left, right ]; 1595 | } 1596 | } 1597 | 1598 | return result; 1599 | } 1600 | 1601 | 1602 | /***/ }), 1603 | 1604 | /***/ 544: 1605 | /***/ (function(module, __unusedexports, __webpack_require__) { 1606 | 1607 | module.exports = realpath 1608 | realpath.realpath = realpath 1609 | realpath.sync = realpathSync 1610 | realpath.realpathSync = realpathSync 1611 | realpath.monkeypatch = monkeypatch 1612 | realpath.unmonkeypatch = unmonkeypatch 1613 | 1614 | var fs = __webpack_require__(747) 1615 | var origRealpath = fs.realpath 1616 | var origRealpathSync = fs.realpathSync 1617 | 1618 | var version = process.version 1619 | var ok = /^v[0-5]\./.test(version) 1620 | var old = __webpack_require__(348) 1621 | 1622 | function newError (er) { 1623 | return er && er.syscall === 'realpath' && ( 1624 | er.code === 'ELOOP' || 1625 | er.code === 'ENOMEM' || 1626 | er.code === 'ENAMETOOLONG' 1627 | ) 1628 | } 1629 | 1630 | function realpath (p, cache, cb) { 1631 | if (ok) { 1632 | return origRealpath(p, cache, cb) 1633 | } 1634 | 1635 | if (typeof cache === 'function') { 1636 | cb = cache 1637 | cache = null 1638 | } 1639 | origRealpath(p, cache, function (er, result) { 1640 | if (newError(er)) { 1641 | old.realpath(p, cache, cb) 1642 | } else { 1643 | cb(er, result) 1644 | } 1645 | }) 1646 | } 1647 | 1648 | function realpathSync (p, cache) { 1649 | if (ok) { 1650 | return origRealpathSync(p, cache) 1651 | } 1652 | 1653 | try { 1654 | return origRealpathSync(p, cache) 1655 | } catch (er) { 1656 | if (newError(er)) { 1657 | return old.realpathSync(p, cache) 1658 | } else { 1659 | throw er 1660 | } 1661 | } 1662 | } 1663 | 1664 | function monkeypatch () { 1665 | fs.realpath = realpath 1666 | fs.realpathSync = realpathSync 1667 | } 1668 | 1669 | function unmonkeypatch () { 1670 | fs.realpath = origRealpath 1671 | fs.realpathSync = origRealpathSync 1672 | } 1673 | 1674 | 1675 | /***/ }), 1676 | 1677 | /***/ 614: 1678 | /***/ (function(module) { 1679 | 1680 | module.exports = require("events"); 1681 | 1682 | /***/ }), 1683 | 1684 | /***/ 622: 1685 | /***/ (function(__unusedmodule, __unusedexports, __webpack_require__) { 1686 | 1687 | const core = __webpack_require__(827); 1688 | const path = __webpack_require__(277); 1689 | const fs = __webpack_require__(747); 1690 | const tmp = __webpack_require__(938); 1691 | const { render } = __webpack_require__(190); 1692 | 1693 | async function run() { 1694 | try { 1695 | const jsonFilePath = core.getInput("json", { 1696 | required: true 1697 | }); 1698 | 1699 | // Parse the task definition 1700 | const jsonAbsolutePath = path.isAbsolute(jsonFilePath) 1701 | ? jsonFilePath 1702 | : path.join(process.env.GITHUB_WORKSPACE, jsonFilePath); 1703 | 1704 | if (!fs.existsSync(jsonAbsolutePath)) { 1705 | throw new Error(`Json file does not exist: ${jsonFilePath}`); 1706 | } 1707 | 1708 | const jsonObj = require(jsonAbsolutePath); 1709 | 1710 | const result = render(jsonObj); 1711 | 1712 | console.log(JSON.stringify(result)); 1713 | 1714 | // Write out a new task definition file 1715 | var tempFile = tmp.fileSync({ 1716 | dir: process.env.RUNNER_TEMP, 1717 | prefix: "json-rendered-", 1718 | postfix: ".json", 1719 | keep: true, 1720 | discardDescriptor: true 1721 | }); 1722 | 1723 | const newJsonObj = JSON.stringify(result, null, 2); 1724 | fs.writeFileSync(tempFile.name, newJsonObj); 1725 | core.setOutput("result", tempFile.name); 1726 | } catch (error) { 1727 | core.setFailed(error.message); 1728 | } 1729 | } 1730 | 1731 | run(); 1732 | 1733 | 1734 | /***/ }), 1735 | 1736 | /***/ 669: 1737 | /***/ (function(module) { 1738 | 1739 | module.exports = require("util"); 1740 | 1741 | /***/ }), 1742 | 1743 | /***/ 689: 1744 | /***/ (function(module, __unusedexports, __webpack_require__) { 1745 | 1746 | module.exports = minimatch 1747 | minimatch.Minimatch = Minimatch 1748 | 1749 | var path = { sep: '/' } 1750 | try { 1751 | path = __webpack_require__(277) 1752 | } catch (er) {} 1753 | 1754 | var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {} 1755 | var expand = __webpack_require__(416) 1756 | 1757 | var plTypes = { 1758 | '!': { open: '(?:(?!(?:', close: '))[^/]*?)'}, 1759 | '?': { open: '(?:', close: ')?' }, 1760 | '+': { open: '(?:', close: ')+' }, 1761 | '*': { open: '(?:', close: ')*' }, 1762 | '@': { open: '(?:', close: ')' } 1763 | } 1764 | 1765 | // any single thing other than / 1766 | // don't need to escape / when using new RegExp() 1767 | var qmark = '[^/]' 1768 | 1769 | // * => any number of characters 1770 | var star = qmark + '*?' 1771 | 1772 | // ** when dots are allowed. Anything goes, except .. and . 1773 | // not (^ or / followed by one or two dots followed by $ or /), 1774 | // followed by anything, any number of times. 1775 | var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?' 1776 | 1777 | // not a ^ or / followed by a dot, 1778 | // followed by anything, any number of times. 1779 | var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?' 1780 | 1781 | // characters that need to be escaped in RegExp. 1782 | var reSpecials = charSet('().*{}+?[]^$\\!') 1783 | 1784 | // "abc" -> { a:true, b:true, c:true } 1785 | function charSet (s) { 1786 | return s.split('').reduce(function (set, c) { 1787 | set[c] = true 1788 | return set 1789 | }, {}) 1790 | } 1791 | 1792 | // normalizes slashes. 1793 | var slashSplit = /\/+/ 1794 | 1795 | minimatch.filter = filter 1796 | function filter (pattern, options) { 1797 | options = options || {} 1798 | return function (p, i, list) { 1799 | return minimatch(p, pattern, options) 1800 | } 1801 | } 1802 | 1803 | function ext (a, b) { 1804 | a = a || {} 1805 | b = b || {} 1806 | var t = {} 1807 | Object.keys(b).forEach(function (k) { 1808 | t[k] = b[k] 1809 | }) 1810 | Object.keys(a).forEach(function (k) { 1811 | t[k] = a[k] 1812 | }) 1813 | return t 1814 | } 1815 | 1816 | minimatch.defaults = function (def) { 1817 | if (!def || !Object.keys(def).length) return minimatch 1818 | 1819 | var orig = minimatch 1820 | 1821 | var m = function minimatch (p, pattern, options) { 1822 | return orig.minimatch(p, pattern, ext(def, options)) 1823 | } 1824 | 1825 | m.Minimatch = function Minimatch (pattern, options) { 1826 | return new orig.Minimatch(pattern, ext(def, options)) 1827 | } 1828 | 1829 | return m 1830 | } 1831 | 1832 | Minimatch.defaults = function (def) { 1833 | if (!def || !Object.keys(def).length) return Minimatch 1834 | return minimatch.defaults(def).Minimatch 1835 | } 1836 | 1837 | function minimatch (p, pattern, options) { 1838 | if (typeof pattern !== 'string') { 1839 | throw new TypeError('glob pattern string required') 1840 | } 1841 | 1842 | if (!options) options = {} 1843 | 1844 | // shortcut: comments match nothing. 1845 | if (!options.nocomment && pattern.charAt(0) === '#') { 1846 | return false 1847 | } 1848 | 1849 | // "" only matches "" 1850 | if (pattern.trim() === '') return p === '' 1851 | 1852 | return new Minimatch(pattern, options).match(p) 1853 | } 1854 | 1855 | function Minimatch (pattern, options) { 1856 | if (!(this instanceof Minimatch)) { 1857 | return new Minimatch(pattern, options) 1858 | } 1859 | 1860 | if (typeof pattern !== 'string') { 1861 | throw new TypeError('glob pattern string required') 1862 | } 1863 | 1864 | if (!options) options = {} 1865 | pattern = pattern.trim() 1866 | 1867 | // windows support: need to use /, not \ 1868 | if (path.sep !== '/') { 1869 | pattern = pattern.split(path.sep).join('/') 1870 | } 1871 | 1872 | this.options = options 1873 | this.set = [] 1874 | this.pattern = pattern 1875 | this.regexp = null 1876 | this.negate = false 1877 | this.comment = false 1878 | this.empty = false 1879 | 1880 | // make the set of regexps etc. 1881 | this.make() 1882 | } 1883 | 1884 | Minimatch.prototype.debug = function () {} 1885 | 1886 | Minimatch.prototype.make = make 1887 | function make () { 1888 | // don't do it more than once. 1889 | if (this._made) return 1890 | 1891 | var pattern = this.pattern 1892 | var options = this.options 1893 | 1894 | // empty patterns and comments match nothing. 1895 | if (!options.nocomment && pattern.charAt(0) === '#') { 1896 | this.comment = true 1897 | return 1898 | } 1899 | if (!pattern) { 1900 | this.empty = true 1901 | return 1902 | } 1903 | 1904 | // step 1: figure out negation, etc. 1905 | this.parseNegate() 1906 | 1907 | // step 2: expand braces 1908 | var set = this.globSet = this.braceExpand() 1909 | 1910 | if (options.debug) this.debug = console.error 1911 | 1912 | this.debug(this.pattern, set) 1913 | 1914 | // step 3: now we have a set, so turn each one into a series of path-portion 1915 | // matching patterns. 1916 | // These will be regexps, except in the case of "**", which is 1917 | // set to the GLOBSTAR object for globstar behavior, 1918 | // and will not contain any / characters 1919 | set = this.globParts = set.map(function (s) { 1920 | return s.split(slashSplit) 1921 | }) 1922 | 1923 | this.debug(this.pattern, set) 1924 | 1925 | // glob --> regexps 1926 | set = set.map(function (s, si, set) { 1927 | return s.map(this.parse, this) 1928 | }, this) 1929 | 1930 | this.debug(this.pattern, set) 1931 | 1932 | // filter out everything that didn't compile properly. 1933 | set = set.filter(function (s) { 1934 | return s.indexOf(false) === -1 1935 | }) 1936 | 1937 | this.debug(this.pattern, set) 1938 | 1939 | this.set = set 1940 | } 1941 | 1942 | Minimatch.prototype.parseNegate = parseNegate 1943 | function parseNegate () { 1944 | var pattern = this.pattern 1945 | var negate = false 1946 | var options = this.options 1947 | var negateOffset = 0 1948 | 1949 | if (options.nonegate) return 1950 | 1951 | for (var i = 0, l = pattern.length 1952 | ; i < l && pattern.charAt(i) === '!' 1953 | ; i++) { 1954 | negate = !negate 1955 | negateOffset++ 1956 | } 1957 | 1958 | if (negateOffset) this.pattern = pattern.substr(negateOffset) 1959 | this.negate = negate 1960 | } 1961 | 1962 | // Brace expansion: 1963 | // a{b,c}d -> abd acd 1964 | // a{b,}c -> abc ac 1965 | // a{0..3}d -> a0d a1d a2d a3d 1966 | // a{b,c{d,e}f}g -> abg acdfg acefg 1967 | // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg 1968 | // 1969 | // Invalid sets are not expanded. 1970 | // a{2..}b -> a{2..}b 1971 | // a{b}c -> a{b}c 1972 | minimatch.braceExpand = function (pattern, options) { 1973 | return braceExpand(pattern, options) 1974 | } 1975 | 1976 | Minimatch.prototype.braceExpand = braceExpand 1977 | 1978 | function braceExpand (pattern, options) { 1979 | if (!options) { 1980 | if (this instanceof Minimatch) { 1981 | options = this.options 1982 | } else { 1983 | options = {} 1984 | } 1985 | } 1986 | 1987 | pattern = typeof pattern === 'undefined' 1988 | ? this.pattern : pattern 1989 | 1990 | if (typeof pattern === 'undefined') { 1991 | throw new TypeError('undefined pattern') 1992 | } 1993 | 1994 | if (options.nobrace || 1995 | !pattern.match(/\{.*\}/)) { 1996 | // shortcut. no need to expand. 1997 | return [pattern] 1998 | } 1999 | 2000 | return expand(pattern) 2001 | } 2002 | 2003 | // parse a component of the expanded set. 2004 | // At this point, no pattern may contain "/" in it 2005 | // so we're going to return a 2d array, where each entry is the full 2006 | // pattern, split on '/', and then turned into a regular expression. 2007 | // A regexp is made at the end which joins each array with an 2008 | // escaped /, and another full one which joins each regexp with |. 2009 | // 2010 | // Following the lead of Bash 4.1, note that "**" only has special meaning 2011 | // when it is the *only* thing in a path portion. Otherwise, any series 2012 | // of * is equivalent to a single *. Globstar behavior is enabled by 2013 | // default, and can be disabled by setting options.noglobstar. 2014 | Minimatch.prototype.parse = parse 2015 | var SUBPARSE = {} 2016 | function parse (pattern, isSub) { 2017 | if (pattern.length > 1024 * 64) { 2018 | throw new TypeError('pattern is too long') 2019 | } 2020 | 2021 | var options = this.options 2022 | 2023 | // shortcuts 2024 | if (!options.noglobstar && pattern === '**') return GLOBSTAR 2025 | if (pattern === '') return '' 2026 | 2027 | var re = '' 2028 | var hasMagic = !!options.nocase 2029 | var escaping = false 2030 | // ? => one single character 2031 | var patternListStack = [] 2032 | var negativeLists = [] 2033 | var stateChar 2034 | var inClass = false 2035 | var reClassStart = -1 2036 | var classStart = -1 2037 | // . and .. never match anything that doesn't start with ., 2038 | // even when options.dot is set. 2039 | var patternStart = pattern.charAt(0) === '.' ? '' // anything 2040 | // not (start or / followed by . or .. followed by / or end) 2041 | : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' 2042 | : '(?!\\.)' 2043 | var self = this 2044 | 2045 | function clearStateChar () { 2046 | if (stateChar) { 2047 | // we had some state-tracking character 2048 | // that wasn't consumed by this pass. 2049 | switch (stateChar) { 2050 | case '*': 2051 | re += star 2052 | hasMagic = true 2053 | break 2054 | case '?': 2055 | re += qmark 2056 | hasMagic = true 2057 | break 2058 | default: 2059 | re += '\\' + stateChar 2060 | break 2061 | } 2062 | self.debug('clearStateChar %j %j', stateChar, re) 2063 | stateChar = false 2064 | } 2065 | } 2066 | 2067 | for (var i = 0, len = pattern.length, c 2068 | ; (i < len) && (c = pattern.charAt(i)) 2069 | ; i++) { 2070 | this.debug('%s\t%s %s %j', pattern, i, re, c) 2071 | 2072 | // skip over any that are escaped. 2073 | if (escaping && reSpecials[c]) { 2074 | re += '\\' + c 2075 | escaping = false 2076 | continue 2077 | } 2078 | 2079 | switch (c) { 2080 | case '/': 2081 | // completely not allowed, even escaped. 2082 | // Should already be path-split by now. 2083 | return false 2084 | 2085 | case '\\': 2086 | clearStateChar() 2087 | escaping = true 2088 | continue 2089 | 2090 | // the various stateChar values 2091 | // for the "extglob" stuff. 2092 | case '?': 2093 | case '*': 2094 | case '+': 2095 | case '@': 2096 | case '!': 2097 | this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c) 2098 | 2099 | // all of those are literals inside a class, except that 2100 | // the glob [!a] means [^a] in regexp 2101 | if (inClass) { 2102 | this.debug(' in class') 2103 | if (c === '!' && i === classStart + 1) c = '^' 2104 | re += c 2105 | continue 2106 | } 2107 | 2108 | // if we already have a stateChar, then it means 2109 | // that there was something like ** or +? in there. 2110 | // Handle the stateChar, then proceed with this one. 2111 | self.debug('call clearStateChar %j', stateChar) 2112 | clearStateChar() 2113 | stateChar = c 2114 | // if extglob is disabled, then +(asdf|foo) isn't a thing. 2115 | // just clear the statechar *now*, rather than even diving into 2116 | // the patternList stuff. 2117 | if (options.noext) clearStateChar() 2118 | continue 2119 | 2120 | case '(': 2121 | if (inClass) { 2122 | re += '(' 2123 | continue 2124 | } 2125 | 2126 | if (!stateChar) { 2127 | re += '\\(' 2128 | continue 2129 | } 2130 | 2131 | patternListStack.push({ 2132 | type: stateChar, 2133 | start: i - 1, 2134 | reStart: re.length, 2135 | open: plTypes[stateChar].open, 2136 | close: plTypes[stateChar].close 2137 | }) 2138 | // negation is (?:(?!js)[^/]*) 2139 | re += stateChar === '!' ? '(?:(?!(?:' : '(?:' 2140 | this.debug('plType %j %j', stateChar, re) 2141 | stateChar = false 2142 | continue 2143 | 2144 | case ')': 2145 | if (inClass || !patternListStack.length) { 2146 | re += '\\)' 2147 | continue 2148 | } 2149 | 2150 | clearStateChar() 2151 | hasMagic = true 2152 | var pl = patternListStack.pop() 2153 | // negation is (?:(?!js)[^/]*) 2154 | // The others are (?:) 2155 | re += pl.close 2156 | if (pl.type === '!') { 2157 | negativeLists.push(pl) 2158 | } 2159 | pl.reEnd = re.length 2160 | continue 2161 | 2162 | case '|': 2163 | if (inClass || !patternListStack.length || escaping) { 2164 | re += '\\|' 2165 | escaping = false 2166 | continue 2167 | } 2168 | 2169 | clearStateChar() 2170 | re += '|' 2171 | continue 2172 | 2173 | // these are mostly the same in regexp and glob 2174 | case '[': 2175 | // swallow any state-tracking char before the [ 2176 | clearStateChar() 2177 | 2178 | if (inClass) { 2179 | re += '\\' + c 2180 | continue 2181 | } 2182 | 2183 | inClass = true 2184 | classStart = i 2185 | reClassStart = re.length 2186 | re += c 2187 | continue 2188 | 2189 | case ']': 2190 | // a right bracket shall lose its special 2191 | // meaning and represent itself in 2192 | // a bracket expression if it occurs 2193 | // first in the list. -- POSIX.2 2.8.3.2 2194 | if (i === classStart + 1 || !inClass) { 2195 | re += '\\' + c 2196 | escaping = false 2197 | continue 2198 | } 2199 | 2200 | // handle the case where we left a class open. 2201 | // "[z-a]" is valid, equivalent to "\[z-a\]" 2202 | if (inClass) { 2203 | // split where the last [ was, make sure we don't have 2204 | // an invalid re. if so, re-walk the contents of the 2205 | // would-be class to re-translate any characters that 2206 | // were passed through as-is 2207 | // TODO: It would probably be faster to determine this 2208 | // without a try/catch and a new RegExp, but it's tricky 2209 | // to do safely. For now, this is safe and works. 2210 | var cs = pattern.substring(classStart + 1, i) 2211 | try { 2212 | RegExp('[' + cs + ']') 2213 | } catch (er) { 2214 | // not a valid class! 2215 | var sp = this.parse(cs, SUBPARSE) 2216 | re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]' 2217 | hasMagic = hasMagic || sp[1] 2218 | inClass = false 2219 | continue 2220 | } 2221 | } 2222 | 2223 | // finish up the class. 2224 | hasMagic = true 2225 | inClass = false 2226 | re += c 2227 | continue 2228 | 2229 | default: 2230 | // swallow any state char that wasn't consumed 2231 | clearStateChar() 2232 | 2233 | if (escaping) { 2234 | // no need 2235 | escaping = false 2236 | } else if (reSpecials[c] 2237 | && !(c === '^' && inClass)) { 2238 | re += '\\' 2239 | } 2240 | 2241 | re += c 2242 | 2243 | } // switch 2244 | } // for 2245 | 2246 | // handle the case where we left a class open. 2247 | // "[abc" is valid, equivalent to "\[abc" 2248 | if (inClass) { 2249 | // split where the last [ was, and escape it 2250 | // this is a huge pita. We now have to re-walk 2251 | // the contents of the would-be class to re-translate 2252 | // any characters that were passed through as-is 2253 | cs = pattern.substr(classStart + 1) 2254 | sp = this.parse(cs, SUBPARSE) 2255 | re = re.substr(0, reClassStart) + '\\[' + sp[0] 2256 | hasMagic = hasMagic || sp[1] 2257 | } 2258 | 2259 | // handle the case where we had a +( thing at the *end* 2260 | // of the pattern. 2261 | // each pattern list stack adds 3 chars, and we need to go through 2262 | // and escape any | chars that were passed through as-is for the regexp. 2263 | // Go through and escape them, taking care not to double-escape any 2264 | // | chars that were already escaped. 2265 | for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) { 2266 | var tail = re.slice(pl.reStart + pl.open.length) 2267 | this.debug('setting tail', re, pl) 2268 | // maybe some even number of \, then maybe 1 \, followed by a | 2269 | tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) { 2270 | if (!$2) { 2271 | // the | isn't already escaped, so escape it. 2272 | $2 = '\\' 2273 | } 2274 | 2275 | // need to escape all those slashes *again*, without escaping the 2276 | // one that we need for escaping the | character. As it works out, 2277 | // escaping an even number of slashes can be done by simply repeating 2278 | // it exactly after itself. That's why this trick works. 2279 | // 2280 | // I am sorry that you have to see this. 2281 | return $1 + $1 + $2 + '|' 2282 | }) 2283 | 2284 | this.debug('tail=%j\n %s', tail, tail, pl, re) 2285 | var t = pl.type === '*' ? star 2286 | : pl.type === '?' ? qmark 2287 | : '\\' + pl.type 2288 | 2289 | hasMagic = true 2290 | re = re.slice(0, pl.reStart) + t + '\\(' + tail 2291 | } 2292 | 2293 | // handle trailing things that only matter at the very end. 2294 | clearStateChar() 2295 | if (escaping) { 2296 | // trailing \\ 2297 | re += '\\\\' 2298 | } 2299 | 2300 | // only need to apply the nodot start if the re starts with 2301 | // something that could conceivably capture a dot 2302 | var addPatternStart = false 2303 | switch (re.charAt(0)) { 2304 | case '.': 2305 | case '[': 2306 | case '(': addPatternStart = true 2307 | } 2308 | 2309 | // Hack to work around lack of negative lookbehind in JS 2310 | // A pattern like: *.!(x).!(y|z) needs to ensure that a name 2311 | // like 'a.xyz.yz' doesn't match. So, the first negative 2312 | // lookahead, has to look ALL the way ahead, to the end of 2313 | // the pattern. 2314 | for (var n = negativeLists.length - 1; n > -1; n--) { 2315 | var nl = negativeLists[n] 2316 | 2317 | var nlBefore = re.slice(0, nl.reStart) 2318 | var nlFirst = re.slice(nl.reStart, nl.reEnd - 8) 2319 | var nlLast = re.slice(nl.reEnd - 8, nl.reEnd) 2320 | var nlAfter = re.slice(nl.reEnd) 2321 | 2322 | nlLast += nlAfter 2323 | 2324 | // Handle nested stuff like *(*.js|!(*.json)), where open parens 2325 | // mean that we should *not* include the ) in the bit that is considered 2326 | // "after" the negated section. 2327 | var openParensBefore = nlBefore.split('(').length - 1 2328 | var cleanAfter = nlAfter 2329 | for (i = 0; i < openParensBefore; i++) { 2330 | cleanAfter = cleanAfter.replace(/\)[+*?]?/, '') 2331 | } 2332 | nlAfter = cleanAfter 2333 | 2334 | var dollar = '' 2335 | if (nlAfter === '' && isSub !== SUBPARSE) { 2336 | dollar = '$' 2337 | } 2338 | var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast 2339 | re = newRe 2340 | } 2341 | 2342 | // if the re is not "" at this point, then we need to make sure 2343 | // it doesn't match against an empty path part. 2344 | // Otherwise a/* will match a/, which it should not. 2345 | if (re !== '' && hasMagic) { 2346 | re = '(?=.)' + re 2347 | } 2348 | 2349 | if (addPatternStart) { 2350 | re = patternStart + re 2351 | } 2352 | 2353 | // parsing just a piece of a larger pattern. 2354 | if (isSub === SUBPARSE) { 2355 | return [re, hasMagic] 2356 | } 2357 | 2358 | // skip the regexp for non-magical patterns 2359 | // unescape anything in it, though, so that it'll be 2360 | // an exact match against a file etc. 2361 | if (!hasMagic) { 2362 | return globUnescape(pattern) 2363 | } 2364 | 2365 | var flags = options.nocase ? 'i' : '' 2366 | try { 2367 | var regExp = new RegExp('^' + re + '$', flags) 2368 | } catch (er) { 2369 | // If it was an invalid regular expression, then it can't match 2370 | // anything. This trick looks for a character after the end of 2371 | // the string, which is of course impossible, except in multi-line 2372 | // mode, but it's not a /m regex. 2373 | return new RegExp('$.') 2374 | } 2375 | 2376 | regExp._glob = pattern 2377 | regExp._src = re 2378 | 2379 | return regExp 2380 | } 2381 | 2382 | minimatch.makeRe = function (pattern, options) { 2383 | return new Minimatch(pattern, options || {}).makeRe() 2384 | } 2385 | 2386 | Minimatch.prototype.makeRe = makeRe 2387 | function makeRe () { 2388 | if (this.regexp || this.regexp === false) return this.regexp 2389 | 2390 | // at this point, this.set is a 2d array of partial 2391 | // pattern strings, or "**". 2392 | // 2393 | // It's better to use .match(). This function shouldn't 2394 | // be used, really, but it's pretty convenient sometimes, 2395 | // when you just want to work with a regex. 2396 | var set = this.set 2397 | 2398 | if (!set.length) { 2399 | this.regexp = false 2400 | return this.regexp 2401 | } 2402 | var options = this.options 2403 | 2404 | var twoStar = options.noglobstar ? star 2405 | : options.dot ? twoStarDot 2406 | : twoStarNoDot 2407 | var flags = options.nocase ? 'i' : '' 2408 | 2409 | var re = set.map(function (pattern) { 2410 | return pattern.map(function (p) { 2411 | return (p === GLOBSTAR) ? twoStar 2412 | : (typeof p === 'string') ? regExpEscape(p) 2413 | : p._src 2414 | }).join('\\\/') 2415 | }).join('|') 2416 | 2417 | // must match entire pattern 2418 | // ending in a * or ** will make it less strict. 2419 | re = '^(?:' + re + ')$' 2420 | 2421 | // can match anything, as long as it's not this. 2422 | if (this.negate) re = '^(?!' + re + ').*$' 2423 | 2424 | try { 2425 | this.regexp = new RegExp(re, flags) 2426 | } catch (ex) { 2427 | this.regexp = false 2428 | } 2429 | return this.regexp 2430 | } 2431 | 2432 | minimatch.match = function (list, pattern, options) { 2433 | options = options || {} 2434 | var mm = new Minimatch(pattern, options) 2435 | list = list.filter(function (f) { 2436 | return mm.match(f) 2437 | }) 2438 | if (mm.options.nonull && !list.length) { 2439 | list.push(pattern) 2440 | } 2441 | return list 2442 | } 2443 | 2444 | Minimatch.prototype.match = match 2445 | function match (f, partial) { 2446 | this.debug('match', f, this.pattern) 2447 | // short-circuit in the case of busted things. 2448 | // comments, etc. 2449 | if (this.comment) return false 2450 | if (this.empty) return f === '' 2451 | 2452 | if (f === '/' && partial) return true 2453 | 2454 | var options = this.options 2455 | 2456 | // windows: need to use /, not \ 2457 | if (path.sep !== '/') { 2458 | f = f.split(path.sep).join('/') 2459 | } 2460 | 2461 | // treat the test path as a set of pathparts. 2462 | f = f.split(slashSplit) 2463 | this.debug(this.pattern, 'split', f) 2464 | 2465 | // just ONE of the pattern sets in this.set needs to match 2466 | // in order for it to be valid. If negating, then just one 2467 | // match means that we have failed. 2468 | // Either way, return on the first hit. 2469 | 2470 | var set = this.set 2471 | this.debug(this.pattern, 'set', set) 2472 | 2473 | // Find the basename of the path by looking for the last non-empty segment 2474 | var filename 2475 | var i 2476 | for (i = f.length - 1; i >= 0; i--) { 2477 | filename = f[i] 2478 | if (filename) break 2479 | } 2480 | 2481 | for (i = 0; i < set.length; i++) { 2482 | var pattern = set[i] 2483 | var file = f 2484 | if (options.matchBase && pattern.length === 1) { 2485 | file = [filename] 2486 | } 2487 | var hit = this.matchOne(file, pattern, partial) 2488 | if (hit) { 2489 | if (options.flipNegate) return true 2490 | return !this.negate 2491 | } 2492 | } 2493 | 2494 | // didn't get any hits. this is success if it's a negative 2495 | // pattern, failure otherwise. 2496 | if (options.flipNegate) return false 2497 | return this.negate 2498 | } 2499 | 2500 | // set partial to true to test if, for example, 2501 | // "/a/b" matches the start of "/*/b/*/d" 2502 | // Partial means, if you run out of file before you run 2503 | // out of pattern, then that's fine, as long as all 2504 | // the parts match. 2505 | Minimatch.prototype.matchOne = function (file, pattern, partial) { 2506 | var options = this.options 2507 | 2508 | this.debug('matchOne', 2509 | { 'this': this, file: file, pattern: pattern }) 2510 | 2511 | this.debug('matchOne', file.length, pattern.length) 2512 | 2513 | for (var fi = 0, 2514 | pi = 0, 2515 | fl = file.length, 2516 | pl = pattern.length 2517 | ; (fi < fl) && (pi < pl) 2518 | ; fi++, pi++) { 2519 | this.debug('matchOne loop') 2520 | var p = pattern[pi] 2521 | var f = file[fi] 2522 | 2523 | this.debug(pattern, p, f) 2524 | 2525 | // should be impossible. 2526 | // some invalid regexp stuff in the set. 2527 | if (p === false) return false 2528 | 2529 | if (p === GLOBSTAR) { 2530 | this.debug('GLOBSTAR', [pattern, p, f]) 2531 | 2532 | // "**" 2533 | // a/**/b/**/c would match the following: 2534 | // a/b/x/y/z/c 2535 | // a/x/y/z/b/c 2536 | // a/b/x/b/x/c 2537 | // a/b/c 2538 | // To do this, take the rest of the pattern after 2539 | // the **, and see if it would match the file remainder. 2540 | // If so, return success. 2541 | // If not, the ** "swallows" a segment, and try again. 2542 | // This is recursively awful. 2543 | // 2544 | // a/**/b/**/c matching a/b/x/y/z/c 2545 | // - a matches a 2546 | // - doublestar 2547 | // - matchOne(b/x/y/z/c, b/**/c) 2548 | // - b matches b 2549 | // - doublestar 2550 | // - matchOne(x/y/z/c, c) -> no 2551 | // - matchOne(y/z/c, c) -> no 2552 | // - matchOne(z/c, c) -> no 2553 | // - matchOne(c, c) yes, hit 2554 | var fr = fi 2555 | var pr = pi + 1 2556 | if (pr === pl) { 2557 | this.debug('** at the end') 2558 | // a ** at the end will just swallow the rest. 2559 | // We have found a match. 2560 | // however, it will not swallow /.x, unless 2561 | // options.dot is set. 2562 | // . and .. are *never* matched by **, for explosively 2563 | // exponential reasons. 2564 | for (; fi < fl; fi++) { 2565 | if (file[fi] === '.' || file[fi] === '..' || 2566 | (!options.dot && file[fi].charAt(0) === '.')) return false 2567 | } 2568 | return true 2569 | } 2570 | 2571 | // ok, let's see if we can swallow whatever we can. 2572 | while (fr < fl) { 2573 | var swallowee = file[fr] 2574 | 2575 | this.debug('\nglobstar while', file, fr, pattern, pr, swallowee) 2576 | 2577 | // XXX remove this slice. Just pass the start index. 2578 | if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) { 2579 | this.debug('globstar found match!', fr, fl, swallowee) 2580 | // found a match. 2581 | return true 2582 | } else { 2583 | // can't swallow "." or ".." ever. 2584 | // can only swallow ".foo" when explicitly asked. 2585 | if (swallowee === '.' || swallowee === '..' || 2586 | (!options.dot && swallowee.charAt(0) === '.')) { 2587 | this.debug('dot detected!', file, fr, pattern, pr) 2588 | break 2589 | } 2590 | 2591 | // ** swallows a segment, and continue. 2592 | this.debug('globstar swallow a segment, and continue') 2593 | fr++ 2594 | } 2595 | } 2596 | 2597 | // no match was found. 2598 | // However, in partial mode, we can't say this is necessarily over. 2599 | // If there's more *pattern* left, then 2600 | if (partial) { 2601 | // ran out of file 2602 | this.debug('\n>>> no match, partial?', file, fr, pattern, pr) 2603 | if (fr === fl) return true 2604 | } 2605 | return false 2606 | } 2607 | 2608 | // something other than ** 2609 | // non-magic patterns just have to match exactly 2610 | // patterns with magic have been turned into regexps. 2611 | var hit 2612 | if (typeof p === 'string') { 2613 | if (options.nocase) { 2614 | hit = f.toLowerCase() === p.toLowerCase() 2615 | } else { 2616 | hit = f === p 2617 | } 2618 | this.debug('string match', p, f, hit) 2619 | } else { 2620 | hit = f.match(p) 2621 | this.debug('pattern match', p, f, hit) 2622 | } 2623 | 2624 | if (!hit) return false 2625 | } 2626 | 2627 | // Note: ending in / means that we'll get a final "" 2628 | // at the end of the pattern. This can only match a 2629 | // corresponding "" at the end of the file. 2630 | // If the file ends in /, then it can only match a 2631 | // a pattern that ends in /, unless the pattern just 2632 | // doesn't have any more for it. But, a/b/ should *not* 2633 | // match "a/b/*", even though "" matches against the 2634 | // [^/]*? pattern, except in partial mode, where it might 2635 | // simply not be reached yet. 2636 | // However, a/b/ should still satisfy a/* 2637 | 2638 | // now either we fell off the end of the pattern, or we're done. 2639 | if (fi === fl && pi === pl) { 2640 | // ran out of pattern and filename at the same time. 2641 | // an exact hit! 2642 | return true 2643 | } else if (fi === fl) { 2644 | // ran out of file, but still had pattern left. 2645 | // this is ok if we're doing the match as part of 2646 | // a glob fs traversal. 2647 | return partial 2648 | } else if (pi === pl) { 2649 | // ran out of pattern, still have file left. 2650 | // this is only acceptable if we're on the very last 2651 | // empty segment of a file with a trailing slash. 2652 | // a/* should match a/b/ 2653 | var emptyFileEnd = (fi === fl - 1) && (file[fi] === '') 2654 | return emptyFileEnd 2655 | } 2656 | 2657 | // should be unreachable. 2658 | throw new Error('wtf?') 2659 | } 2660 | 2661 | // replace stuff like \* with * 2662 | function globUnescape (s) { 2663 | return s.replace(/\\(.)/g, '$1') 2664 | } 2665 | 2666 | function regExpEscape (s) { 2667 | return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&') 2668 | } 2669 | 2670 | 2671 | /***/ }), 2672 | 2673 | /***/ 696: 2674 | /***/ (function(module, __unusedexports, __webpack_require__) { 2675 | 2676 | // Approach: 2677 | // 2678 | // 1. Get the minimatch set 2679 | // 2. For each pattern in the set, PROCESS(pattern, false) 2680 | // 3. Store matches per-set, then uniq them 2681 | // 2682 | // PROCESS(pattern, inGlobStar) 2683 | // Get the first [n] items from pattern that are all strings 2684 | // Join these together. This is PREFIX. 2685 | // If there is no more remaining, then stat(PREFIX) and 2686 | // add to matches if it succeeds. END. 2687 | // 2688 | // If inGlobStar and PREFIX is symlink and points to dir 2689 | // set ENTRIES = [] 2690 | // else readdir(PREFIX) as ENTRIES 2691 | // If fail, END 2692 | // 2693 | // with ENTRIES 2694 | // If pattern[n] is GLOBSTAR 2695 | // // handle the case where the globstar match is empty 2696 | // // by pruning it out, and testing the resulting pattern 2697 | // PROCESS(pattern[0..n] + pattern[n+1 .. $], false) 2698 | // // handle other cases. 2699 | // for ENTRY in ENTRIES (not dotfiles) 2700 | // // attach globstar + tail onto the entry 2701 | // // Mark that this entry is a globstar match 2702 | // PROCESS(pattern[0..n] + ENTRY + pattern[n .. $], true) 2703 | // 2704 | // else // not globstar 2705 | // for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot) 2706 | // Test ENTRY against pattern[n] 2707 | // If fails, continue 2708 | // If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $]) 2709 | // 2710 | // Caveat: 2711 | // Cache all stats and readdirs results to minimize syscall. Since all 2712 | // we ever care about is existence and directory-ness, we can just keep 2713 | // `true` for files, and [children,...] for directories, or `false` for 2714 | // things that don't exist. 2715 | 2716 | module.exports = glob 2717 | 2718 | var fs = __webpack_require__(747) 2719 | var rp = __webpack_require__(544) 2720 | var minimatch = __webpack_require__(689) 2721 | var Minimatch = minimatch.Minimatch 2722 | var inherits = __webpack_require__(276) 2723 | var EE = __webpack_require__(614).EventEmitter 2724 | var path = __webpack_require__(277) 2725 | var assert = __webpack_require__(357) 2726 | var isAbsolute = __webpack_require__(829) 2727 | var globSync = __webpack_require__(133) 2728 | var common = __webpack_require__(18) 2729 | var alphasort = common.alphasort 2730 | var alphasorti = common.alphasorti 2731 | var setopts = common.setopts 2732 | var ownProp = common.ownProp 2733 | var inflight = __webpack_require__(421) 2734 | var util = __webpack_require__(669) 2735 | var childrenIgnored = common.childrenIgnored 2736 | var isIgnored = common.isIgnored 2737 | 2738 | var once = __webpack_require__(870) 2739 | 2740 | function glob (pattern, options, cb) { 2741 | if (typeof options === 'function') cb = options, options = {} 2742 | if (!options) options = {} 2743 | 2744 | if (options.sync) { 2745 | if (cb) 2746 | throw new TypeError('callback provided to sync glob') 2747 | return globSync(pattern, options) 2748 | } 2749 | 2750 | return new Glob(pattern, options, cb) 2751 | } 2752 | 2753 | glob.sync = globSync 2754 | var GlobSync = glob.GlobSync = globSync.GlobSync 2755 | 2756 | // old api surface 2757 | glob.glob = glob 2758 | 2759 | function extend (origin, add) { 2760 | if (add === null || typeof add !== 'object') { 2761 | return origin 2762 | } 2763 | 2764 | var keys = Object.keys(add) 2765 | var i = keys.length 2766 | while (i--) { 2767 | origin[keys[i]] = add[keys[i]] 2768 | } 2769 | return origin 2770 | } 2771 | 2772 | glob.hasMagic = function (pattern, options_) { 2773 | var options = extend({}, options_) 2774 | options.noprocess = true 2775 | 2776 | var g = new Glob(pattern, options) 2777 | var set = g.minimatch.set 2778 | 2779 | if (!pattern) 2780 | return false 2781 | 2782 | if (set.length > 1) 2783 | return true 2784 | 2785 | for (var j = 0; j < set[0].length; j++) { 2786 | if (typeof set[0][j] !== 'string') 2787 | return true 2788 | } 2789 | 2790 | return false 2791 | } 2792 | 2793 | glob.Glob = Glob 2794 | inherits(Glob, EE) 2795 | function Glob (pattern, options, cb) { 2796 | if (typeof options === 'function') { 2797 | cb = options 2798 | options = null 2799 | } 2800 | 2801 | if (options && options.sync) { 2802 | if (cb) 2803 | throw new TypeError('callback provided to sync glob') 2804 | return new GlobSync(pattern, options) 2805 | } 2806 | 2807 | if (!(this instanceof Glob)) 2808 | return new Glob(pattern, options, cb) 2809 | 2810 | setopts(this, pattern, options) 2811 | this._didRealPath = false 2812 | 2813 | // process each pattern in the minimatch set 2814 | var n = this.minimatch.set.length 2815 | 2816 | // The matches are stored as {: true,...} so that 2817 | // duplicates are automagically pruned. 2818 | // Later, we do an Object.keys() on these. 2819 | // Keep them as a list so we can fill in when nonull is set. 2820 | this.matches = new Array(n) 2821 | 2822 | if (typeof cb === 'function') { 2823 | cb = once(cb) 2824 | this.on('error', cb) 2825 | this.on('end', function (matches) { 2826 | cb(null, matches) 2827 | }) 2828 | } 2829 | 2830 | var self = this 2831 | this._processing = 0 2832 | 2833 | this._emitQueue = [] 2834 | this._processQueue = [] 2835 | this.paused = false 2836 | 2837 | if (this.noprocess) 2838 | return this 2839 | 2840 | if (n === 0) 2841 | return done() 2842 | 2843 | var sync = true 2844 | for (var i = 0; i < n; i ++) { 2845 | this._process(this.minimatch.set[i], i, false, done) 2846 | } 2847 | sync = false 2848 | 2849 | function done () { 2850 | --self._processing 2851 | if (self._processing <= 0) { 2852 | if (sync) { 2853 | process.nextTick(function () { 2854 | self._finish() 2855 | }) 2856 | } else { 2857 | self._finish() 2858 | } 2859 | } 2860 | } 2861 | } 2862 | 2863 | Glob.prototype._finish = function () { 2864 | assert(this instanceof Glob) 2865 | if (this.aborted) 2866 | return 2867 | 2868 | if (this.realpath && !this._didRealpath) 2869 | return this._realpath() 2870 | 2871 | common.finish(this) 2872 | this.emit('end', this.found) 2873 | } 2874 | 2875 | Glob.prototype._realpath = function () { 2876 | if (this._didRealpath) 2877 | return 2878 | 2879 | this._didRealpath = true 2880 | 2881 | var n = this.matches.length 2882 | if (n === 0) 2883 | return this._finish() 2884 | 2885 | var self = this 2886 | for (var i = 0; i < this.matches.length; i++) 2887 | this._realpathSet(i, next) 2888 | 2889 | function next () { 2890 | if (--n === 0) 2891 | self._finish() 2892 | } 2893 | } 2894 | 2895 | Glob.prototype._realpathSet = function (index, cb) { 2896 | var matchset = this.matches[index] 2897 | if (!matchset) 2898 | return cb() 2899 | 2900 | var found = Object.keys(matchset) 2901 | var self = this 2902 | var n = found.length 2903 | 2904 | if (n === 0) 2905 | return cb() 2906 | 2907 | var set = this.matches[index] = Object.create(null) 2908 | found.forEach(function (p, i) { 2909 | // If there's a problem with the stat, then it means that 2910 | // one or more of the links in the realpath couldn't be 2911 | // resolved. just return the abs value in that case. 2912 | p = self._makeAbs(p) 2913 | rp.realpath(p, self.realpathCache, function (er, real) { 2914 | if (!er) 2915 | set[real] = true 2916 | else if (er.syscall === 'stat') 2917 | set[p] = true 2918 | else 2919 | self.emit('error', er) // srsly wtf right here 2920 | 2921 | if (--n === 0) { 2922 | self.matches[index] = set 2923 | cb() 2924 | } 2925 | }) 2926 | }) 2927 | } 2928 | 2929 | Glob.prototype._mark = function (p) { 2930 | return common.mark(this, p) 2931 | } 2932 | 2933 | Glob.prototype._makeAbs = function (f) { 2934 | return common.makeAbs(this, f) 2935 | } 2936 | 2937 | Glob.prototype.abort = function () { 2938 | this.aborted = true 2939 | this.emit('abort') 2940 | } 2941 | 2942 | Glob.prototype.pause = function () { 2943 | if (!this.paused) { 2944 | this.paused = true 2945 | this.emit('pause') 2946 | } 2947 | } 2948 | 2949 | Glob.prototype.resume = function () { 2950 | if (this.paused) { 2951 | this.emit('resume') 2952 | this.paused = false 2953 | if (this._emitQueue.length) { 2954 | var eq = this._emitQueue.slice(0) 2955 | this._emitQueue.length = 0 2956 | for (var i = 0; i < eq.length; i ++) { 2957 | var e = eq[i] 2958 | this._emitMatch(e[0], e[1]) 2959 | } 2960 | } 2961 | if (this._processQueue.length) { 2962 | var pq = this._processQueue.slice(0) 2963 | this._processQueue.length = 0 2964 | for (var i = 0; i < pq.length; i ++) { 2965 | var p = pq[i] 2966 | this._processing-- 2967 | this._process(p[0], p[1], p[2], p[3]) 2968 | } 2969 | } 2970 | } 2971 | } 2972 | 2973 | Glob.prototype._process = function (pattern, index, inGlobStar, cb) { 2974 | assert(this instanceof Glob) 2975 | assert(typeof cb === 'function') 2976 | 2977 | if (this.aborted) 2978 | return 2979 | 2980 | this._processing++ 2981 | if (this.paused) { 2982 | this._processQueue.push([pattern, index, inGlobStar, cb]) 2983 | return 2984 | } 2985 | 2986 | //console.error('PROCESS %d', this._processing, pattern) 2987 | 2988 | // Get the first [n] parts of pattern that are all strings. 2989 | var n = 0 2990 | while (typeof pattern[n] === 'string') { 2991 | n ++ 2992 | } 2993 | // now n is the index of the first one that is *not* a string. 2994 | 2995 | // see if there's anything else 2996 | var prefix 2997 | switch (n) { 2998 | // if not, then this is rather simple 2999 | case pattern.length: 3000 | this._processSimple(pattern.join('/'), index, cb) 3001 | return 3002 | 3003 | case 0: 3004 | // pattern *starts* with some non-trivial item. 3005 | // going to readdir(cwd), but not include the prefix in matches. 3006 | prefix = null 3007 | break 3008 | 3009 | default: 3010 | // pattern has some string bits in the front. 3011 | // whatever it starts with, whether that's 'absolute' like /foo/bar, 3012 | // or 'relative' like '../baz' 3013 | prefix = pattern.slice(0, n).join('/') 3014 | break 3015 | } 3016 | 3017 | var remain = pattern.slice(n) 3018 | 3019 | // get the list of entries. 3020 | var read 3021 | if (prefix === null) 3022 | read = '.' 3023 | else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) { 3024 | if (!prefix || !isAbsolute(prefix)) 3025 | prefix = '/' + prefix 3026 | read = prefix 3027 | } else 3028 | read = prefix 3029 | 3030 | var abs = this._makeAbs(read) 3031 | 3032 | //if ignored, skip _processing 3033 | if (childrenIgnored(this, read)) 3034 | return cb() 3035 | 3036 | var isGlobStar = remain[0] === minimatch.GLOBSTAR 3037 | if (isGlobStar) 3038 | this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb) 3039 | else 3040 | this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb) 3041 | } 3042 | 3043 | Glob.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar, cb) { 3044 | var self = this 3045 | this._readdir(abs, inGlobStar, function (er, entries) { 3046 | return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb) 3047 | }) 3048 | } 3049 | 3050 | Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) { 3051 | 3052 | // if the abs isn't a dir, then nothing can match! 3053 | if (!entries) 3054 | return cb() 3055 | 3056 | // It will only match dot entries if it starts with a dot, or if 3057 | // dot is set. Stuff like @(.foo|.bar) isn't allowed. 3058 | var pn = remain[0] 3059 | var negate = !!this.minimatch.negate 3060 | var rawGlob = pn._glob 3061 | var dotOk = this.dot || rawGlob.charAt(0) === '.' 3062 | 3063 | var matchedEntries = [] 3064 | for (var i = 0; i < entries.length; i++) { 3065 | var e = entries[i] 3066 | if (e.charAt(0) !== '.' || dotOk) { 3067 | var m 3068 | if (negate && !prefix) { 3069 | m = !e.match(pn) 3070 | } else { 3071 | m = e.match(pn) 3072 | } 3073 | if (m) 3074 | matchedEntries.push(e) 3075 | } 3076 | } 3077 | 3078 | //console.error('prd2', prefix, entries, remain[0]._glob, matchedEntries) 3079 | 3080 | var len = matchedEntries.length 3081 | // If there are no matched entries, then nothing matches. 3082 | if (len === 0) 3083 | return cb() 3084 | 3085 | // if this is the last remaining pattern bit, then no need for 3086 | // an additional stat *unless* the user has specified mark or 3087 | // stat explicitly. We know they exist, since readdir returned 3088 | // them. 3089 | 3090 | if (remain.length === 1 && !this.mark && !this.stat) { 3091 | if (!this.matches[index]) 3092 | this.matches[index] = Object.create(null) 3093 | 3094 | for (var i = 0; i < len; i ++) { 3095 | var e = matchedEntries[i] 3096 | if (prefix) { 3097 | if (prefix !== '/') 3098 | e = prefix + '/' + e 3099 | else 3100 | e = prefix + e 3101 | } 3102 | 3103 | if (e.charAt(0) === '/' && !this.nomount) { 3104 | e = path.join(this.root, e) 3105 | } 3106 | this._emitMatch(index, e) 3107 | } 3108 | // This was the last one, and no stats were needed 3109 | return cb() 3110 | } 3111 | 3112 | // now test all matched entries as stand-ins for that part 3113 | // of the pattern. 3114 | remain.shift() 3115 | for (var i = 0; i < len; i ++) { 3116 | var e = matchedEntries[i] 3117 | var newPattern 3118 | if (prefix) { 3119 | if (prefix !== '/') 3120 | e = prefix + '/' + e 3121 | else 3122 | e = prefix + e 3123 | } 3124 | this._process([e].concat(remain), index, inGlobStar, cb) 3125 | } 3126 | cb() 3127 | } 3128 | 3129 | Glob.prototype._emitMatch = function (index, e) { 3130 | if (this.aborted) 3131 | return 3132 | 3133 | if (isIgnored(this, e)) 3134 | return 3135 | 3136 | if (this.paused) { 3137 | this._emitQueue.push([index, e]) 3138 | return 3139 | } 3140 | 3141 | var abs = isAbsolute(e) ? e : this._makeAbs(e) 3142 | 3143 | if (this.mark) 3144 | e = this._mark(e) 3145 | 3146 | if (this.absolute) 3147 | e = abs 3148 | 3149 | if (this.matches[index][e]) 3150 | return 3151 | 3152 | if (this.nodir) { 3153 | var c = this.cache[abs] 3154 | if (c === 'DIR' || Array.isArray(c)) 3155 | return 3156 | } 3157 | 3158 | this.matches[index][e] = true 3159 | 3160 | var st = this.statCache[abs] 3161 | if (st) 3162 | this.emit('stat', e, st) 3163 | 3164 | this.emit('match', e) 3165 | } 3166 | 3167 | Glob.prototype._readdirInGlobStar = function (abs, cb) { 3168 | if (this.aborted) 3169 | return 3170 | 3171 | // follow all symlinked directories forever 3172 | // just proceed as if this is a non-globstar situation 3173 | if (this.follow) 3174 | return this._readdir(abs, false, cb) 3175 | 3176 | var lstatkey = 'lstat\0' + abs 3177 | var self = this 3178 | var lstatcb = inflight(lstatkey, lstatcb_) 3179 | 3180 | if (lstatcb) 3181 | fs.lstat(abs, lstatcb) 3182 | 3183 | function lstatcb_ (er, lstat) { 3184 | if (er && er.code === 'ENOENT') 3185 | return cb() 3186 | 3187 | var isSym = lstat && lstat.isSymbolicLink() 3188 | self.symlinks[abs] = isSym 3189 | 3190 | // If it's not a symlink or a dir, then it's definitely a regular file. 3191 | // don't bother doing a readdir in that case. 3192 | if (!isSym && lstat && !lstat.isDirectory()) { 3193 | self.cache[abs] = 'FILE' 3194 | cb() 3195 | } else 3196 | self._readdir(abs, false, cb) 3197 | } 3198 | } 3199 | 3200 | Glob.prototype._readdir = function (abs, inGlobStar, cb) { 3201 | if (this.aborted) 3202 | return 3203 | 3204 | cb = inflight('readdir\0'+abs+'\0'+inGlobStar, cb) 3205 | if (!cb) 3206 | return 3207 | 3208 | //console.error('RD %j %j', +inGlobStar, abs) 3209 | if (inGlobStar && !ownProp(this.symlinks, abs)) 3210 | return this._readdirInGlobStar(abs, cb) 3211 | 3212 | if (ownProp(this.cache, abs)) { 3213 | var c = this.cache[abs] 3214 | if (!c || c === 'FILE') 3215 | return cb() 3216 | 3217 | if (Array.isArray(c)) 3218 | return cb(null, c) 3219 | } 3220 | 3221 | var self = this 3222 | fs.readdir(abs, readdirCb(this, abs, cb)) 3223 | } 3224 | 3225 | function readdirCb (self, abs, cb) { 3226 | return function (er, entries) { 3227 | if (er) 3228 | self._readdirError(abs, er, cb) 3229 | else 3230 | self._readdirEntries(abs, entries, cb) 3231 | } 3232 | } 3233 | 3234 | Glob.prototype._readdirEntries = function (abs, entries, cb) { 3235 | if (this.aborted) 3236 | return 3237 | 3238 | // if we haven't asked to stat everything, then just 3239 | // assume that everything in there exists, so we can avoid 3240 | // having to stat it a second time. 3241 | if (!this.mark && !this.stat) { 3242 | for (var i = 0; i < entries.length; i ++) { 3243 | var e = entries[i] 3244 | if (abs === '/') 3245 | e = abs + e 3246 | else 3247 | e = abs + '/' + e 3248 | this.cache[e] = true 3249 | } 3250 | } 3251 | 3252 | this.cache[abs] = entries 3253 | return cb(null, entries) 3254 | } 3255 | 3256 | Glob.prototype._readdirError = function (f, er, cb) { 3257 | if (this.aborted) 3258 | return 3259 | 3260 | // handle errors, and cache the information 3261 | switch (er.code) { 3262 | case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205 3263 | case 'ENOTDIR': // totally normal. means it *does* exist. 3264 | var abs = this._makeAbs(f) 3265 | this.cache[abs] = 'FILE' 3266 | if (abs === this.cwdAbs) { 3267 | var error = new Error(er.code + ' invalid cwd ' + this.cwd) 3268 | error.path = this.cwd 3269 | error.code = er.code 3270 | this.emit('error', error) 3271 | this.abort() 3272 | } 3273 | break 3274 | 3275 | case 'ENOENT': // not terribly unusual 3276 | case 'ELOOP': 3277 | case 'ENAMETOOLONG': 3278 | case 'UNKNOWN': 3279 | this.cache[this._makeAbs(f)] = false 3280 | break 3281 | 3282 | default: // some unusual error. Treat as failure. 3283 | this.cache[this._makeAbs(f)] = false 3284 | if (this.strict) { 3285 | this.emit('error', er) 3286 | // If the error is handled, then we abort 3287 | // if not, we threw out of here 3288 | this.abort() 3289 | } 3290 | if (!this.silent) 3291 | console.error('glob error', er) 3292 | break 3293 | } 3294 | 3295 | return cb() 3296 | } 3297 | 3298 | Glob.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar, cb) { 3299 | var self = this 3300 | this._readdir(abs, inGlobStar, function (er, entries) { 3301 | self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb) 3302 | }) 3303 | } 3304 | 3305 | 3306 | Glob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) { 3307 | //console.error('pgs2', prefix, remain[0], entries) 3308 | 3309 | // no entries means not a dir, so it can never have matches 3310 | // foo.txt/** doesn't match foo.txt 3311 | if (!entries) 3312 | return cb() 3313 | 3314 | // test without the globstar, and with every child both below 3315 | // and replacing the globstar. 3316 | var remainWithoutGlobStar = remain.slice(1) 3317 | var gspref = prefix ? [ prefix ] : [] 3318 | var noGlobStar = gspref.concat(remainWithoutGlobStar) 3319 | 3320 | // the noGlobStar pattern exits the inGlobStar state 3321 | this._process(noGlobStar, index, false, cb) 3322 | 3323 | var isSym = this.symlinks[abs] 3324 | var len = entries.length 3325 | 3326 | // If it's a symlink, and we're in a globstar, then stop 3327 | if (isSym && inGlobStar) 3328 | return cb() 3329 | 3330 | for (var i = 0; i < len; i++) { 3331 | var e = entries[i] 3332 | if (e.charAt(0) === '.' && !this.dot) 3333 | continue 3334 | 3335 | // these two cases enter the inGlobStar state 3336 | var instead = gspref.concat(entries[i], remainWithoutGlobStar) 3337 | this._process(instead, index, true, cb) 3338 | 3339 | var below = gspref.concat(entries[i], remain) 3340 | this._process(below, index, true, cb) 3341 | } 3342 | 3343 | cb() 3344 | } 3345 | 3346 | Glob.prototype._processSimple = function (prefix, index, cb) { 3347 | // XXX review this. Shouldn't it be doing the mounting etc 3348 | // before doing stat? kinda weird? 3349 | var self = this 3350 | this._stat(prefix, function (er, exists) { 3351 | self._processSimple2(prefix, index, er, exists, cb) 3352 | }) 3353 | } 3354 | Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) { 3355 | 3356 | //console.error('ps2', prefix, exists) 3357 | 3358 | if (!this.matches[index]) 3359 | this.matches[index] = Object.create(null) 3360 | 3361 | // If it doesn't exist, then just mark the lack of results 3362 | if (!exists) 3363 | return cb() 3364 | 3365 | if (prefix && isAbsolute(prefix) && !this.nomount) { 3366 | var trail = /[\/\\]$/.test(prefix) 3367 | if (prefix.charAt(0) === '/') { 3368 | prefix = path.join(this.root, prefix) 3369 | } else { 3370 | prefix = path.resolve(this.root, prefix) 3371 | if (trail) 3372 | prefix += '/' 3373 | } 3374 | } 3375 | 3376 | if (process.platform === 'win32') 3377 | prefix = prefix.replace(/\\/g, '/') 3378 | 3379 | // Mark this as a match 3380 | this._emitMatch(index, prefix) 3381 | cb() 3382 | } 3383 | 3384 | // Returns either 'DIR', 'FILE', or false 3385 | Glob.prototype._stat = function (f, cb) { 3386 | var abs = this._makeAbs(f) 3387 | var needDir = f.slice(-1) === '/' 3388 | 3389 | if (f.length > this.maxLength) 3390 | return cb() 3391 | 3392 | if (!this.stat && ownProp(this.cache, abs)) { 3393 | var c = this.cache[abs] 3394 | 3395 | if (Array.isArray(c)) 3396 | c = 'DIR' 3397 | 3398 | // It exists, but maybe not how we need it 3399 | if (!needDir || c === 'DIR') 3400 | return cb(null, c) 3401 | 3402 | if (needDir && c === 'FILE') 3403 | return cb() 3404 | 3405 | // otherwise we have to stat, because maybe c=true 3406 | // if we know it exists, but not what it is. 3407 | } 3408 | 3409 | var exists 3410 | var stat = this.statCache[abs] 3411 | if (stat !== undefined) { 3412 | if (stat === false) 3413 | return cb(null, stat) 3414 | else { 3415 | var type = stat.isDirectory() ? 'DIR' : 'FILE' 3416 | if (needDir && type === 'FILE') 3417 | return cb() 3418 | else 3419 | return cb(null, type, stat) 3420 | } 3421 | } 3422 | 3423 | var self = this 3424 | var statcb = inflight('stat\0' + abs, lstatcb_) 3425 | if (statcb) 3426 | fs.lstat(abs, statcb) 3427 | 3428 | function lstatcb_ (er, lstat) { 3429 | if (lstat && lstat.isSymbolicLink()) { 3430 | // If it's a symlink, then treat it as the target, unless 3431 | // the target does not exist, then treat it as a file. 3432 | return fs.stat(abs, function (er, stat) { 3433 | if (er) 3434 | self._stat2(f, abs, null, lstat, cb) 3435 | else 3436 | self._stat2(f, abs, er, stat, cb) 3437 | }) 3438 | } else { 3439 | self._stat2(f, abs, er, lstat, cb) 3440 | } 3441 | } 3442 | } 3443 | 3444 | Glob.prototype._stat2 = function (f, abs, er, stat, cb) { 3445 | if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) { 3446 | this.statCache[abs] = false 3447 | return cb() 3448 | } 3449 | 3450 | var needDir = f.slice(-1) === '/' 3451 | this.statCache[abs] = stat 3452 | 3453 | if (abs.slice(-1) === '/' && stat && !stat.isDirectory()) 3454 | return cb(null, false, stat) 3455 | 3456 | var c = true 3457 | if (stat) 3458 | c = stat.isDirectory() ? 'DIR' : 'FILE' 3459 | this.cache[abs] = this.cache[abs] || c 3460 | 3461 | if (needDir && c === 'FILE') 3462 | return cb() 3463 | 3464 | return cb(null, c, stat) 3465 | } 3466 | 3467 | 3468 | /***/ }), 3469 | 3470 | /***/ 700: 3471 | /***/ (function(module, __unusedexports, __webpack_require__) { 3472 | 3473 | module.exports = rimraf 3474 | rimraf.sync = rimrafSync 3475 | 3476 | var assert = __webpack_require__(357) 3477 | var path = __webpack_require__(277) 3478 | var fs = __webpack_require__(747) 3479 | var glob = __webpack_require__(696) 3480 | var _0666 = parseInt('666', 8) 3481 | 3482 | var defaultGlobOpts = { 3483 | nosort: true, 3484 | silent: true 3485 | } 3486 | 3487 | // for EMFILE handling 3488 | var timeout = 0 3489 | 3490 | var isWindows = (process.platform === "win32") 3491 | 3492 | function defaults (options) { 3493 | var methods = [ 3494 | 'unlink', 3495 | 'chmod', 3496 | 'stat', 3497 | 'lstat', 3498 | 'rmdir', 3499 | 'readdir' 3500 | ] 3501 | methods.forEach(function(m) { 3502 | options[m] = options[m] || fs[m] 3503 | m = m + 'Sync' 3504 | options[m] = options[m] || fs[m] 3505 | }) 3506 | 3507 | options.maxBusyTries = options.maxBusyTries || 3 3508 | options.emfileWait = options.emfileWait || 1000 3509 | if (options.glob === false) { 3510 | options.disableGlob = true 3511 | } 3512 | options.disableGlob = options.disableGlob || false 3513 | options.glob = options.glob || defaultGlobOpts 3514 | } 3515 | 3516 | function rimraf (p, options, cb) { 3517 | if (typeof options === 'function') { 3518 | cb = options 3519 | options = {} 3520 | } 3521 | 3522 | assert(p, 'rimraf: missing path') 3523 | assert.equal(typeof p, 'string', 'rimraf: path should be a string') 3524 | assert.equal(typeof cb, 'function', 'rimraf: callback function required') 3525 | assert(options, 'rimraf: invalid options argument provided') 3526 | assert.equal(typeof options, 'object', 'rimraf: options should be object') 3527 | 3528 | defaults(options) 3529 | 3530 | var busyTries = 0 3531 | var errState = null 3532 | var n = 0 3533 | 3534 | if (options.disableGlob || !glob.hasMagic(p)) 3535 | return afterGlob(null, [p]) 3536 | 3537 | options.lstat(p, function (er, stat) { 3538 | if (!er) 3539 | return afterGlob(null, [p]) 3540 | 3541 | glob(p, options.glob, afterGlob) 3542 | }) 3543 | 3544 | function next (er) { 3545 | errState = errState || er 3546 | if (--n === 0) 3547 | cb(errState) 3548 | } 3549 | 3550 | function afterGlob (er, results) { 3551 | if (er) 3552 | return cb(er) 3553 | 3554 | n = results.length 3555 | if (n === 0) 3556 | return cb() 3557 | 3558 | results.forEach(function (p) { 3559 | rimraf_(p, options, function CB (er) { 3560 | if (er) { 3561 | if ((er.code === "EBUSY" || er.code === "ENOTEMPTY" || er.code === "EPERM") && 3562 | busyTries < options.maxBusyTries) { 3563 | busyTries ++ 3564 | var time = busyTries * 100 3565 | // try again, with the same exact callback as this one. 3566 | return setTimeout(function () { 3567 | rimraf_(p, options, CB) 3568 | }, time) 3569 | } 3570 | 3571 | // this one won't happen if graceful-fs is used. 3572 | if (er.code === "EMFILE" && timeout < options.emfileWait) { 3573 | return setTimeout(function () { 3574 | rimraf_(p, options, CB) 3575 | }, timeout ++) 3576 | } 3577 | 3578 | // already gone 3579 | if (er.code === "ENOENT") er = null 3580 | } 3581 | 3582 | timeout = 0 3583 | next(er) 3584 | }) 3585 | }) 3586 | } 3587 | } 3588 | 3589 | // Two possible strategies. 3590 | // 1. Assume it's a file. unlink it, then do the dir stuff on EPERM or EISDIR 3591 | // 2. Assume it's a directory. readdir, then do the file stuff on ENOTDIR 3592 | // 3593 | // Both result in an extra syscall when you guess wrong. However, there 3594 | // are likely far more normal files in the world than directories. This 3595 | // is based on the assumption that a the average number of files per 3596 | // directory is >= 1. 3597 | // 3598 | // If anyone ever complains about this, then I guess the strategy could 3599 | // be made configurable somehow. But until then, YAGNI. 3600 | function rimraf_ (p, options, cb) { 3601 | assert(p) 3602 | assert(options) 3603 | assert(typeof cb === 'function') 3604 | 3605 | // sunos lets the root user unlink directories, which is... weird. 3606 | // so we have to lstat here and make sure it's not a dir. 3607 | options.lstat(p, function (er, st) { 3608 | if (er && er.code === "ENOENT") 3609 | return cb(null) 3610 | 3611 | // Windows can EPERM on stat. Life is suffering. 3612 | if (er && er.code === "EPERM" && isWindows) 3613 | fixWinEPERM(p, options, er, cb) 3614 | 3615 | if (st && st.isDirectory()) 3616 | return rmdir(p, options, er, cb) 3617 | 3618 | options.unlink(p, function (er) { 3619 | if (er) { 3620 | if (er.code === "ENOENT") 3621 | return cb(null) 3622 | if (er.code === "EPERM") 3623 | return (isWindows) 3624 | ? fixWinEPERM(p, options, er, cb) 3625 | : rmdir(p, options, er, cb) 3626 | if (er.code === "EISDIR") 3627 | return rmdir(p, options, er, cb) 3628 | } 3629 | return cb(er) 3630 | }) 3631 | }) 3632 | } 3633 | 3634 | function fixWinEPERM (p, options, er, cb) { 3635 | assert(p) 3636 | assert(options) 3637 | assert(typeof cb === 'function') 3638 | if (er) 3639 | assert(er instanceof Error) 3640 | 3641 | options.chmod(p, _0666, function (er2) { 3642 | if (er2) 3643 | cb(er2.code === "ENOENT" ? null : er) 3644 | else 3645 | options.stat(p, function(er3, stats) { 3646 | if (er3) 3647 | cb(er3.code === "ENOENT" ? null : er) 3648 | else if (stats.isDirectory()) 3649 | rmdir(p, options, er, cb) 3650 | else 3651 | options.unlink(p, cb) 3652 | }) 3653 | }) 3654 | } 3655 | 3656 | function fixWinEPERMSync (p, options, er) { 3657 | assert(p) 3658 | assert(options) 3659 | if (er) 3660 | assert(er instanceof Error) 3661 | 3662 | try { 3663 | options.chmodSync(p, _0666) 3664 | } catch (er2) { 3665 | if (er2.code === "ENOENT") 3666 | return 3667 | else 3668 | throw er 3669 | } 3670 | 3671 | try { 3672 | var stats = options.statSync(p) 3673 | } catch (er3) { 3674 | if (er3.code === "ENOENT") 3675 | return 3676 | else 3677 | throw er 3678 | } 3679 | 3680 | if (stats.isDirectory()) 3681 | rmdirSync(p, options, er) 3682 | else 3683 | options.unlinkSync(p) 3684 | } 3685 | 3686 | function rmdir (p, options, originalEr, cb) { 3687 | assert(p) 3688 | assert(options) 3689 | if (originalEr) 3690 | assert(originalEr instanceof Error) 3691 | assert(typeof cb === 'function') 3692 | 3693 | // try to rmdir first, and only readdir on ENOTEMPTY or EEXIST (SunOS) 3694 | // if we guessed wrong, and it's not a directory, then 3695 | // raise the original error. 3696 | options.rmdir(p, function (er) { 3697 | if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM")) 3698 | rmkids(p, options, cb) 3699 | else if (er && er.code === "ENOTDIR") 3700 | cb(originalEr) 3701 | else 3702 | cb(er) 3703 | }) 3704 | } 3705 | 3706 | function rmkids(p, options, cb) { 3707 | assert(p) 3708 | assert(options) 3709 | assert(typeof cb === 'function') 3710 | 3711 | options.readdir(p, function (er, files) { 3712 | if (er) 3713 | return cb(er) 3714 | var n = files.length 3715 | if (n === 0) 3716 | return options.rmdir(p, cb) 3717 | var errState 3718 | files.forEach(function (f) { 3719 | rimraf(path.join(p, f), options, function (er) { 3720 | if (errState) 3721 | return 3722 | if (er) 3723 | return cb(errState = er) 3724 | if (--n === 0) 3725 | options.rmdir(p, cb) 3726 | }) 3727 | }) 3728 | }) 3729 | } 3730 | 3731 | // this looks simpler, and is strictly *faster*, but will 3732 | // tie up the JavaScript thread and fail on excessively 3733 | // deep directory trees. 3734 | function rimrafSync (p, options) { 3735 | options = options || {} 3736 | defaults(options) 3737 | 3738 | assert(p, 'rimraf: missing path') 3739 | assert.equal(typeof p, 'string', 'rimraf: path should be a string') 3740 | assert(options, 'rimraf: missing options') 3741 | assert.equal(typeof options, 'object', 'rimraf: options should be object') 3742 | 3743 | var results 3744 | 3745 | if (options.disableGlob || !glob.hasMagic(p)) { 3746 | results = [p] 3747 | } else { 3748 | try { 3749 | options.lstatSync(p) 3750 | results = [p] 3751 | } catch (er) { 3752 | results = glob.sync(p, options.glob) 3753 | } 3754 | } 3755 | 3756 | if (!results.length) 3757 | return 3758 | 3759 | for (var i = 0; i < results.length; i++) { 3760 | var p = results[i] 3761 | 3762 | try { 3763 | var st = options.lstatSync(p) 3764 | } catch (er) { 3765 | if (er.code === "ENOENT") 3766 | return 3767 | 3768 | // Windows can EPERM on stat. Life is suffering. 3769 | if (er.code === "EPERM" && isWindows) 3770 | fixWinEPERMSync(p, options, er) 3771 | } 3772 | 3773 | try { 3774 | // sunos lets the root user unlink directories, which is... weird. 3775 | if (st && st.isDirectory()) 3776 | rmdirSync(p, options, null) 3777 | else 3778 | options.unlinkSync(p) 3779 | } catch (er) { 3780 | if (er.code === "ENOENT") 3781 | return 3782 | if (er.code === "EPERM") 3783 | return isWindows ? fixWinEPERMSync(p, options, er) : rmdirSync(p, options, er) 3784 | if (er.code !== "EISDIR") 3785 | throw er 3786 | 3787 | rmdirSync(p, options, er) 3788 | } 3789 | } 3790 | } 3791 | 3792 | function rmdirSync (p, options, originalEr) { 3793 | assert(p) 3794 | assert(options) 3795 | if (originalEr) 3796 | assert(originalEr instanceof Error) 3797 | 3798 | try { 3799 | options.rmdirSync(p) 3800 | } catch (er) { 3801 | if (er.code === "ENOENT") 3802 | return 3803 | if (er.code === "ENOTDIR") 3804 | throw originalEr 3805 | if (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM") 3806 | rmkidsSync(p, options) 3807 | } 3808 | } 3809 | 3810 | function rmkidsSync (p, options) { 3811 | assert(p) 3812 | assert(options) 3813 | options.readdirSync(p).forEach(function (f) { 3814 | rimrafSync(path.join(p, f), options) 3815 | }) 3816 | 3817 | // We only end up here once we got ENOTEMPTY at least once, and 3818 | // at this point, we are guaranteed to have removed all the kids. 3819 | // So, we know that it won't be ENOENT or ENOTDIR or anything else. 3820 | // try really hard to delete stuff on windows, because it has a 3821 | // PROFOUNDLY annoying habit of not closing handles promptly when 3822 | // files are deleted, resulting in spurious ENOTEMPTY errors. 3823 | var retries = isWindows ? 100 : 1 3824 | var i = 0 3825 | do { 3826 | var threw = true 3827 | try { 3828 | var ret = options.rmdirSync(p, options) 3829 | threw = false 3830 | return ret 3831 | } finally { 3832 | if (++i < retries && threw) 3833 | continue 3834 | } 3835 | } while (true) 3836 | } 3837 | 3838 | 3839 | /***/ }), 3840 | 3841 | /***/ 719: 3842 | /***/ (function(module) { 3843 | 3844 | // Returns a wrapper function that returns a wrapped callback 3845 | // The wrapper function should do some stuff, and return a 3846 | // presumably different callback function. 3847 | // This makes sure that own properties are retained, so that 3848 | // decorations and such are not lost along the way. 3849 | module.exports = wrappy 3850 | function wrappy (fn, cb) { 3851 | if (fn && cb) return wrappy(fn)(cb) 3852 | 3853 | if (typeof fn !== 'function') 3854 | throw new TypeError('need wrapper function') 3855 | 3856 | Object.keys(fn).forEach(function (k) { 3857 | wrapper[k] = fn[k] 3858 | }) 3859 | 3860 | return wrapper 3861 | 3862 | function wrapper() { 3863 | var args = new Array(arguments.length) 3864 | for (var i = 0; i < args.length; i++) { 3865 | args[i] = arguments[i] 3866 | } 3867 | var ret = fn.apply(this, args) 3868 | var cb = args[args.length-1] 3869 | if (typeof ret === 'function' && ret !== cb) { 3870 | Object.keys(cb).forEach(function (k) { 3871 | ret[k] = cb[k] 3872 | }) 3873 | } 3874 | return ret 3875 | } 3876 | } 3877 | 3878 | 3879 | /***/ }), 3880 | 3881 | /***/ 747: 3882 | /***/ (function(module) { 3883 | 3884 | module.exports = require("fs"); 3885 | 3886 | /***/ }), 3887 | 3888 | /***/ 812: 3889 | /***/ (function(module) { 3890 | 3891 | module.exports = function (xs, fn) { 3892 | var res = []; 3893 | for (var i = 0; i < xs.length; i++) { 3894 | var x = fn(xs[i], i); 3895 | if (isArray(x)) res.push.apply(res, x); 3896 | else res.push(x); 3897 | } 3898 | return res; 3899 | }; 3900 | 3901 | var isArray = Array.isArray || function (xs) { 3902 | return Object.prototype.toString.call(xs) === '[object Array]'; 3903 | }; 3904 | 3905 | 3906 | /***/ }), 3907 | 3908 | /***/ 827: 3909 | /***/ (function(__unusedmodule, exports, __webpack_require__) { 3910 | 3911 | "use strict"; 3912 | 3913 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3914 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 3915 | return new (P || (P = Promise))(function (resolve, reject) { 3916 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 3917 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 3918 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 3919 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 3920 | }); 3921 | }; 3922 | Object.defineProperty(exports, "__esModule", { value: true }); 3923 | const command_1 = __webpack_require__(215); 3924 | const os = __webpack_require__(87); 3925 | const path = __webpack_require__(277); 3926 | /** 3927 | * The code to exit an action 3928 | */ 3929 | var ExitCode; 3930 | (function (ExitCode) { 3931 | /** 3932 | * A code indicating that the action was successful 3933 | */ 3934 | ExitCode[ExitCode["Success"] = 0] = "Success"; 3935 | /** 3936 | * A code indicating that the action was a failure 3937 | */ 3938 | ExitCode[ExitCode["Failure"] = 1] = "Failure"; 3939 | })(ExitCode = exports.ExitCode || (exports.ExitCode = {})); 3940 | //----------------------------------------------------------------------- 3941 | // Variables 3942 | //----------------------------------------------------------------------- 3943 | /** 3944 | * Sets env variable for this action and future actions in the job 3945 | * @param name the name of the variable to set 3946 | * @param val the value of the variable 3947 | */ 3948 | function exportVariable(name, val) { 3949 | process.env[name] = val; 3950 | command_1.issueCommand('set-env', { name }, val); 3951 | } 3952 | exports.exportVariable = exportVariable; 3953 | /** 3954 | * Registers a secret which will get masked from logs 3955 | * @param secret value of the secret 3956 | */ 3957 | function setSecret(secret) { 3958 | command_1.issueCommand('add-mask', {}, secret); 3959 | } 3960 | exports.setSecret = setSecret; 3961 | /** 3962 | * Prepends inputPath to the PATH (for this action and future actions) 3963 | * @param inputPath 3964 | */ 3965 | function addPath(inputPath) { 3966 | command_1.issueCommand('add-path', {}, inputPath); 3967 | process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`; 3968 | } 3969 | exports.addPath = addPath; 3970 | /** 3971 | * Gets the value of an input. The value is also trimmed. 3972 | * 3973 | * @param name name of the input to get 3974 | * @param options optional. See InputOptions. 3975 | * @returns string 3976 | */ 3977 | function getInput(name, options) { 3978 | const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || ''; 3979 | if (options && options.required && !val) { 3980 | throw new Error(`Input required and not supplied: ${name}`); 3981 | } 3982 | return val.trim(); 3983 | } 3984 | exports.getInput = getInput; 3985 | /** 3986 | * Sets the value of an output. 3987 | * 3988 | * @param name name of the output to set 3989 | * @param value value to store 3990 | */ 3991 | function setOutput(name, value) { 3992 | command_1.issueCommand('set-output', { name }, value); 3993 | } 3994 | exports.setOutput = setOutput; 3995 | //----------------------------------------------------------------------- 3996 | // Results 3997 | //----------------------------------------------------------------------- 3998 | /** 3999 | * Sets the action status to failed. 4000 | * When the action exits it will be with an exit code of 1 4001 | * @param message add error issue message 4002 | */ 4003 | function setFailed(message) { 4004 | process.exitCode = ExitCode.Failure; 4005 | error(message); 4006 | } 4007 | exports.setFailed = setFailed; 4008 | //----------------------------------------------------------------------- 4009 | // Logging Commands 4010 | //----------------------------------------------------------------------- 4011 | /** 4012 | * Writes debug message to user log 4013 | * @param message debug message 4014 | */ 4015 | function debug(message) { 4016 | command_1.issueCommand('debug', {}, message); 4017 | } 4018 | exports.debug = debug; 4019 | /** 4020 | * Adds an error issue 4021 | * @param message error issue message 4022 | */ 4023 | function error(message) { 4024 | command_1.issue('error', message); 4025 | } 4026 | exports.error = error; 4027 | /** 4028 | * Adds an warning issue 4029 | * @param message warning issue message 4030 | */ 4031 | function warning(message) { 4032 | command_1.issue('warning', message); 4033 | } 4034 | exports.warning = warning; 4035 | /** 4036 | * Writes info to log with console.log. 4037 | * @param message info message 4038 | */ 4039 | function info(message) { 4040 | process.stdout.write(message + os.EOL); 4041 | } 4042 | exports.info = info; 4043 | /** 4044 | * Begin an output group. 4045 | * 4046 | * Output until the next `groupEnd` will be foldable in this group 4047 | * 4048 | * @param name The name of the output group 4049 | */ 4050 | function startGroup(name) { 4051 | command_1.issue('group', name); 4052 | } 4053 | exports.startGroup = startGroup; 4054 | /** 4055 | * End an output group. 4056 | */ 4057 | function endGroup() { 4058 | command_1.issue('endgroup'); 4059 | } 4060 | exports.endGroup = endGroup; 4061 | /** 4062 | * Wrap an asynchronous function call in a group. 4063 | * 4064 | * Returns the same type as the function itself. 4065 | * 4066 | * @param name The name of the group 4067 | * @param fn The function to wrap in the group 4068 | */ 4069 | function group(name, fn) { 4070 | return __awaiter(this, void 0, void 0, function* () { 4071 | startGroup(name); 4072 | let result; 4073 | try { 4074 | result = yield fn(); 4075 | } 4076 | finally { 4077 | endGroup(); 4078 | } 4079 | return result; 4080 | }); 4081 | } 4082 | exports.group = group; 4083 | //----------------------------------------------------------------------- 4084 | // Wrapper action state 4085 | //----------------------------------------------------------------------- 4086 | /** 4087 | * Saves state for current action, the state can only be retrieved by this action's post job execution. 4088 | * 4089 | * @param name name of the state to store 4090 | * @param value value to store 4091 | */ 4092 | function saveState(name, value) { 4093 | command_1.issueCommand('save-state', { name }, value); 4094 | } 4095 | exports.saveState = saveState; 4096 | /** 4097 | * Gets the value of an state set by this action's main execution. 4098 | * 4099 | * @param name name of the state to get 4100 | * @returns string 4101 | */ 4102 | function getState(name) { 4103 | return process.env[`STATE_${name}`] || ''; 4104 | } 4105 | exports.getState = getState; 4106 | //# sourceMappingURL=core.js.map 4107 | 4108 | /***/ }), 4109 | 4110 | /***/ 829: 4111 | /***/ (function(module) { 4112 | 4113 | "use strict"; 4114 | 4115 | 4116 | function posix(path) { 4117 | return path.charAt(0) === '/'; 4118 | } 4119 | 4120 | function win32(path) { 4121 | // https://github.com/nodejs/node/blob/b3fcc245fb25539909ef1d5eaa01dbf92e168633/lib/path.js#L56 4122 | var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/; 4123 | var result = splitDeviceRe.exec(path); 4124 | var device = result[1] || ''; 4125 | var isUnc = Boolean(device && device.charAt(1) !== ':'); 4126 | 4127 | // UNC paths are always absolute 4128 | return Boolean(result[2] || isUnc); 4129 | } 4130 | 4131 | module.exports = process.platform === 'win32' ? win32 : posix; 4132 | module.exports.posix = posix; 4133 | module.exports.win32 = win32; 4134 | 4135 | 4136 | /***/ }), 4137 | 4138 | /***/ 851: 4139 | /***/ (function(module) { 4140 | 4141 | if (typeof Object.create === 'function') { 4142 | // implementation from standard node.js 'util' module 4143 | module.exports = function inherits(ctor, superCtor) { 4144 | if (superCtor) { 4145 | ctor.super_ = superCtor 4146 | ctor.prototype = Object.create(superCtor.prototype, { 4147 | constructor: { 4148 | value: ctor, 4149 | enumerable: false, 4150 | writable: true, 4151 | configurable: true 4152 | } 4153 | }) 4154 | } 4155 | }; 4156 | } else { 4157 | // old school shim for old browsers 4158 | module.exports = function inherits(ctor, superCtor) { 4159 | if (superCtor) { 4160 | ctor.super_ = superCtor 4161 | var TempCtor = function () {} 4162 | TempCtor.prototype = superCtor.prototype 4163 | ctor.prototype = new TempCtor() 4164 | ctor.prototype.constructor = ctor 4165 | } 4166 | } 4167 | } 4168 | 4169 | 4170 | /***/ }), 4171 | 4172 | /***/ 870: 4173 | /***/ (function(module, __unusedexports, __webpack_require__) { 4174 | 4175 | var wrappy = __webpack_require__(719) 4176 | module.exports = wrappy(once) 4177 | module.exports.strict = wrappy(onceStrict) 4178 | 4179 | once.proto = once(function () { 4180 | Object.defineProperty(Function.prototype, 'once', { 4181 | value: function () { 4182 | return once(this) 4183 | }, 4184 | configurable: true 4185 | }) 4186 | 4187 | Object.defineProperty(Function.prototype, 'onceStrict', { 4188 | value: function () { 4189 | return onceStrict(this) 4190 | }, 4191 | configurable: true 4192 | }) 4193 | }) 4194 | 4195 | function once (fn) { 4196 | var f = function () { 4197 | if (f.called) return f.value 4198 | f.called = true 4199 | return f.value = fn.apply(this, arguments) 4200 | } 4201 | f.called = false 4202 | return f 4203 | } 4204 | 4205 | function onceStrict (fn) { 4206 | var f = function () { 4207 | if (f.called) 4208 | throw new Error(f.onceError) 4209 | f.called = true 4210 | return f.value = fn.apply(this, arguments) 4211 | } 4212 | var name = fn.name || 'Function wrapped with `once`' 4213 | f.onceError = name + " shouldn't be called more than once" 4214 | f.called = false 4215 | return f 4216 | } 4217 | 4218 | 4219 | /***/ }), 4220 | 4221 | /***/ 938: 4222 | /***/ (function(module, __unusedexports, __webpack_require__) { 4223 | 4224 | /*! 4225 | * Tmp 4226 | * 4227 | * Copyright (c) 2011-2017 KARASZI Istvan 4228 | * 4229 | * MIT Licensed 4230 | */ 4231 | 4232 | /* 4233 | * Module dependencies. 4234 | */ 4235 | const fs = __webpack_require__(747); 4236 | const os = __webpack_require__(87); 4237 | const path = __webpack_require__(277); 4238 | const crypto = __webpack_require__(417); 4239 | const _c = fs.constants && os.constants ? 4240 | { fs: fs.constants, os: os.constants } : 4241 | process.binding('constants'); 4242 | const rimraf = __webpack_require__(700); 4243 | 4244 | /* 4245 | * The working inner variables. 4246 | */ 4247 | const 4248 | // the random characters to choose from 4249 | RANDOM_CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', 4250 | 4251 | TEMPLATE_PATTERN = /XXXXXX/, 4252 | 4253 | DEFAULT_TRIES = 3, 4254 | 4255 | CREATE_FLAGS = (_c.O_CREAT || _c.fs.O_CREAT) | (_c.O_EXCL || _c.fs.O_EXCL) | (_c.O_RDWR || _c.fs.O_RDWR), 4256 | 4257 | EBADF = _c.EBADF || _c.os.errno.EBADF, 4258 | ENOENT = _c.ENOENT || _c.os.errno.ENOENT, 4259 | 4260 | DIR_MODE = 448 /* 0o700 */, 4261 | FILE_MODE = 384 /* 0o600 */, 4262 | 4263 | EXIT = 'exit', 4264 | 4265 | SIGINT = 'SIGINT', 4266 | 4267 | // this will hold the objects need to be removed on exit 4268 | _removeObjects = []; 4269 | 4270 | var 4271 | _gracefulCleanup = false; 4272 | 4273 | /** 4274 | * Random name generator based on crypto. 4275 | * Adapted from http://blog.tompawlak.org/how-to-generate-random-values-nodejs-javascript 4276 | * 4277 | * @param {number} howMany 4278 | * @returns {string} the generated random name 4279 | * @private 4280 | */ 4281 | function _randomChars(howMany) { 4282 | var 4283 | value = [], 4284 | rnd = null; 4285 | 4286 | // make sure that we do not fail because we ran out of entropy 4287 | try { 4288 | rnd = crypto.randomBytes(howMany); 4289 | } catch (e) { 4290 | rnd = crypto.pseudoRandomBytes(howMany); 4291 | } 4292 | 4293 | for (var i = 0; i < howMany; i++) { 4294 | value.push(RANDOM_CHARS[rnd[i] % RANDOM_CHARS.length]); 4295 | } 4296 | 4297 | return value.join(''); 4298 | } 4299 | 4300 | /** 4301 | * Checks whether the `obj` parameter is defined or not. 4302 | * 4303 | * @param {Object} obj 4304 | * @returns {boolean} true if the object is undefined 4305 | * @private 4306 | */ 4307 | function _isUndefined(obj) { 4308 | return typeof obj === 'undefined'; 4309 | } 4310 | 4311 | /** 4312 | * Parses the function arguments. 4313 | * 4314 | * This function helps to have optional arguments. 4315 | * 4316 | * @param {(Options|Function)} options 4317 | * @param {Function} callback 4318 | * @returns {Array} parsed arguments 4319 | * @private 4320 | */ 4321 | function _parseArguments(options, callback) { 4322 | /* istanbul ignore else */ 4323 | if (typeof options === 'function') { 4324 | return [{}, options]; 4325 | } 4326 | 4327 | /* istanbul ignore else */ 4328 | if (_isUndefined(options)) { 4329 | return [{}, callback]; 4330 | } 4331 | 4332 | return [options, callback]; 4333 | } 4334 | 4335 | /** 4336 | * Generates a new temporary name. 4337 | * 4338 | * @param {Object} opts 4339 | * @returns {string} the new random name according to opts 4340 | * @private 4341 | */ 4342 | function _generateTmpName(opts) { 4343 | 4344 | const tmpDir = _getTmpDir(); 4345 | 4346 | // fail early on missing tmp dir 4347 | if (isBlank(opts.dir) && isBlank(tmpDir)) { 4348 | throw new Error('No tmp dir specified'); 4349 | } 4350 | 4351 | /* istanbul ignore else */ 4352 | if (!isBlank(opts.name)) { 4353 | return path.join(opts.dir || tmpDir, opts.name); 4354 | } 4355 | 4356 | // mkstemps like template 4357 | // opts.template has already been guarded in tmpName() below 4358 | /* istanbul ignore else */ 4359 | if (opts.template) { 4360 | var template = opts.template; 4361 | // make sure that we prepend the tmp path if none was given 4362 | /* istanbul ignore else */ 4363 | if (path.basename(template) === template) 4364 | template = path.join(opts.dir || tmpDir, template); 4365 | return template.replace(TEMPLATE_PATTERN, _randomChars(6)); 4366 | } 4367 | 4368 | // prefix and postfix 4369 | const name = [ 4370 | (isBlank(opts.prefix) ? 'tmp-' : opts.prefix), 4371 | process.pid, 4372 | _randomChars(12), 4373 | (opts.postfix ? opts.postfix : '') 4374 | ].join(''); 4375 | 4376 | return path.join(opts.dir || tmpDir, name); 4377 | } 4378 | 4379 | /** 4380 | * Gets a temporary file name. 4381 | * 4382 | * @param {(Options|tmpNameCallback)} options options or callback 4383 | * @param {?tmpNameCallback} callback the callback function 4384 | */ 4385 | function tmpName(options, callback) { 4386 | var 4387 | args = _parseArguments(options, callback), 4388 | opts = args[0], 4389 | cb = args[1], 4390 | tries = !isBlank(opts.name) ? 1 : opts.tries || DEFAULT_TRIES; 4391 | 4392 | /* istanbul ignore else */ 4393 | if (isNaN(tries) || tries < 0) 4394 | return cb(new Error('Invalid tries')); 4395 | 4396 | /* istanbul ignore else */ 4397 | if (opts.template && !opts.template.match(TEMPLATE_PATTERN)) 4398 | return cb(new Error('Invalid template provided')); 4399 | 4400 | (function _getUniqueName() { 4401 | try { 4402 | const name = _generateTmpName(opts); 4403 | 4404 | // check whether the path exists then retry if needed 4405 | fs.stat(name, function (err) { 4406 | /* istanbul ignore else */ 4407 | if (!err) { 4408 | /* istanbul ignore else */ 4409 | if (tries-- > 0) return _getUniqueName(); 4410 | 4411 | return cb(new Error('Could not get a unique tmp filename, max tries reached ' + name)); 4412 | } 4413 | 4414 | cb(null, name); 4415 | }); 4416 | } catch (err) { 4417 | cb(err); 4418 | } 4419 | }()); 4420 | } 4421 | 4422 | /** 4423 | * Synchronous version of tmpName. 4424 | * 4425 | * @param {Object} options 4426 | * @returns {string} the generated random name 4427 | * @throws {Error} if the options are invalid or could not generate a filename 4428 | */ 4429 | function tmpNameSync(options) { 4430 | var 4431 | args = _parseArguments(options), 4432 | opts = args[0], 4433 | tries = !isBlank(opts.name) ? 1 : opts.tries || DEFAULT_TRIES; 4434 | 4435 | /* istanbul ignore else */ 4436 | if (isNaN(tries) || tries < 0) 4437 | throw new Error('Invalid tries'); 4438 | 4439 | /* istanbul ignore else */ 4440 | if (opts.template && !opts.template.match(TEMPLATE_PATTERN)) 4441 | throw new Error('Invalid template provided'); 4442 | 4443 | do { 4444 | const name = _generateTmpName(opts); 4445 | try { 4446 | fs.statSync(name); 4447 | } catch (e) { 4448 | return name; 4449 | } 4450 | } while (tries-- > 0); 4451 | 4452 | throw new Error('Could not get a unique tmp filename, max tries reached'); 4453 | } 4454 | 4455 | /** 4456 | * Creates and opens a temporary file. 4457 | * 4458 | * @param {(Options|fileCallback)} options the config options or the callback function 4459 | * @param {?fileCallback} callback 4460 | */ 4461 | function file(options, callback) { 4462 | var 4463 | args = _parseArguments(options, callback), 4464 | opts = args[0], 4465 | cb = args[1]; 4466 | 4467 | // gets a temporary filename 4468 | tmpName(opts, function _tmpNameCreated(err, name) { 4469 | /* istanbul ignore else */ 4470 | if (err) return cb(err); 4471 | 4472 | // create and open the file 4473 | fs.open(name, CREATE_FLAGS, opts.mode || FILE_MODE, function _fileCreated(err, fd) { 4474 | /* istanbul ignore else */ 4475 | if (err) return cb(err); 4476 | 4477 | if (opts.discardDescriptor) { 4478 | return fs.close(fd, function _discardCallback(err) { 4479 | /* istanbul ignore else */ 4480 | if (err) { 4481 | // Low probability, and the file exists, so this could be 4482 | // ignored. If it isn't we certainly need to unlink the 4483 | // file, and if that fails too its error is more 4484 | // important. 4485 | try { 4486 | fs.unlinkSync(name); 4487 | } catch (e) { 4488 | if (!isENOENT(e)) { 4489 | err = e; 4490 | } 4491 | } 4492 | return cb(err); 4493 | } 4494 | cb(null, name, undefined, _prepareTmpFileRemoveCallback(name, -1, opts)); 4495 | }); 4496 | } 4497 | /* istanbul ignore else */ 4498 | if (opts.detachDescriptor) { 4499 | return cb(null, name, fd, _prepareTmpFileRemoveCallback(name, -1, opts)); 4500 | } 4501 | cb(null, name, fd, _prepareTmpFileRemoveCallback(name, fd, opts)); 4502 | }); 4503 | }); 4504 | } 4505 | 4506 | /** 4507 | * Synchronous version of file. 4508 | * 4509 | * @param {Options} options 4510 | * @returns {FileSyncObject} object consists of name, fd and removeCallback 4511 | * @throws {Error} if cannot create a file 4512 | */ 4513 | function fileSync(options) { 4514 | var 4515 | args = _parseArguments(options), 4516 | opts = args[0]; 4517 | 4518 | const discardOrDetachDescriptor = opts.discardDescriptor || opts.detachDescriptor; 4519 | const name = tmpNameSync(opts); 4520 | var fd = fs.openSync(name, CREATE_FLAGS, opts.mode || FILE_MODE); 4521 | /* istanbul ignore else */ 4522 | if (opts.discardDescriptor) { 4523 | fs.closeSync(fd); 4524 | fd = undefined; 4525 | } 4526 | 4527 | return { 4528 | name: name, 4529 | fd: fd, 4530 | removeCallback: _prepareTmpFileRemoveCallback(name, discardOrDetachDescriptor ? -1 : fd, opts) 4531 | }; 4532 | } 4533 | 4534 | /** 4535 | * Creates a temporary directory. 4536 | * 4537 | * @param {(Options|dirCallback)} options the options or the callback function 4538 | * @param {?dirCallback} callback 4539 | */ 4540 | function dir(options, callback) { 4541 | var 4542 | args = _parseArguments(options, callback), 4543 | opts = args[0], 4544 | cb = args[1]; 4545 | 4546 | // gets a temporary filename 4547 | tmpName(opts, function _tmpNameCreated(err, name) { 4548 | /* istanbul ignore else */ 4549 | if (err) return cb(err); 4550 | 4551 | // create the directory 4552 | fs.mkdir(name, opts.mode || DIR_MODE, function _dirCreated(err) { 4553 | /* istanbul ignore else */ 4554 | if (err) return cb(err); 4555 | 4556 | cb(null, name, _prepareTmpDirRemoveCallback(name, opts)); 4557 | }); 4558 | }); 4559 | } 4560 | 4561 | /** 4562 | * Synchronous version of dir. 4563 | * 4564 | * @param {Options} options 4565 | * @returns {DirSyncObject} object consists of name and removeCallback 4566 | * @throws {Error} if it cannot create a directory 4567 | */ 4568 | function dirSync(options) { 4569 | var 4570 | args = _parseArguments(options), 4571 | opts = args[0]; 4572 | 4573 | const name = tmpNameSync(opts); 4574 | fs.mkdirSync(name, opts.mode || DIR_MODE); 4575 | 4576 | return { 4577 | name: name, 4578 | removeCallback: _prepareTmpDirRemoveCallback(name, opts) 4579 | }; 4580 | } 4581 | 4582 | /** 4583 | * Removes files asynchronously. 4584 | * 4585 | * @param {Object} fdPath 4586 | * @param {Function} next 4587 | * @private 4588 | */ 4589 | function _removeFileAsync(fdPath, next) { 4590 | const _handler = function (err) { 4591 | if (err && !isENOENT(err)) { 4592 | // reraise any unanticipated error 4593 | return next(err); 4594 | } 4595 | next(); 4596 | } 4597 | 4598 | if (0 <= fdPath[0]) 4599 | fs.close(fdPath[0], function (err) { 4600 | fs.unlink(fdPath[1], _handler); 4601 | }); 4602 | else fs.unlink(fdPath[1], _handler); 4603 | } 4604 | 4605 | /** 4606 | * Removes files synchronously. 4607 | * 4608 | * @param {Object} fdPath 4609 | * @private 4610 | */ 4611 | function _removeFileSync(fdPath) { 4612 | try { 4613 | if (0 <= fdPath[0]) fs.closeSync(fdPath[0]); 4614 | } catch (e) { 4615 | // reraise any unanticipated error 4616 | if (!isEBADF(e) && !isENOENT(e)) throw e; 4617 | } finally { 4618 | try { 4619 | fs.unlinkSync(fdPath[1]); 4620 | } 4621 | catch (e) { 4622 | // reraise any unanticipated error 4623 | if (!isENOENT(e)) throw e; 4624 | } 4625 | } 4626 | } 4627 | 4628 | /** 4629 | * Prepares the callback for removal of the temporary file. 4630 | * 4631 | * @param {string} name the path of the file 4632 | * @param {number} fd file descriptor 4633 | * @param {Object} opts 4634 | * @returns {fileCallback} 4635 | * @private 4636 | */ 4637 | function _prepareTmpFileRemoveCallback(name, fd, opts) { 4638 | const removeCallbackSync = _prepareRemoveCallback(_removeFileSync, [fd, name]); 4639 | const removeCallback = _prepareRemoveCallback(_removeFileAsync, [fd, name], removeCallbackSync); 4640 | 4641 | if (!opts.keep) _removeObjects.unshift(removeCallbackSync); 4642 | 4643 | return removeCallback; 4644 | } 4645 | 4646 | /** 4647 | * Simple wrapper for rimraf. 4648 | * 4649 | * @param {string} dirPath 4650 | * @param {Function} next 4651 | * @private 4652 | */ 4653 | function _rimrafRemoveDirWrapper(dirPath, next) { 4654 | rimraf(dirPath, next); 4655 | } 4656 | 4657 | /** 4658 | * Simple wrapper for rimraf.sync. 4659 | * 4660 | * @param {string} dirPath 4661 | * @private 4662 | */ 4663 | function _rimrafRemoveDirSyncWrapper(dirPath, next) { 4664 | try { 4665 | return next(null, rimraf.sync(dirPath)); 4666 | } catch (err) { 4667 | return next(err); 4668 | } 4669 | } 4670 | 4671 | /** 4672 | * Prepares the callback for removal of the temporary directory. 4673 | * 4674 | * @param {string} name 4675 | * @param {Object} opts 4676 | * @returns {Function} the callback 4677 | * @private 4678 | */ 4679 | function _prepareTmpDirRemoveCallback(name, opts) { 4680 | const removeFunction = opts.unsafeCleanup ? _rimrafRemoveDirWrapper : fs.rmdir.bind(fs); 4681 | const removeFunctionSync = opts.unsafeCleanup ? _rimrafRemoveDirSyncWrapper : fs.rmdirSync.bind(fs); 4682 | const removeCallbackSync = _prepareRemoveCallback(removeFunctionSync, name); 4683 | const removeCallback = _prepareRemoveCallback(removeFunction, name, removeCallbackSync); 4684 | if (!opts.keep) _removeObjects.unshift(removeCallbackSync); 4685 | 4686 | return removeCallback; 4687 | } 4688 | 4689 | /** 4690 | * Creates a guarded function wrapping the removeFunction call. 4691 | * 4692 | * @param {Function} removeFunction 4693 | * @param {Object} arg 4694 | * @returns {Function} 4695 | * @private 4696 | */ 4697 | function _prepareRemoveCallback(removeFunction, arg, cleanupCallbackSync) { 4698 | var called = false; 4699 | 4700 | return function _cleanupCallback(next) { 4701 | next = next || function () {}; 4702 | if (!called) { 4703 | const toRemove = cleanupCallbackSync || _cleanupCallback; 4704 | const index = _removeObjects.indexOf(toRemove); 4705 | /* istanbul ignore else */ 4706 | if (index >= 0) _removeObjects.splice(index, 1); 4707 | 4708 | called = true; 4709 | // sync? 4710 | if (removeFunction.length === 1) { 4711 | try { 4712 | removeFunction(arg); 4713 | return next(null); 4714 | } 4715 | catch (err) { 4716 | // if no next is provided and since we are 4717 | // in silent cleanup mode on process exit, 4718 | // we will ignore the error 4719 | return next(err); 4720 | } 4721 | } else return removeFunction(arg, next); 4722 | } else return next(new Error('cleanup callback has already been called')); 4723 | }; 4724 | } 4725 | 4726 | /** 4727 | * The garbage collector. 4728 | * 4729 | * @private 4730 | */ 4731 | function _garbageCollector() { 4732 | /* istanbul ignore else */ 4733 | if (!_gracefulCleanup) return; 4734 | 4735 | // the function being called removes itself from _removeObjects, 4736 | // loop until _removeObjects is empty 4737 | while (_removeObjects.length) { 4738 | try { 4739 | _removeObjects[0](); 4740 | } catch (e) { 4741 | // already removed? 4742 | } 4743 | } 4744 | } 4745 | 4746 | /** 4747 | * Helper for testing against EBADF to compensate changes made to Node 7.x under Windows. 4748 | */ 4749 | function isEBADF(error) { 4750 | return isExpectedError(error, -EBADF, 'EBADF'); 4751 | } 4752 | 4753 | /** 4754 | * Helper for testing against ENOENT to compensate changes made to Node 7.x under Windows. 4755 | */ 4756 | function isENOENT(error) { 4757 | return isExpectedError(error, -ENOENT, 'ENOENT'); 4758 | } 4759 | 4760 | /** 4761 | * Helper to determine whether the expected error code matches the actual code and errno, 4762 | * which will differ between the supported node versions. 4763 | * 4764 | * - Node >= 7.0: 4765 | * error.code {string} 4766 | * error.errno {string|number} any numerical value will be negated 4767 | * 4768 | * - Node >= 6.0 < 7.0: 4769 | * error.code {string} 4770 | * error.errno {number} negated 4771 | * 4772 | * - Node >= 4.0 < 6.0: introduces SystemError 4773 | * error.code {string} 4774 | * error.errno {number} negated 4775 | * 4776 | * - Node >= 0.10 < 4.0: 4777 | * error.code {number} negated 4778 | * error.errno n/a 4779 | */ 4780 | function isExpectedError(error, code, errno) { 4781 | return error.code === code || error.code === errno; 4782 | } 4783 | 4784 | /** 4785 | * Helper which determines whether a string s is blank, that is undefined, or empty or null. 4786 | * 4787 | * @private 4788 | * @param {string} s 4789 | * @returns {Boolean} true whether the string s is blank, false otherwise 4790 | */ 4791 | function isBlank(s) { 4792 | return s === null || s === undefined || !s.trim(); 4793 | } 4794 | 4795 | /** 4796 | * Sets the graceful cleanup. 4797 | */ 4798 | function setGracefulCleanup() { 4799 | _gracefulCleanup = true; 4800 | } 4801 | 4802 | /** 4803 | * Returns the currently configured tmp dir from os.tmpdir(). 4804 | * 4805 | * @private 4806 | * @returns {string} the currently configured tmp dir 4807 | */ 4808 | function _getTmpDir() { 4809 | return os.tmpdir(); 4810 | } 4811 | 4812 | /** 4813 | * If there are multiple different versions of tmp in place, make sure that 4814 | * we recognize the old listeners. 4815 | * 4816 | * @param {Function} listener 4817 | * @private 4818 | * @returns {Boolean} true whether listener is a legacy listener 4819 | */ 4820 | function _is_legacy_listener(listener) { 4821 | return (listener.name === '_exit' || listener.name === '_uncaughtExceptionThrown') 4822 | && listener.toString().indexOf('_garbageCollector();') > -1; 4823 | } 4824 | 4825 | /** 4826 | * Safely install SIGINT listener. 4827 | * 4828 | * NOTE: this will only work on OSX and Linux. 4829 | * 4830 | * @private 4831 | */ 4832 | function _safely_install_sigint_listener() { 4833 | 4834 | const listeners = process.listeners(SIGINT); 4835 | const existingListeners = []; 4836 | for (let i = 0, length = listeners.length; i < length; i++) { 4837 | const lstnr = listeners[i]; 4838 | /* istanbul ignore else */ 4839 | if (lstnr.name === '_tmp$sigint_listener') { 4840 | existingListeners.push(lstnr); 4841 | process.removeListener(SIGINT, lstnr); 4842 | } 4843 | } 4844 | process.on(SIGINT, function _tmp$sigint_listener(doExit) { 4845 | for (let i = 0, length = existingListeners.length; i < length; i++) { 4846 | // let the existing listener do the garbage collection (e.g. jest sandbox) 4847 | try { 4848 | existingListeners[i](false); 4849 | } catch (err) { 4850 | // ignore 4851 | } 4852 | } 4853 | try { 4854 | // force the garbage collector even it is called again in the exit listener 4855 | _garbageCollector(); 4856 | } finally { 4857 | if (!!doExit) { 4858 | process.exit(0); 4859 | } 4860 | } 4861 | }); 4862 | } 4863 | 4864 | /** 4865 | * Safely install process exit listener. 4866 | * 4867 | * @private 4868 | */ 4869 | function _safely_install_exit_listener() { 4870 | const listeners = process.listeners(EXIT); 4871 | 4872 | // collect any existing listeners 4873 | const existingListeners = []; 4874 | for (let i = 0, length = listeners.length; i < length; i++) { 4875 | const lstnr = listeners[i]; 4876 | /* istanbul ignore else */ 4877 | // TODO: remove support for legacy listeners once release 1.0.0 is out 4878 | if (lstnr.name === '_tmp$safe_listener' || _is_legacy_listener(lstnr)) { 4879 | // we must forget about the uncaughtException listener, hopefully it is ours 4880 | if (lstnr.name !== '_uncaughtExceptionThrown') { 4881 | existingListeners.push(lstnr); 4882 | } 4883 | process.removeListener(EXIT, lstnr); 4884 | } 4885 | } 4886 | // TODO: what was the data parameter good for? 4887 | process.addListener(EXIT, function _tmp$safe_listener(data) { 4888 | for (let i = 0, length = existingListeners.length; i < length; i++) { 4889 | // let the existing listener do the garbage collection (e.g. jest sandbox) 4890 | try { 4891 | existingListeners[i](data); 4892 | } catch (err) { 4893 | // ignore 4894 | } 4895 | } 4896 | _garbageCollector(); 4897 | }); 4898 | } 4899 | 4900 | _safely_install_exit_listener(); 4901 | _safely_install_sigint_listener(); 4902 | 4903 | /** 4904 | * Configuration options. 4905 | * 4906 | * @typedef {Object} Options 4907 | * @property {?number} tries the number of tries before give up the name generation 4908 | * @property {?string} template the "mkstemp" like filename template 4909 | * @property {?string} name fix name 4910 | * @property {?string} dir the tmp directory to use 4911 | * @property {?string} prefix prefix for the generated name 4912 | * @property {?string} postfix postfix for the generated name 4913 | * @property {?boolean} unsafeCleanup recursively removes the created temporary directory, even when it's not empty 4914 | */ 4915 | 4916 | /** 4917 | * @typedef {Object} FileSyncObject 4918 | * @property {string} name the name of the file 4919 | * @property {string} fd the file descriptor 4920 | * @property {fileCallback} removeCallback the callback function to remove the file 4921 | */ 4922 | 4923 | /** 4924 | * @typedef {Object} DirSyncObject 4925 | * @property {string} name the name of the directory 4926 | * @property {fileCallback} removeCallback the callback function to remove the directory 4927 | */ 4928 | 4929 | /** 4930 | * @callback tmpNameCallback 4931 | * @param {?Error} err the error object if anything goes wrong 4932 | * @param {string} name the temporary file name 4933 | */ 4934 | 4935 | /** 4936 | * @callback fileCallback 4937 | * @param {?Error} err the error object if anything goes wrong 4938 | * @param {string} name the temporary file name 4939 | * @param {number} fd the file descriptor 4940 | * @param {cleanupCallback} fn the cleanup callback function 4941 | */ 4942 | 4943 | /** 4944 | * @callback dirCallback 4945 | * @param {?Error} err the error object if anything goes wrong 4946 | * @param {string} name the temporary file name 4947 | * @param {cleanupCallback} fn the cleanup callback function 4948 | */ 4949 | 4950 | /** 4951 | * Removes the temporary created file or directory. 4952 | * 4953 | * @callback cleanupCallback 4954 | * @param {simpleCallback} [next] function to call after entry was removed 4955 | */ 4956 | 4957 | /** 4958 | * Callback function for function composition. 4959 | * @see {@link https://github.com/raszi/node-tmp/issues/57|raszi/node-tmp#57} 4960 | * 4961 | * @callback simpleCallback 4962 | */ 4963 | 4964 | // exporting all the needed methods 4965 | 4966 | // evaluate os.tmpdir() lazily, mainly for simplifying testing but it also will 4967 | // allow users to reconfigure the temporary directory 4968 | Object.defineProperty(module.exports, 'tmpdir', { 4969 | enumerable: true, 4970 | configurable: false, 4971 | get: function () { 4972 | return _getTmpDir(); 4973 | } 4974 | }); 4975 | 4976 | module.exports.dir = dir; 4977 | module.exports.dirSync = dirSync; 4978 | 4979 | module.exports.file = file; 4980 | module.exports.fileSync = fileSync; 4981 | 4982 | module.exports.tmpName = tmpName; 4983 | module.exports.tmpNameSync = tmpNameSync; 4984 | 4985 | module.exports.setGracefulCleanup = setGracefulCleanup; 4986 | 4987 | 4988 | /***/ }) 4989 | 4990 | /******/ }, 4991 | /******/ function(__webpack_require__) { // webpackRuntimeModules 4992 | /******/ "use strict"; 4993 | /******/ 4994 | /******/ /* webpack/runtime/make namespace object */ 4995 | /******/ !function() { 4996 | /******/ // define __esModule on exports 4997 | /******/ __webpack_require__.r = function(exports) { 4998 | /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 4999 | /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 5000 | /******/ } 5001 | /******/ Object.defineProperty(exports, '__esModule', { value: true }); 5002 | /******/ }; 5003 | /******/ }(); 5004 | /******/ 5005 | /******/ /* webpack/runtime/define property getter */ 5006 | /******/ !function() { 5007 | /******/ // define getter function for harmony exports 5008 | /******/ var hasOwnProperty = Object.prototype.hasOwnProperty; 5009 | /******/ __webpack_require__.d = function(exports, name, getter) { 5010 | /******/ if(!hasOwnProperty.call(exports, name)) { 5011 | /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); 5012 | /******/ } 5013 | /******/ }; 5014 | /******/ }(); 5015 | /******/ 5016 | /******/ } 5017 | ); -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const core = require("@actions/core"); 2 | const path = require("path"); 3 | const fs = require("fs"); 4 | const tmp = require('tmp'); 5 | const { render } = require("./util"); 6 | 7 | async function run() { 8 | try { 9 | const jsonFilePath = core.getInput("json", { 10 | required: true 11 | }); 12 | 13 | // Parse the task definition 14 | const jsonAbsolutePath = path.isAbsolute(jsonFilePath) 15 | ? jsonFilePath 16 | : path.join(process.env.GITHUB_WORKSPACE, jsonFilePath); 17 | 18 | if (!fs.existsSync(jsonAbsolutePath)) { 19 | throw new Error(`Json file does not exist: ${jsonFilePath}`); 20 | } 21 | 22 | const jsonObj = require(jsonAbsolutePath); 23 | 24 | const result = render(jsonObj); 25 | 26 | console.log(JSON.stringify(result)); 27 | 28 | // Write out a new task definition file 29 | var tempFile = tmp.fileSync({ 30 | dir: process.env.RUNNER_TEMP, 31 | prefix: "json-rendered-", 32 | postfix: ".json", 33 | keep: true, 34 | discardDescriptor: true 35 | }); 36 | 37 | const newJsonObj = JSON.stringify(result, null, 2); 38 | fs.writeFileSync(tempFile.name, newJsonObj); 39 | core.setOutput("result", tempFile.name); 40 | } catch (error) { 41 | core.setFailed(error.message); 42 | } 43 | } 44 | 45 | run(); 46 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "render-json-action", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "@actions/core": { 8 | "version": "1.2.1", 9 | "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.2.1.tgz", 10 | "integrity": "sha512-xD+CQd9p4lU7ZfRqmUcbJpqR+Ss51rJRVeXMyOLrZQImN9/8Sy/BEUBnHO/UKD3z03R686PVTLfEPmkropGuLw==" 11 | }, 12 | "balanced-match": { 13 | "version": "1.0.0", 14 | "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", 15 | "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" 16 | }, 17 | "brace-expansion": { 18 | "version": "1.1.11", 19 | "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", 20 | "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", 21 | "requires": { 22 | "balanced-match": "^1.0.0", 23 | "concat-map": "0.0.1" 24 | } 25 | }, 26 | "concat-map": { 27 | "version": "0.0.1", 28 | "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", 29 | "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" 30 | }, 31 | "fs.realpath": { 32 | "version": "1.0.0", 33 | "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", 34 | "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" 35 | }, 36 | "glob": { 37 | "version": "7.1.6", 38 | "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", 39 | "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", 40 | "requires": { 41 | "fs.realpath": "^1.0.0", 42 | "inflight": "^1.0.4", 43 | "inherits": "2", 44 | "minimatch": "^3.0.4", 45 | "once": "^1.3.0", 46 | "path-is-absolute": "^1.0.0" 47 | } 48 | }, 49 | "inflight": { 50 | "version": "1.0.6", 51 | "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", 52 | "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", 53 | "requires": { 54 | "once": "^1.3.0", 55 | "wrappy": "1" 56 | } 57 | }, 58 | "inherits": { 59 | "version": "2.0.4", 60 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", 61 | "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" 62 | }, 63 | "minimatch": { 64 | "version": "3.0.4", 65 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", 66 | "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", 67 | "requires": { 68 | "brace-expansion": "^1.1.7" 69 | } 70 | }, 71 | "once": { 72 | "version": "1.4.0", 73 | "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", 74 | "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", 75 | "requires": { 76 | "wrappy": "1" 77 | } 78 | }, 79 | "path-is-absolute": { 80 | "version": "1.0.1", 81 | "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", 82 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" 83 | }, 84 | "rimraf": { 85 | "version": "2.6.3", 86 | "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.6.3.tgz", 87 | "integrity": "sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==", 88 | "requires": { 89 | "glob": "^7.1.3" 90 | } 91 | }, 92 | "tmp": { 93 | "version": "0.1.0", 94 | "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.1.0.tgz", 95 | "integrity": "sha512-J7Z2K08jbGcdA1kkQpJSqLF6T0tdQqpR2pnSUXsIchbPdTI9v3e85cLW0d6WDhwuAleOV71j2xWs8qMPfK7nKw==", 96 | "requires": { 97 | "rimraf": "^2.6.3" 98 | } 99 | }, 100 | "wrappy": { 101 | "version": "1.0.2", 102 | "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", 103 | "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "render-json-action", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "package": "ncc build index.js -o dist", 8 | "test": "echo \"Error: no test specified\" && exit 1" 9 | }, 10 | "keywords": [], 11 | "author": "", 12 | "license": "ISC", 13 | "dependencies": { 14 | "@actions/core": "^1.2.1", 15 | "tmp": "^0.1.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /util.js: -------------------------------------------------------------------------------- 1 | export function render(item) { 2 | if (item === null || item === undefined) return null; 3 | 4 | if (typeof item === "object") { 5 | if (Array.isArray(item)) { 6 | return item.map(i => render(i)); 7 | } else { 8 | for (let [key, value] of Object.entries(item)) { 9 | item[key] = render(value); 10 | } 11 | return item; 12 | } 13 | } else { 14 | if (typeof item === "string" && item.match(/^\%d/)) { 15 | return process.env[item.substr(3)] 16 | ? parseInt(process.env[item.substr(3)], 10) 17 | : undefined; 18 | } 19 | 20 | if (typeof item === "string" && item.match(/^\%f/)) { 21 | return process.env[item.substr(3)] 22 | ? parseFloat(process.env[item.substr(3)]) 23 | : undefined; 24 | } 25 | 26 | if (typeof item === "string" && item.match(/^\%s/)) { 27 | return process.env[item.substr(3)]; 28 | } 29 | 30 | if (typeof item === "string" && item.match(/^\%b/)) { 31 | return process.env[item.substr(3)] === "true"; 32 | } 33 | 34 | return item; 35 | } 36 | } 37 | --------------------------------------------------------------------------------