From f69e830323f8724b408e48b9b4165df24df09db2 Mon Sep 17 00:00:00 2001 From: konradpabjan Date: Tue, 6 Apr 2021 15:06:52 -0400 Subject: [PATCH 1/2] Bump @actions/artifact to version 0.5.1 --- dist/index.js | 3112 +++++++++++++++++++++++---------------------- package-lock.json | 42 +- package.json | 2 +- 3 files changed, 1573 insertions(+), 1583 deletions(-) diff --git a/dist/index.js b/dist/index.js index ae4f0ef4..343b4bfd 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1448,1071 +1448,1043 @@ exports.realpath = function realpath(p, cache, cb) { /***/ }), -/***/ 120: -/***/ (function(module, __unusedexports, __webpack_require__) { +/***/ 141: +/***/ (function(__unusedmodule, exports, __webpack_require__) { -// Approach: -// -// 1. Get the minimatch set -// 2. For each pattern in the set, PROCESS(pattern, false) -// 3. Store matches per-set, then uniq them -// -// PROCESS(pattern, inGlobStar) -// Get the first [n] items from pattern that are all strings -// Join these together. This is PREFIX. -// If there is no more remaining, then stat(PREFIX) and -// add to matches if it succeeds. END. -// -// If inGlobStar and PREFIX is symlink and points to dir -// set ENTRIES = [] -// else readdir(PREFIX) as ENTRIES -// If fail, END -// -// with ENTRIES -// If pattern[n] is GLOBSTAR -// // handle the case where the globstar match is empty -// // by pruning it out, and testing the resulting pattern -// PROCESS(pattern[0..n] + pattern[n+1 .. $], false) -// // handle other cases. -// for ENTRY in ENTRIES (not dotfiles) -// // attach globstar + tail onto the entry -// // Mark that this entry is a globstar match -// PROCESS(pattern[0..n] + ENTRY + pattern[n .. $], true) -// -// else // not globstar -// for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot) -// Test ENTRY against pattern[n] -// If fails, continue -// If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $]) -// -// Caveat: -// Cache all stats and readdirs results to minimize syscall. Since all -// we ever care about is existence and directory-ness, we can just keep -// `true` for files, and [children,...] for directories, or `false` for -// things that don't exist. +"use strict"; -module.exports = glob -var fs = __webpack_require__(747) -var rp = __webpack_require__(302) -var minimatch = __webpack_require__(93) -var Minimatch = minimatch.Minimatch -var inherits = __webpack_require__(689) -var EE = __webpack_require__(614).EventEmitter -var path = __webpack_require__(622) -var assert = __webpack_require__(357) -var isAbsolute = __webpack_require__(681) -var globSync = __webpack_require__(245) -var common = __webpack_require__(856) -var alphasort = common.alphasort -var alphasorti = common.alphasorti -var setopts = common.setopts -var ownProp = common.ownProp -var inflight = __webpack_require__(674) -var util = __webpack_require__(669) -var childrenIgnored = common.childrenIgnored -var isIgnored = common.isIgnored +var net = __webpack_require__(631); +var tls = __webpack_require__(16); +var http = __webpack_require__(605); +var https = __webpack_require__(211); +var events = __webpack_require__(614); +var assert = __webpack_require__(357); +var util = __webpack_require__(669); -var once = __webpack_require__(49) -function glob (pattern, options, cb) { - if (typeof options === 'function') cb = options, options = {} - if (!options) options = {} +exports.httpOverHttp = httpOverHttp; +exports.httpsOverHttp = httpsOverHttp; +exports.httpOverHttps = httpOverHttps; +exports.httpsOverHttps = httpsOverHttps; - if (options.sync) { - if (cb) - throw new TypeError('callback provided to sync glob') - return globSync(pattern, options) - } - return new Glob(pattern, options, cb) +function httpOverHttp(options) { + var agent = new TunnelingAgent(options); + agent.request = http.request; + return agent; } -glob.sync = globSync -var GlobSync = glob.GlobSync = globSync.GlobSync - -// old api surface -glob.glob = glob +function httpsOverHttp(options) { + var agent = new TunnelingAgent(options); + agent.request = http.request; + agent.createSocket = createSecureSocket; + agent.defaultPort = 443; + return agent; +} -function extend (origin, add) { - if (add === null || typeof add !== 'object') { - return origin - } +function httpOverHttps(options) { + var agent = new TunnelingAgent(options); + agent.request = https.request; + return agent; +} - var keys = Object.keys(add) - var i = keys.length - while (i--) { - origin[keys[i]] = add[keys[i]] - } - return origin +function httpsOverHttps(options) { + var agent = new TunnelingAgent(options); + agent.request = https.request; + agent.createSocket = createSecureSocket; + agent.defaultPort = 443; + return agent; } -glob.hasMagic = function (pattern, options_) { - var options = extend({}, options_) - options.noprocess = true - var g = new Glob(pattern, options) - var set = g.minimatch.set +function TunnelingAgent(options) { + var self = this; + self.options = options || {}; + self.proxyOptions = self.options.proxy || {}; + self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets; + self.requests = []; + self.sockets = []; - if (!pattern) - return false + self.on('free', function onFree(socket, host, port, localAddress) { + var options = toOptions(host, port, localAddress); + for (var i = 0, len = self.requests.length; i < len; ++i) { + var pending = self.requests[i]; + if (pending.host === options.host && pending.port === options.port) { + // Detect the request to connect same origin server, + // reuse the connection. + self.requests.splice(i, 1); + pending.request.onSocket(socket); + return; + } + } + socket.destroy(); + self.removeSocket(socket); + }); +} +util.inherits(TunnelingAgent, events.EventEmitter); - if (set.length > 1) - return true +TunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) { + var self = this; + var options = mergeOptions({request: req}, self.options, toOptions(host, port, localAddress)); - for (var j = 0; j < set[0].length; j++) { - if (typeof set[0][j] !== 'string') - return true + if (self.sockets.length >= this.maxSockets) { + // We are over limit so we'll add it to the queue. + self.requests.push(options); + return; } - return false -} + // If we are under maxSockets create a new one. + self.createSocket(options, function(socket) { + socket.on('free', onFree); + socket.on('close', onCloseOrRemove); + socket.on('agentRemove', onCloseOrRemove); + req.onSocket(socket); -glob.Glob = Glob -inherits(Glob, EE) -function Glob (pattern, options, cb) { - if (typeof options === 'function') { - cb = options - options = null - } + function onFree() { + self.emit('free', socket, options); + } - if (options && options.sync) { - if (cb) - throw new TypeError('callback provided to sync glob') - return new GlobSync(pattern, options) - } + function onCloseOrRemove(err) { + self.removeSocket(socket); + socket.removeListener('free', onFree); + socket.removeListener('close', onCloseOrRemove); + socket.removeListener('agentRemove', onCloseOrRemove); + } + }); +}; - if (!(this instanceof Glob)) - return new Glob(pattern, options, cb) +TunnelingAgent.prototype.createSocket = function createSocket(options, cb) { + var self = this; + var placeholder = {}; + self.sockets.push(placeholder); - setopts(this, pattern, options) - this._didRealPath = false + var connectOptions = mergeOptions({}, self.proxyOptions, { + method: 'CONNECT', + path: options.host + ':' + options.port, + agent: false, + headers: { + host: options.host + ':' + options.port + } + }); + if (options.localAddress) { + connectOptions.localAddress = options.localAddress; + } + if (connectOptions.proxyAuth) { + connectOptions.headers = connectOptions.headers || {}; + connectOptions.headers['Proxy-Authorization'] = 'Basic ' + + new Buffer(connectOptions.proxyAuth).toString('base64'); + } - // process each pattern in the minimatch set - var n = this.minimatch.set.length + debug('making CONNECT request'); + var connectReq = self.request(connectOptions); + connectReq.useChunkedEncodingByDefault = false; // for v0.6 + connectReq.once('response', onResponse); // for v0.6 + connectReq.once('upgrade', onUpgrade); // for v0.6 + connectReq.once('connect', onConnect); // for v0.7 or later + connectReq.once('error', onError); + connectReq.end(); - // The matches are stored as {: true,...} so that - // duplicates are automagically pruned. - // Later, we do an Object.keys() on these. - // Keep them as a list so we can fill in when nonull is set. - this.matches = new Array(n) + function onResponse(res) { + // Very hacky. This is necessary to avoid http-parser leaks. + res.upgrade = true; + } - if (typeof cb === 'function') { - cb = once(cb) - this.on('error', cb) - this.on('end', function (matches) { - cb(null, matches) - }) + function onUpgrade(res, socket, head) { + // Hacky. + process.nextTick(function() { + onConnect(res, socket, head); + }); } - var self = this - this._processing = 0 + function onConnect(res, socket, head) { + connectReq.removeAllListeners(); + socket.removeAllListeners(); - this._emitQueue = [] - this._processQueue = [] - this.paused = false - - if (this.noprocess) - return this + if (res.statusCode !== 200) { + debug('tunneling socket could not be established, statusCode=%d', + res.statusCode); + socket.destroy(); + var error = new Error('tunneling socket could not be established, ' + + 'statusCode=' + res.statusCode); + error.code = 'ECONNRESET'; + options.request.emit('error', error); + self.removeSocket(placeholder); + return; + } + if (head.length > 0) { + debug('got illegal response body from proxy'); + socket.destroy(); + var error = new Error('got illegal response body from proxy'); + error.code = 'ECONNRESET'; + options.request.emit('error', error); + self.removeSocket(placeholder); + return; + } + debug('tunneling connection has established'); + self.sockets[self.sockets.indexOf(placeholder)] = socket; + return cb(socket); + } - if (n === 0) - return done() + function onError(cause) { + connectReq.removeAllListeners(); - var sync = true - for (var i = 0; i < n; i ++) { - this._process(this.minimatch.set[i], i, false, done) + debug('tunneling socket could not be established, cause=%s\n', + cause.message, cause.stack); + var error = new Error('tunneling socket could not be established, ' + + 'cause=' + cause.message); + error.code = 'ECONNRESET'; + options.request.emit('error', error); + self.removeSocket(placeholder); } - sync = false +}; - function done () { - --self._processing - if (self._processing <= 0) { - if (sync) { - process.nextTick(function () { - self._finish() - }) - } else { - self._finish() - } - } +TunnelingAgent.prototype.removeSocket = function removeSocket(socket) { + var pos = this.sockets.indexOf(socket) + if (pos === -1) { + return; } -} + this.sockets.splice(pos, 1); -Glob.prototype._finish = function () { - assert(this instanceof Glob) - if (this.aborted) - return + var pending = this.requests.shift(); + if (pending) { + // If we have pending requests and a socket gets closed a new one + // needs to be created to take over in the pool for the one that closed. + this.createSocket(pending, function(socket) { + pending.request.onSocket(socket); + }); + } +}; - if (this.realpath && !this._didRealpath) - return this._realpath() +function createSecureSocket(options, cb) { + var self = this; + TunnelingAgent.prototype.createSocket.call(self, options, function(socket) { + var hostHeader = options.request.getHeader('host'); + var tlsOptions = mergeOptions({}, self.options, { + socket: socket, + servername: hostHeader ? hostHeader.replace(/:.*$/, '') : options.host + }); - common.finish(this) - this.emit('end', this.found) + // 0 is dummy port for v0.6 + var secureSocket = tls.connect(0, tlsOptions); + self.sockets[self.sockets.indexOf(socket)] = secureSocket; + cb(secureSocket); + }); } -Glob.prototype._realpath = function () { - if (this._didRealpath) - return - this._didRealpath = true +function toOptions(host, port, localAddress) { + if (typeof host === 'string') { // since v0.10 + return { + host: host, + port: port, + localAddress: localAddress + }; + } + return host; // for v0.11 or later +} - var n = this.matches.length - if (n === 0) - return this._finish() +function mergeOptions(target) { + for (var i = 1, len = arguments.length; i < len; ++i) { + var overrides = arguments[i]; + if (typeof overrides === 'object') { + var keys = Object.keys(overrides); + for (var j = 0, keyLen = keys.length; j < keyLen; ++j) { + var k = keys[j]; + if (overrides[k] !== undefined) { + target[k] = overrides[k]; + } + } + } + } + return target; +} - var self = this - for (var i = 0; i < this.matches.length; i++) - this._realpathSet(i, next) - function next () { - if (--n === 0) - self._finish() +var debug; +if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) { + debug = function() { + var args = Array.prototype.slice.call(arguments); + if (typeof args[0] === 'string') { + args[0] = 'TUNNEL: ' + args[0]; + } else { + args.unshift('TUNNEL:'); + } + console.error.apply(console, args); } +} else { + debug = function() {}; } +exports.debug = debug; // for test -Glob.prototype._realpathSet = function (index, cb) { - var matchset = this.matches[index] - if (!matchset) - return cb() - var found = Object.keys(matchset) - var self = this - var n = found.length +/***/ }), - if (n === 0) - return cb() +/***/ 150: +/***/ (function(module, __unusedexports, __webpack_require__) { - var set = this.matches[index] = Object.create(null) - found.forEach(function (p, i) { - // If there's a problem with the stat, then it means that - // one or more of the links in the realpath couldn't be - // resolved. just return the abs value in that case. - p = self._makeAbs(p) - rp.realpath(p, self.realpathCache, function (er, real) { - if (!er) - set[real] = true - else if (er.syscall === 'stat') - set[p] = true - else - self.emit('error', er) // srsly wtf right here +/*! + * Tmp + * + * Copyright (c) 2011-2017 KARASZI Istvan + * + * MIT Licensed + */ - if (--n === 0) { - self.matches[index] = set - cb() - } - }) - }) -} +/* + * Module dependencies. + */ +const fs = __webpack_require__(747); +const os = __webpack_require__(87); +const path = __webpack_require__(622); +const crypto = __webpack_require__(417); +const _c = fs.constants && os.constants ? + { fs: fs.constants, os: os.constants } : + process.binding('constants'); +const rimraf = __webpack_require__(569); -Glob.prototype._mark = function (p) { - return common.mark(this, p) -} +/* + * The working inner variables. + */ +const + // the random characters to choose from + RANDOM_CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', -Glob.prototype._makeAbs = function (f) { - return common.makeAbs(this, f) -} + TEMPLATE_PATTERN = /XXXXXX/, -Glob.prototype.abort = function () { - this.aborted = true - this.emit('abort') -} + DEFAULT_TRIES = 3, -Glob.prototype.pause = function () { - if (!this.paused) { - this.paused = true - this.emit('pause') - } -} + CREATE_FLAGS = (_c.O_CREAT || _c.fs.O_CREAT) | (_c.O_EXCL || _c.fs.O_EXCL) | (_c.O_RDWR || _c.fs.O_RDWR), -Glob.prototype.resume = function () { - if (this.paused) { - this.emit('resume') - this.paused = false - if (this._emitQueue.length) { - var eq = this._emitQueue.slice(0) - this._emitQueue.length = 0 - for (var i = 0; i < eq.length; i ++) { - var e = eq[i] - this._emitMatch(e[0], e[1]) - } - } - if (this._processQueue.length) { - var pq = this._processQueue.slice(0) - this._processQueue.length = 0 - for (var i = 0; i < pq.length; i ++) { - var p = pq[i] - this._processing-- - this._process(p[0], p[1], p[2], p[3]) - } - } - } -} + EBADF = _c.EBADF || _c.os.errno.EBADF, + ENOENT = _c.ENOENT || _c.os.errno.ENOENT, -Glob.prototype._process = function (pattern, index, inGlobStar, cb) { - assert(this instanceof Glob) - assert(typeof cb === 'function') + DIR_MODE = 448 /* 0o700 */, + FILE_MODE = 384 /* 0o600 */, - if (this.aborted) - return + EXIT = 'exit', - this._processing++ - if (this.paused) { - this._processQueue.push([pattern, index, inGlobStar, cb]) - return - } + SIGINT = 'SIGINT', - //console.error('PROCESS %d', this._processing, pattern) - - // Get the first [n] parts of pattern that are all strings. - var n = 0 - while (typeof pattern[n] === 'string') { - n ++ - } - // now n is the index of the first one that is *not* a string. + // this will hold the objects need to be removed on exit + _removeObjects = []; - // see if there's anything else - var prefix - switch (n) { - // if not, then this is rather simple - case pattern.length: - this._processSimple(pattern.join('/'), index, cb) - return +var + _gracefulCleanup = false; - case 0: - // pattern *starts* with some non-trivial item. - // going to readdir(cwd), but not include the prefix in matches. - prefix = null - break +/** + * Random name generator based on crypto. + * Adapted from http://blog.tompawlak.org/how-to-generate-random-values-nodejs-javascript + * + * @param {number} howMany + * @returns {string} the generated random name + * @private + */ +function _randomChars(howMany) { + var + value = [], + rnd = null; - default: - // pattern has some string bits in the front. - // whatever it starts with, whether that's 'absolute' like /foo/bar, - // or 'relative' like '../baz' - prefix = pattern.slice(0, n).join('/') - break + // make sure that we do not fail because we ran out of entropy + try { + rnd = crypto.randomBytes(howMany); + } catch (e) { + rnd = crypto.pseudoRandomBytes(howMany); } - var remain = pattern.slice(n) - - // get the list of entries. - var read - if (prefix === null) - read = '.' - else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) { - if (!prefix || !isAbsolute(prefix)) - prefix = '/' + prefix - read = prefix - } else - read = prefix - - var abs = this._makeAbs(read) - - //if ignored, skip _processing - if (childrenIgnored(this, read)) - return cb() + for (var i = 0; i < howMany; i++) { + value.push(RANDOM_CHARS[rnd[i] % RANDOM_CHARS.length]); + } - var isGlobStar = remain[0] === minimatch.GLOBSTAR - if (isGlobStar) - this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb) - else - this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb) + return value.join(''); } -Glob.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar, cb) { - var self = this - this._readdir(abs, inGlobStar, function (er, entries) { - return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb) - }) +/** + * Checks whether the `obj` parameter is defined or not. + * + * @param {Object} obj + * @returns {boolean} true if the object is undefined + * @private + */ +function _isUndefined(obj) { + return typeof obj === 'undefined'; } -Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) { - - // if the abs isn't a dir, then nothing can match! - if (!entries) - return cb() - - // It will only match dot entries if it starts with a dot, or if - // dot is set. Stuff like @(.foo|.bar) isn't allowed. - var pn = remain[0] - var negate = !!this.minimatch.negate - var rawGlob = pn._glob - var dotOk = this.dot || rawGlob.charAt(0) === '.' - - var matchedEntries = [] - for (var i = 0; i < entries.length; i++) { - var e = entries[i] - if (e.charAt(0) !== '.' || dotOk) { - var m - if (negate && !prefix) { - m = !e.match(pn) - } else { - m = e.match(pn) - } - if (m) - matchedEntries.push(e) - } +/** + * Parses the function arguments. + * + * This function helps to have optional arguments. + * + * @param {(Options|Function)} options + * @param {Function} callback + * @returns {Array} parsed arguments + * @private + */ +function _parseArguments(options, callback) { + /* istanbul ignore else */ + if (typeof options === 'function') { + return [{}, options]; } - //console.error('prd2', prefix, entries, remain[0]._glob, matchedEntries) - - var len = matchedEntries.length - // If there are no matched entries, then nothing matches. - if (len === 0) - return cb() + /* istanbul ignore else */ + if (_isUndefined(options)) { + return [{}, callback]; + } - // if this is the last remaining pattern bit, then no need for - // an additional stat *unless* the user has specified mark or - // stat explicitly. We know they exist, since readdir returned - // them. + return [options, callback]; +} - if (remain.length === 1 && !this.mark && !this.stat) { - if (!this.matches[index]) - this.matches[index] = Object.create(null) +/** + * Generates a new temporary name. + * + * @param {Object} opts + * @returns {string} the new random name according to opts + * @private + */ +function _generateTmpName(opts) { - for (var i = 0; i < len; i ++) { - var e = matchedEntries[i] - if (prefix) { - if (prefix !== '/') - e = prefix + '/' + e - else - e = prefix + e - } + const tmpDir = _getTmpDir(); - if (e.charAt(0) === '/' && !this.nomount) { - e = path.join(this.root, e) - } - this._emitMatch(index, e) - } - // This was the last one, and no stats were needed - return cb() + // fail early on missing tmp dir + if (isBlank(opts.dir) && isBlank(tmpDir)) { + throw new Error('No tmp dir specified'); } - // now test all matched entries as stand-ins for that part - // of the pattern. - remain.shift() - for (var i = 0; i < len; i ++) { - var e = matchedEntries[i] - var newPattern - if (prefix) { - if (prefix !== '/') - e = prefix + '/' + e - else - e = prefix + e - } - this._process([e].concat(remain), index, inGlobStar, cb) + /* istanbul ignore else */ + if (!isBlank(opts.name)) { + return path.join(opts.dir || tmpDir, opts.name); } - cb() -} - -Glob.prototype._emitMatch = function (index, e) { - if (this.aborted) - return - - if (isIgnored(this, e)) - return - if (this.paused) { - this._emitQueue.push([index, e]) - return + // mkstemps like template + // opts.template has already been guarded in tmpName() below + /* istanbul ignore else */ + if (opts.template) { + var template = opts.template; + // make sure that we prepend the tmp path if none was given + /* istanbul ignore else */ + if (path.basename(template) === template) + template = path.join(opts.dir || tmpDir, template); + return template.replace(TEMPLATE_PATTERN, _randomChars(6)); } - var abs = isAbsolute(e) ? e : this._makeAbs(e) + // prefix and postfix + const name = [ + (isBlank(opts.prefix) ? 'tmp-' : opts.prefix), + process.pid, + _randomChars(12), + (opts.postfix ? opts.postfix : '') + ].join(''); - if (this.mark) - e = this._mark(e) + return path.join(opts.dir || tmpDir, name); +} - if (this.absolute) - e = abs +/** + * Gets a temporary file name. + * + * @param {(Options|tmpNameCallback)} options options or callback + * @param {?tmpNameCallback} callback the callback function + */ +function tmpName(options, callback) { + var + args = _parseArguments(options, callback), + opts = args[0], + cb = args[1], + tries = !isBlank(opts.name) ? 1 : opts.tries || DEFAULT_TRIES; - if (this.matches[index][e]) - return + /* istanbul ignore else */ + if (isNaN(tries) || tries < 0) + return cb(new Error('Invalid tries')); - if (this.nodir) { - var c = this.cache[abs] - if (c === 'DIR' || Array.isArray(c)) - return - } + /* istanbul ignore else */ + if (opts.template && !opts.template.match(TEMPLATE_PATTERN)) + return cb(new Error('Invalid template provided')); - this.matches[index][e] = true + (function _getUniqueName() { + try { + const name = _generateTmpName(opts); - var st = this.statCache[abs] - if (st) - this.emit('stat', e, st) - - this.emit('match', e) -} + // check whether the path exists then retry if needed + fs.stat(name, function (err) { + /* istanbul ignore else */ + if (!err) { + /* istanbul ignore else */ + if (tries-- > 0) return _getUniqueName(); -Glob.prototype._readdirInGlobStar = function (abs, cb) { - if (this.aborted) - return + return cb(new Error('Could not get a unique tmp filename, max tries reached ' + name)); + } - // follow all symlinked directories forever - // just proceed as if this is a non-globstar situation - if (this.follow) - return this._readdir(abs, false, cb) + cb(null, name); + }); + } catch (err) { + cb(err); + } + }()); +} - var lstatkey = 'lstat\0' + abs - var self = this - var lstatcb = inflight(lstatkey, lstatcb_) +/** + * Synchronous version of tmpName. + * + * @param {Object} options + * @returns {string} the generated random name + * @throws {Error} if the options are invalid or could not generate a filename + */ +function tmpNameSync(options) { + var + args = _parseArguments(options), + opts = args[0], + tries = !isBlank(opts.name) ? 1 : opts.tries || DEFAULT_TRIES; - if (lstatcb) - fs.lstat(abs, lstatcb) + /* istanbul ignore else */ + if (isNaN(tries) || tries < 0) + throw new Error('Invalid tries'); - function lstatcb_ (er, lstat) { - if (er && er.code === 'ENOENT') - return cb() + /* istanbul ignore else */ + if (opts.template && !opts.template.match(TEMPLATE_PATTERN)) + throw new Error('Invalid template provided'); - var isSym = lstat && lstat.isSymbolicLink() - self.symlinks[abs] = isSym + do { + const name = _generateTmpName(opts); + try { + fs.statSync(name); + } catch (e) { + return name; + } + } while (tries-- > 0); - // If it's not a symlink or a dir, then it's definitely a regular file. - // don't bother doing a readdir in that case. - if (!isSym && lstat && !lstat.isDirectory()) { - self.cache[abs] = 'FILE' - cb() - } else - self._readdir(abs, false, cb) - } + throw new Error('Could not get a unique tmp filename, max tries reached'); } -Glob.prototype._readdir = function (abs, inGlobStar, cb) { - if (this.aborted) - return +/** + * Creates and opens a temporary file. + * + * @param {(Options|fileCallback)} options the config options or the callback function + * @param {?fileCallback} callback + */ +function file(options, callback) { + var + args = _parseArguments(options, callback), + opts = args[0], + cb = args[1]; - cb = inflight('readdir\0'+abs+'\0'+inGlobStar, cb) - if (!cb) - return + // gets a temporary filename + tmpName(opts, function _tmpNameCreated(err, name) { + /* istanbul ignore else */ + if (err) return cb(err); - //console.error('RD %j %j', +inGlobStar, abs) - if (inGlobStar && !ownProp(this.symlinks, abs)) - return this._readdirInGlobStar(abs, cb) + // create and open the file + fs.open(name, CREATE_FLAGS, opts.mode || FILE_MODE, function _fileCreated(err, fd) { + /* istanbul ignore else */ + if (err) return cb(err); - if (ownProp(this.cache, abs)) { - var c = this.cache[abs] - if (!c || c === 'FILE') - return cb() + if (opts.discardDescriptor) { + return fs.close(fd, function _discardCallback(err) { + /* istanbul ignore else */ + if (err) { + // Low probability, and the file exists, so this could be + // ignored. If it isn't we certainly need to unlink the + // file, and if that fails too its error is more + // important. + try { + fs.unlinkSync(name); + } catch (e) { + if (!isENOENT(e)) { + err = e; + } + } + return cb(err); + } + cb(null, name, undefined, _prepareTmpFileRemoveCallback(name, -1, opts)); + }); + } + /* istanbul ignore else */ + if (opts.detachDescriptor) { + return cb(null, name, fd, _prepareTmpFileRemoveCallback(name, -1, opts)); + } + cb(null, name, fd, _prepareTmpFileRemoveCallback(name, fd, opts)); + }); + }); +} - if (Array.isArray(c)) - return cb(null, c) +/** + * Synchronous version of file. + * + * @param {Options} options + * @returns {FileSyncObject} object consists of name, fd and removeCallback + * @throws {Error} if cannot create a file + */ +function fileSync(options) { + var + args = _parseArguments(options), + opts = args[0]; + + const discardOrDetachDescriptor = opts.discardDescriptor || opts.detachDescriptor; + const name = tmpNameSync(opts); + var fd = fs.openSync(name, CREATE_FLAGS, opts.mode || FILE_MODE); + /* istanbul ignore else */ + if (opts.discardDescriptor) { + fs.closeSync(fd); + fd = undefined; } - var self = this - fs.readdir(abs, readdirCb(this, abs, cb)) + return { + name: name, + fd: fd, + removeCallback: _prepareTmpFileRemoveCallback(name, discardOrDetachDescriptor ? -1 : fd, opts) + }; } -function readdirCb (self, abs, cb) { - return function (er, entries) { - if (er) - self._readdirError(abs, er, cb) - else - self._readdirEntries(abs, entries, cb) - } -} +/** + * Creates a temporary directory. + * + * @param {(Options|dirCallback)} options the options or the callback function + * @param {?dirCallback} callback + */ +function dir(options, callback) { + var + args = _parseArguments(options, callback), + opts = args[0], + cb = args[1]; -Glob.prototype._readdirEntries = function (abs, entries, cb) { - if (this.aborted) - return + // gets a temporary filename + tmpName(opts, function _tmpNameCreated(err, name) { + /* istanbul ignore else */ + if (err) return cb(err); - // if we haven't asked to stat everything, then just - // assume that everything in there exists, so we can avoid - // having to stat it a second time. - if (!this.mark && !this.stat) { - for (var i = 0; i < entries.length; i ++) { - var e = entries[i] - if (abs === '/') - e = abs + e - else - e = abs + '/' + e - this.cache[e] = true - } - } + // create the directory + fs.mkdir(name, opts.mode || DIR_MODE, function _dirCreated(err) { + /* istanbul ignore else */ + if (err) return cb(err); - this.cache[abs] = entries - return cb(null, entries) + cb(null, name, _prepareTmpDirRemoveCallback(name, opts)); + }); + }); } -Glob.prototype._readdirError = function (f, er, cb) { - if (this.aborted) - return +/** + * Synchronous version of dir. + * + * @param {Options} options + * @returns {DirSyncObject} object consists of name and removeCallback + * @throws {Error} if it cannot create a directory + */ +function dirSync(options) { + var + args = _parseArguments(options), + opts = args[0]; - // handle errors, and cache the information - switch (er.code) { - case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205 - case 'ENOTDIR': // totally normal. means it *does* exist. - var abs = this._makeAbs(f) - this.cache[abs] = 'FILE' - if (abs === this.cwdAbs) { - var error = new Error(er.code + ' invalid cwd ' + this.cwd) - error.path = this.cwd - error.code = er.code - this.emit('error', error) - this.abort() - } - break + const name = tmpNameSync(opts); + fs.mkdirSync(name, opts.mode || DIR_MODE); - case 'ENOENT': // not terribly unusual - case 'ELOOP': - case 'ENAMETOOLONG': - case 'UNKNOWN': - this.cache[this._makeAbs(f)] = false - break + return { + name: name, + removeCallback: _prepareTmpDirRemoveCallback(name, opts) + }; +} - default: // some unusual error. Treat as failure. - this.cache[this._makeAbs(f)] = false - if (this.strict) { - this.emit('error', er) - // If the error is handled, then we abort - // if not, we threw out of here - this.abort() - } - if (!this.silent) - console.error('glob error', er) - break +/** + * Removes files asynchronously. + * + * @param {Object} fdPath + * @param {Function} next + * @private + */ +function _removeFileAsync(fdPath, next) { + const _handler = function (err) { + if (err && !isENOENT(err)) { + // reraise any unanticipated error + return next(err); + } + next(); } - return cb() + if (0 <= fdPath[0]) + fs.close(fdPath[0], function (err) { + fs.unlink(fdPath[1], _handler); + }); + else fs.unlink(fdPath[1], _handler); } -Glob.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar, cb) { - var self = this - this._readdir(abs, inGlobStar, function (er, entries) { - self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb) - }) +/** + * Removes files synchronously. + * + * @param {Object} fdPath + * @private + */ +function _removeFileSync(fdPath) { + try { + if (0 <= fdPath[0]) fs.closeSync(fdPath[0]); + } catch (e) { + // reraise any unanticipated error + if (!isEBADF(e) && !isENOENT(e)) throw e; + } finally { + try { + fs.unlinkSync(fdPath[1]); + } + catch (e) { + // reraise any unanticipated error + if (!isENOENT(e)) throw e; + } + } } +/** + * Prepares the callback for removal of the temporary file. + * + * @param {string} name the path of the file + * @param {number} fd file descriptor + * @param {Object} opts + * @returns {fileCallback} + * @private + */ +function _prepareTmpFileRemoveCallback(name, fd, opts) { + const removeCallbackSync = _prepareRemoveCallback(_removeFileSync, [fd, name]); + const removeCallback = _prepareRemoveCallback(_removeFileAsync, [fd, name], removeCallbackSync); -Glob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) { - //console.error('pgs2', prefix, remain[0], entries) - - // no entries means not a dir, so it can never have matches - // foo.txt/** doesn't match foo.txt - if (!entries) - return cb() - - // test without the globstar, and with every child both below - // and replacing the globstar. - var remainWithoutGlobStar = remain.slice(1) - var gspref = prefix ? [ prefix ] : [] - var noGlobStar = gspref.concat(remainWithoutGlobStar) - - // the noGlobStar pattern exits the inGlobStar state - this._process(noGlobStar, index, false, cb) - - var isSym = this.symlinks[abs] - var len = entries.length - - // If it's a symlink, and we're in a globstar, then stop - if (isSym && inGlobStar) - return cb() + if (!opts.keep) _removeObjects.unshift(removeCallbackSync); - for (var i = 0; i < len; i++) { - var e = entries[i] - if (e.charAt(0) === '.' && !this.dot) - continue + return removeCallback; +} - // these two cases enter the inGlobStar state - var instead = gspref.concat(entries[i], remainWithoutGlobStar) - this._process(instead, index, true, cb) +/** + * Simple wrapper for rimraf. + * + * @param {string} dirPath + * @param {Function} next + * @private + */ +function _rimrafRemoveDirWrapper(dirPath, next) { + rimraf(dirPath, next); +} - var below = gspref.concat(entries[i], remain) - this._process(below, index, true, cb) +/** + * Simple wrapper for rimraf.sync. + * + * @param {string} dirPath + * @private + */ +function _rimrafRemoveDirSyncWrapper(dirPath, next) { + try { + return next(null, rimraf.sync(dirPath)); + } catch (err) { + return next(err); } - - cb() } -Glob.prototype._processSimple = function (prefix, index, cb) { - // XXX review this. Shouldn't it be doing the mounting etc - // before doing stat? kinda weird? - var self = this - this._stat(prefix, function (er, exists) { - self._processSimple2(prefix, index, er, exists, cb) - }) +/** + * Prepares the callback for removal of the temporary directory. + * + * @param {string} name + * @param {Object} opts + * @returns {Function} the callback + * @private + */ +function _prepareTmpDirRemoveCallback(name, opts) { + const removeFunction = opts.unsafeCleanup ? _rimrafRemoveDirWrapper : fs.rmdir.bind(fs); + const removeFunctionSync = opts.unsafeCleanup ? _rimrafRemoveDirSyncWrapper : fs.rmdirSync.bind(fs); + const removeCallbackSync = _prepareRemoveCallback(removeFunctionSync, name); + const removeCallback = _prepareRemoveCallback(removeFunction, name, removeCallbackSync); + if (!opts.keep) _removeObjects.unshift(removeCallbackSync); + + return removeCallback; } -Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) { - //console.error('ps2', prefix, exists) +/** + * Creates a guarded function wrapping the removeFunction call. + * + * @param {Function} removeFunction + * @param {Object} arg + * @returns {Function} + * @private + */ +function _prepareRemoveCallback(removeFunction, arg, cleanupCallbackSync) { + var called = false; - if (!this.matches[index]) - this.matches[index] = Object.create(null) + return function _cleanupCallback(next) { + next = next || function () {}; + if (!called) { + const toRemove = cleanupCallbackSync || _cleanupCallback; + const index = _removeObjects.indexOf(toRemove); + /* istanbul ignore else */ + if (index >= 0) _removeObjects.splice(index, 1); - // If it doesn't exist, then just mark the lack of results - if (!exists) - return cb() + called = true; + // sync? + if (removeFunction.length === 1) { + try { + removeFunction(arg); + return next(null); + } + catch (err) { + // if no next is provided and since we are + // in silent cleanup mode on process exit, + // we will ignore the error + return next(err); + } + } else return removeFunction(arg, next); + } else return next(new Error('cleanup callback has already been called')); + }; +} - if (prefix && isAbsolute(prefix) && !this.nomount) { - var trail = /[\/\\]$/.test(prefix) - if (prefix.charAt(0) === '/') { - prefix = path.join(this.root, prefix) - } else { - prefix = path.resolve(this.root, prefix) - if (trail) - prefix += '/' +/** + * The garbage collector. + * + * @private + */ +function _garbageCollector() { + /* istanbul ignore else */ + if (!_gracefulCleanup) return; + + // the function being called removes itself from _removeObjects, + // loop until _removeObjects is empty + while (_removeObjects.length) { + try { + _removeObjects[0](); + } catch (e) { + // already removed? } } +} - if (process.platform === 'win32') - prefix = prefix.replace(/\\/g, '/') - - // Mark this as a match - this._emitMatch(index, prefix) - cb() +/** + * Helper for testing against EBADF to compensate changes made to Node 7.x under Windows. + */ +function isEBADF(error) { + return isExpectedError(error, -EBADF, 'EBADF'); } -// Returns either 'DIR', 'FILE', or false -Glob.prototype._stat = function (f, cb) { - var abs = this._makeAbs(f) - var needDir = f.slice(-1) === '/' +/** + * Helper for testing against ENOENT to compensate changes made to Node 7.x under Windows. + */ +function isENOENT(error) { + return isExpectedError(error, -ENOENT, 'ENOENT'); +} - if (f.length > this.maxLength) - return cb() +/** + * Helper to determine whether the expected error code matches the actual code and errno, + * which will differ between the supported node versions. + * + * - Node >= 7.0: + * error.code {string} + * error.errno {string|number} any numerical value will be negated + * + * - Node >= 6.0 < 7.0: + * error.code {string} + * error.errno {number} negated + * + * - Node >= 4.0 < 6.0: introduces SystemError + * error.code {string} + * error.errno {number} negated + * + * - Node >= 0.10 < 4.0: + * error.code {number} negated + * error.errno n/a + */ +function isExpectedError(error, code, errno) { + return error.code === code || error.code === errno; +} - if (!this.stat && ownProp(this.cache, abs)) { - var c = this.cache[abs] +/** + * Helper which determines whether a string s is blank, that is undefined, or empty or null. + * + * @private + * @param {string} s + * @returns {Boolean} true whether the string s is blank, false otherwise + */ +function isBlank(s) { + return s === null || s === undefined || !s.trim(); +} - if (Array.isArray(c)) - c = 'DIR' +/** + * Sets the graceful cleanup. + */ +function setGracefulCleanup() { + _gracefulCleanup = true; +} - // It exists, but maybe not how we need it - if (!needDir || c === 'DIR') - return cb(null, c) +/** + * Returns the currently configured tmp dir from os.tmpdir(). + * + * @private + * @returns {string} the currently configured tmp dir + */ +function _getTmpDir() { + return os.tmpdir(); +} - if (needDir && c === 'FILE') - return cb() +/** + * If there are multiple different versions of tmp in place, make sure that + * we recognize the old listeners. + * + * @param {Function} listener + * @private + * @returns {Boolean} true whether listener is a legacy listener + */ +function _is_legacy_listener(listener) { + return (listener.name === '_exit' || listener.name === '_uncaughtExceptionThrown') + && listener.toString().indexOf('_garbageCollector();') > -1; +} - // otherwise we have to stat, because maybe c=true - // if we know it exists, but not what it is. - } +/** + * Safely install SIGINT listener. + * + * NOTE: this will only work on OSX and Linux. + * + * @private + */ +function _safely_install_sigint_listener() { - var exists - var stat = this.statCache[abs] - if (stat !== undefined) { - if (stat === false) - return cb(null, stat) - else { - var type = stat.isDirectory() ? 'DIR' : 'FILE' - if (needDir && type === 'FILE') - return cb() - else - return cb(null, type, stat) + const listeners = process.listeners(SIGINT); + const existingListeners = []; + for (let i = 0, length = listeners.length; i < length; i++) { + const lstnr = listeners[i]; + /* istanbul ignore else */ + if (lstnr.name === '_tmp$sigint_listener') { + existingListeners.push(lstnr); + process.removeListener(SIGINT, lstnr); } } + process.on(SIGINT, function _tmp$sigint_listener(doExit) { + for (let i = 0, length = existingListeners.length; i < length; i++) { + // let the existing listener do the garbage collection (e.g. jest sandbox) + try { + existingListeners[i](false); + } catch (err) { + // ignore + } + } + try { + // force the garbage collector even it is called again in the exit listener + _garbageCollector(); + } finally { + if (!!doExit) { + process.exit(0); + } + } + }); +} - var self = this - var statcb = inflight('stat\0' + abs, lstatcb_) - if (statcb) - fs.lstat(abs, statcb) +/** + * Safely install process exit listener. + * + * @private + */ +function _safely_install_exit_listener() { + const listeners = process.listeners(EXIT); - function lstatcb_ (er, lstat) { - if (lstat && lstat.isSymbolicLink()) { - // If it's a symlink, then treat it as the target, unless - // the target does not exist, then treat it as a file. - return fs.stat(abs, function (er, stat) { - if (er) - self._stat2(f, abs, null, lstat, cb) - else - self._stat2(f, abs, er, stat, cb) - }) - } else { - self._stat2(f, abs, er, lstat, cb) + // collect any existing listeners + const existingListeners = []; + for (let i = 0, length = listeners.length; i < length; i++) { + const lstnr = listeners[i]; + /* istanbul ignore else */ + // TODO: remove support for legacy listeners once release 1.0.0 is out + if (lstnr.name === '_tmp$safe_listener' || _is_legacy_listener(lstnr)) { + // we must forget about the uncaughtException listener, hopefully it is ours + if (lstnr.name !== '_uncaughtExceptionThrown') { + existingListeners.push(lstnr); + } + process.removeListener(EXIT, lstnr); } } + // TODO: what was the data parameter good for? + process.addListener(EXIT, function _tmp$safe_listener(data) { + for (let i = 0, length = existingListeners.length; i < length; i++) { + // let the existing listener do the garbage collection (e.g. jest sandbox) + try { + existingListeners[i](data); + } catch (err) { + // ignore + } + } + _garbageCollector(); + }); } -Glob.prototype._stat2 = function (f, abs, er, stat, cb) { - if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) { - this.statCache[abs] = false - return cb() - } +_safely_install_exit_listener(); +_safely_install_sigint_listener(); - var needDir = f.slice(-1) === '/' - this.statCache[abs] = stat +/** + * Configuration options. + * + * @typedef {Object} Options + * @property {?number} tries the number of tries before give up the name generation + * @property {?string} template the "mkstemp" like filename template + * @property {?string} name fix name + * @property {?string} dir the tmp directory to use + * @property {?string} prefix prefix for the generated name + * @property {?string} postfix postfix for the generated name + * @property {?boolean} unsafeCleanup recursively removes the created temporary directory, even when it's not empty + */ - if (abs.slice(-1) === '/' && stat && !stat.isDirectory()) - return cb(null, false, stat) +/** + * @typedef {Object} FileSyncObject + * @property {string} name the name of the file + * @property {string} fd the file descriptor + * @property {fileCallback} removeCallback the callback function to remove the file + */ - var c = true - if (stat) - c = stat.isDirectory() ? 'DIR' : 'FILE' - this.cache[abs] = this.cache[abs] || c +/** + * @typedef {Object} DirSyncObject + * @property {string} name the name of the directory + * @property {fileCallback} removeCallback the callback function to remove the directory + */ - if (needDir && c === 'FILE') - return cb() +/** + * @callback tmpNameCallback + * @param {?Error} err the error object if anything goes wrong + * @param {string} name the temporary file name + */ - return cb(null, c, stat) -} +/** + * @callback fileCallback + * @param {?Error} err the error object if anything goes wrong + * @param {string} name the temporary file name + * @param {number} fd the file descriptor + * @param {cleanupCallback} fn the cleanup callback function + */ +/** + * @callback dirCallback + * @param {?Error} err the error object if anything goes wrong + * @param {string} name the temporary file name + * @param {cleanupCallback} fn the cleanup callback function + */ -/***/ }), +/** + * Removes the temporary created file or directory. + * + * @callback cleanupCallback + * @param {simpleCallback} [next] function to call after entry was removed + */ -/***/ 141: -/***/ (function(__unusedmodule, exports, __webpack_require__) { +/** + * Callback function for function composition. + * @see {@link https://github.com/raszi/node-tmp/issues/57|raszi/node-tmp#57} + * + * @callback simpleCallback + */ -"use strict"; +// exporting all the needed methods +// evaluate os.tmpdir() lazily, mainly for simplifying testing but it also will +// allow users to reconfigure the temporary directory +Object.defineProperty(module.exports, 'tmpdir', { + enumerable: true, + configurable: false, + get: function () { + return _getTmpDir(); + } +}); -var net = __webpack_require__(631); -var tls = __webpack_require__(16); -var http = __webpack_require__(605); -var https = __webpack_require__(211); -var events = __webpack_require__(614); -var assert = __webpack_require__(357); -var util = __webpack_require__(669); +module.exports.dir = dir; +module.exports.dirSync = dirSync; +module.exports.file = file; +module.exports.fileSync = fileSync; -exports.httpOverHttp = httpOverHttp; -exports.httpsOverHttp = httpsOverHttp; -exports.httpOverHttps = httpOverHttps; -exports.httpsOverHttps = httpsOverHttps; +module.exports.tmpName = tmpName; +module.exports.tmpNameSync = tmpNameSync; - -function httpOverHttp(options) { - var agent = new TunnelingAgent(options); - agent.request = http.request; - return agent; -} - -function httpsOverHttp(options) { - var agent = new TunnelingAgent(options); - agent.request = http.request; - agent.createSocket = createSecureSocket; - agent.defaultPort = 443; - return agent; -} - -function httpOverHttps(options) { - var agent = new TunnelingAgent(options); - agent.request = https.request; - return agent; -} - -function httpsOverHttps(options) { - var agent = new TunnelingAgent(options); - agent.request = https.request; - agent.createSocket = createSecureSocket; - agent.defaultPort = 443; - return agent; -} - - -function TunnelingAgent(options) { - var self = this; - self.options = options || {}; - self.proxyOptions = self.options.proxy || {}; - self.maxSockets = self.options.maxSockets || http.Agent.defaultMaxSockets; - self.requests = []; - self.sockets = []; - - self.on('free', function onFree(socket, host, port, localAddress) { - var options = toOptions(host, port, localAddress); - for (var i = 0, len = self.requests.length; i < len; ++i) { - var pending = self.requests[i]; - if (pending.host === options.host && pending.port === options.port) { - // Detect the request to connect same origin server, - // reuse the connection. - self.requests.splice(i, 1); - pending.request.onSocket(socket); - return; - } - } - socket.destroy(); - self.removeSocket(socket); - }); -} -util.inherits(TunnelingAgent, events.EventEmitter); - -TunnelingAgent.prototype.addRequest = function addRequest(req, host, port, localAddress) { - var self = this; - var options = mergeOptions({request: req}, self.options, toOptions(host, port, localAddress)); - - if (self.sockets.length >= this.maxSockets) { - // We are over limit so we'll add it to the queue. - self.requests.push(options); - return; - } - - // If we are under maxSockets create a new one. - self.createSocket(options, function(socket) { - socket.on('free', onFree); - socket.on('close', onCloseOrRemove); - socket.on('agentRemove', onCloseOrRemove); - req.onSocket(socket); - - function onFree() { - self.emit('free', socket, options); - } - - function onCloseOrRemove(err) { - self.removeSocket(socket); - socket.removeListener('free', onFree); - socket.removeListener('close', onCloseOrRemove); - socket.removeListener('agentRemove', onCloseOrRemove); - } - }); -}; - -TunnelingAgent.prototype.createSocket = function createSocket(options, cb) { - var self = this; - var placeholder = {}; - self.sockets.push(placeholder); - - var connectOptions = mergeOptions({}, self.proxyOptions, { - method: 'CONNECT', - path: options.host + ':' + options.port, - agent: false, - headers: { - host: options.host + ':' + options.port - } - }); - if (options.localAddress) { - connectOptions.localAddress = options.localAddress; - } - if (connectOptions.proxyAuth) { - connectOptions.headers = connectOptions.headers || {}; - connectOptions.headers['Proxy-Authorization'] = 'Basic ' + - new Buffer(connectOptions.proxyAuth).toString('base64'); - } - - debug('making CONNECT request'); - var connectReq = self.request(connectOptions); - connectReq.useChunkedEncodingByDefault = false; // for v0.6 - connectReq.once('response', onResponse); // for v0.6 - connectReq.once('upgrade', onUpgrade); // for v0.6 - connectReq.once('connect', onConnect); // for v0.7 or later - connectReq.once('error', onError); - connectReq.end(); - - function onResponse(res) { - // Very hacky. This is necessary to avoid http-parser leaks. - res.upgrade = true; - } - - function onUpgrade(res, socket, head) { - // Hacky. - process.nextTick(function() { - onConnect(res, socket, head); - }); - } - - function onConnect(res, socket, head) { - connectReq.removeAllListeners(); - socket.removeAllListeners(); - - if (res.statusCode !== 200) { - debug('tunneling socket could not be established, statusCode=%d', - res.statusCode); - socket.destroy(); - var error = new Error('tunneling socket could not be established, ' + - 'statusCode=' + res.statusCode); - error.code = 'ECONNRESET'; - options.request.emit('error', error); - self.removeSocket(placeholder); - return; - } - if (head.length > 0) { - debug('got illegal response body from proxy'); - socket.destroy(); - var error = new Error('got illegal response body from proxy'); - error.code = 'ECONNRESET'; - options.request.emit('error', error); - self.removeSocket(placeholder); - return; - } - debug('tunneling connection has established'); - self.sockets[self.sockets.indexOf(placeholder)] = socket; - return cb(socket); - } - - function onError(cause) { - connectReq.removeAllListeners(); - - debug('tunneling socket could not be established, cause=%s\n', - cause.message, cause.stack); - var error = new Error('tunneling socket could not be established, ' + - 'cause=' + cause.message); - error.code = 'ECONNRESET'; - options.request.emit('error', error); - self.removeSocket(placeholder); - } -}; - -TunnelingAgent.prototype.removeSocket = function removeSocket(socket) { - var pos = this.sockets.indexOf(socket) - if (pos === -1) { - return; - } - this.sockets.splice(pos, 1); - - var pending = this.requests.shift(); - if (pending) { - // If we have pending requests and a socket gets closed a new one - // needs to be created to take over in the pool for the one that closed. - this.createSocket(pending, function(socket) { - pending.request.onSocket(socket); - }); - } -}; - -function createSecureSocket(options, cb) { - var self = this; - TunnelingAgent.prototype.createSocket.call(self, options, function(socket) { - var hostHeader = options.request.getHeader('host'); - var tlsOptions = mergeOptions({}, self.options, { - socket: socket, - servername: hostHeader ? hostHeader.replace(/:.*$/, '') : options.host - }); - - // 0 is dummy port for v0.6 - var secureSocket = tls.connect(0, tlsOptions); - self.sockets[self.sockets.indexOf(socket)] = secureSocket; - cb(secureSocket); - }); -} - - -function toOptions(host, port, localAddress) { - if (typeof host === 'string') { // since v0.10 - return { - host: host, - port: port, - localAddress: localAddress - }; - } - return host; // for v0.11 or later -} - -function mergeOptions(target) { - for (var i = 1, len = arguments.length; i < len; ++i) { - var overrides = arguments[i]; - if (typeof overrides === 'object') { - var keys = Object.keys(overrides); - for (var j = 0, keyLen = keys.length; j < keyLen; ++j) { - var k = keys[j]; - if (overrides[k] !== undefined) { - target[k] = overrides[k]; - } - } - } - } - return target; -} - - -var debug; -if (process.env.NODE_DEBUG && /\btunnel\b/.test(process.env.NODE_DEBUG)) { - debug = function() { - var args = Array.prototype.slice.call(arguments); - if (typeof args[0] === 'string') { - args[0] = 'TUNNEL: ' + args[0]; - } else { - args.unshift('TUNNEL:'); - } - console.error.apply(console, args); - } -} else { - debug = function() {}; -} -exports.debug = debug; // for test +module.exports.setGracefulCleanup = setGracefulCleanup; /***/ }), @@ -2689,7 +2661,7 @@ var fs = __webpack_require__(747) var rp = __webpack_require__(302) var minimatch = __webpack_require__(93) var Minimatch = minimatch.Minimatch -var Glob = __webpack_require__(120).Glob +var Glob = __webpack_require__(402).Glob var util = __webpack_require__(669) var path = __webpack_require__(622) var assert = __webpack_require__(357) @@ -4188,768 +4160,796 @@ exports.getRetentionDays = getRetentionDays; /***/ 402: /***/ (function(module, __unusedexports, __webpack_require__) { -/*! - * Tmp - * - * Copyright (c) 2011-2017 KARASZI Istvan - * - * MIT Licensed - */ - -/* - * Module dependencies. - */ -const fs = __webpack_require__(747); -const os = __webpack_require__(87); -const path = __webpack_require__(622); -const crypto = __webpack_require__(417); -const _c = fs.constants && os.constants ? - { fs: fs.constants, os: os.constants } : - process.binding('constants'); -const rimraf = __webpack_require__(569); - -/* - * The working inner variables. - */ -const - // the random characters to choose from - RANDOM_CHARS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz', - - TEMPLATE_PATTERN = /XXXXXX/, - - DEFAULT_TRIES = 3, +// Approach: +// +// 1. Get the minimatch set +// 2. For each pattern in the set, PROCESS(pattern, false) +// 3. Store matches per-set, then uniq them +// +// PROCESS(pattern, inGlobStar) +// Get the first [n] items from pattern that are all strings +// Join these together. This is PREFIX. +// If there is no more remaining, then stat(PREFIX) and +// add to matches if it succeeds. END. +// +// If inGlobStar and PREFIX is symlink and points to dir +// set ENTRIES = [] +// else readdir(PREFIX) as ENTRIES +// If fail, END +// +// with ENTRIES +// If pattern[n] is GLOBSTAR +// // handle the case where the globstar match is empty +// // by pruning it out, and testing the resulting pattern +// PROCESS(pattern[0..n] + pattern[n+1 .. $], false) +// // handle other cases. +// for ENTRY in ENTRIES (not dotfiles) +// // attach globstar + tail onto the entry +// // Mark that this entry is a globstar match +// PROCESS(pattern[0..n] + ENTRY + pattern[n .. $], true) +// +// else // not globstar +// for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot) +// Test ENTRY against pattern[n] +// If fails, continue +// If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $]) +// +// Caveat: +// Cache all stats and readdirs results to minimize syscall. Since all +// we ever care about is existence and directory-ness, we can just keep +// `true` for files, and [children,...] for directories, or `false` for +// things that don't exist. - CREATE_FLAGS = (_c.O_CREAT || _c.fs.O_CREAT) | (_c.O_EXCL || _c.fs.O_EXCL) | (_c.O_RDWR || _c.fs.O_RDWR), +module.exports = glob - EBADF = _c.EBADF || _c.os.errno.EBADF, - ENOENT = _c.ENOENT || _c.os.errno.ENOENT, +var fs = __webpack_require__(747) +var rp = __webpack_require__(302) +var minimatch = __webpack_require__(93) +var Minimatch = minimatch.Minimatch +var inherits = __webpack_require__(689) +var EE = __webpack_require__(614).EventEmitter +var path = __webpack_require__(622) +var assert = __webpack_require__(357) +var isAbsolute = __webpack_require__(681) +var globSync = __webpack_require__(245) +var common = __webpack_require__(856) +var alphasort = common.alphasort +var alphasorti = common.alphasorti +var setopts = common.setopts +var ownProp = common.ownProp +var inflight = __webpack_require__(674) +var util = __webpack_require__(669) +var childrenIgnored = common.childrenIgnored +var isIgnored = common.isIgnored - DIR_MODE = 448 /* 0o700 */, - FILE_MODE = 384 /* 0o600 */, +var once = __webpack_require__(49) - EXIT = 'exit', +function glob (pattern, options, cb) { + if (typeof options === 'function') cb = options, options = {} + if (!options) options = {} - SIGINT = 'SIGINT', + if (options.sync) { + if (cb) + throw new TypeError('callback provided to sync glob') + return globSync(pattern, options) + } - // this will hold the objects need to be removed on exit - _removeObjects = []; + return new Glob(pattern, options, cb) +} -var - _gracefulCleanup = false; +glob.sync = globSync +var GlobSync = glob.GlobSync = globSync.GlobSync -/** - * Random name generator based on crypto. - * Adapted from http://blog.tompawlak.org/how-to-generate-random-values-nodejs-javascript - * - * @param {number} howMany - * @returns {string} the generated random name - * @private - */ -function _randomChars(howMany) { - var - value = [], - rnd = null; +// old api surface +glob.glob = glob - // make sure that we do not fail because we ran out of entropy - try { - rnd = crypto.randomBytes(howMany); - } catch (e) { - rnd = crypto.pseudoRandomBytes(howMany); +function extend (origin, add) { + if (add === null || typeof add !== 'object') { + return origin } - for (var i = 0; i < howMany; i++) { - value.push(RANDOM_CHARS[rnd[i] % RANDOM_CHARS.length]); + var keys = Object.keys(add) + var i = keys.length + while (i--) { + origin[keys[i]] = add[keys[i]] } - - return value.join(''); + return origin } -/** - * Checks whether the `obj` parameter is defined or not. - * - * @param {Object} obj - * @returns {boolean} true if the object is undefined - * @private - */ -function _isUndefined(obj) { - return typeof obj === 'undefined'; +glob.hasMagic = function (pattern, options_) { + var options = extend({}, options_) + options.noprocess = true + + var g = new Glob(pattern, options) + var set = g.minimatch.set + + if (!pattern) + return false + + if (set.length > 1) + return true + + for (var j = 0; j < set[0].length; j++) { + if (typeof set[0][j] !== 'string') + return true + } + + return false } -/** - * Parses the function arguments. - * - * This function helps to have optional arguments. - * - * @param {(Options|Function)} options - * @param {Function} callback - * @returns {Array} parsed arguments - * @private - */ -function _parseArguments(options, callback) { - /* istanbul ignore else */ +glob.Glob = Glob +inherits(Glob, EE) +function Glob (pattern, options, cb) { if (typeof options === 'function') { - return [{}, options]; + cb = options + options = null } - /* istanbul ignore else */ - if (_isUndefined(options)) { - return [{}, callback]; + if (options && options.sync) { + if (cb) + throw new TypeError('callback provided to sync glob') + return new GlobSync(pattern, options) } - return [options, callback]; -} + if (!(this instanceof Glob)) + return new Glob(pattern, options, cb) -/** - * Generates a new temporary name. - * - * @param {Object} opts - * @returns {string} the new random name according to opts - * @private - */ -function _generateTmpName(opts) { + setopts(this, pattern, options) + this._didRealPath = false - const tmpDir = _getTmpDir(); + // process each pattern in the minimatch set + var n = this.minimatch.set.length - // fail early on missing tmp dir - if (isBlank(opts.dir) && isBlank(tmpDir)) { - throw new Error('No tmp dir specified'); - } + // The matches are stored as {: true,...} so that + // duplicates are automagically pruned. + // Later, we do an Object.keys() on these. + // Keep them as a list so we can fill in when nonull is set. + this.matches = new Array(n) - /* istanbul ignore else */ - if (!isBlank(opts.name)) { - return path.join(opts.dir || tmpDir, opts.name); + if (typeof cb === 'function') { + cb = once(cb) + this.on('error', cb) + this.on('end', function (matches) { + cb(null, matches) + }) } - // mkstemps like template - // opts.template has already been guarded in tmpName() below - /* istanbul ignore else */ - if (opts.template) { - var template = opts.template; - // make sure that we prepend the tmp path if none was given - /* istanbul ignore else */ - if (path.basename(template) === template) - template = path.join(opts.dir || tmpDir, template); - return template.replace(TEMPLATE_PATTERN, _randomChars(6)); - } + var self = this + this._processing = 0 - // prefix and postfix - const name = [ - (isBlank(opts.prefix) ? 'tmp-' : opts.prefix), - process.pid, - _randomChars(12), - (opts.postfix ? opts.postfix : '') - ].join(''); + this._emitQueue = [] + this._processQueue = [] + this.paused = false - return path.join(opts.dir || tmpDir, name); -} + if (this.noprocess) + return this -/** - * Gets a temporary file name. - * - * @param {(Options|tmpNameCallback)} options options or callback - * @param {?tmpNameCallback} callback the callback function - */ -function tmpName(options, callback) { - var - args = _parseArguments(options, callback), - opts = args[0], - cb = args[1], - tries = !isBlank(opts.name) ? 1 : opts.tries || DEFAULT_TRIES; + if (n === 0) + return done() - /* istanbul ignore else */ - if (isNaN(tries) || tries < 0) - return cb(new Error('Invalid tries')); - - /* istanbul ignore else */ - if (opts.template && !opts.template.match(TEMPLATE_PATTERN)) - return cb(new Error('Invalid template provided')); + var sync = true + for (var i = 0; i < n; i ++) { + this._process(this.minimatch.set[i], i, false, done) + } + sync = false - (function _getUniqueName() { - try { - const name = _generateTmpName(opts); + function done () { + --self._processing + if (self._processing <= 0) { + if (sync) { + process.nextTick(function () { + self._finish() + }) + } else { + self._finish() + } + } + } +} - // check whether the path exists then retry if needed - fs.stat(name, function (err) { - /* istanbul ignore else */ - if (!err) { - /* istanbul ignore else */ - if (tries-- > 0) return _getUniqueName(); +Glob.prototype._finish = function () { + assert(this instanceof Glob) + if (this.aborted) + return - return cb(new Error('Could not get a unique tmp filename, max tries reached ' + name)); - } + if (this.realpath && !this._didRealpath) + return this._realpath() - cb(null, name); - }); - } catch (err) { - cb(err); - } - }()); + common.finish(this) + this.emit('end', this.found) } -/** - * Synchronous version of tmpName. - * - * @param {Object} options - * @returns {string} the generated random name - * @throws {Error} if the options are invalid or could not generate a filename - */ -function tmpNameSync(options) { - var - args = _parseArguments(options), - opts = args[0], - tries = !isBlank(opts.name) ? 1 : opts.tries || DEFAULT_TRIES; +Glob.prototype._realpath = function () { + if (this._didRealpath) + return - /* istanbul ignore else */ - if (isNaN(tries) || tries < 0) - throw new Error('Invalid tries'); + this._didRealpath = true - /* istanbul ignore else */ - if (opts.template && !opts.template.match(TEMPLATE_PATTERN)) - throw new Error('Invalid template provided'); + var n = this.matches.length + if (n === 0) + return this._finish() - do { - const name = _generateTmpName(opts); - try { - fs.statSync(name); - } catch (e) { - return name; - } - } while (tries-- > 0); + var self = this + for (var i = 0; i < this.matches.length; i++) + this._realpathSet(i, next) - throw new Error('Could not get a unique tmp filename, max tries reached'); + function next () { + if (--n === 0) + self._finish() + } } -/** - * Creates and opens a temporary file. - * - * @param {(Options|fileCallback)} options the config options or the callback function - * @param {?fileCallback} callback - */ -function file(options, callback) { - var - args = _parseArguments(options, callback), - opts = args[0], - cb = args[1]; +Glob.prototype._realpathSet = function (index, cb) { + var matchset = this.matches[index] + if (!matchset) + return cb() - // gets a temporary filename - tmpName(opts, function _tmpNameCreated(err, name) { - /* istanbul ignore else */ - if (err) return cb(err); + var found = Object.keys(matchset) + var self = this + var n = found.length - // create and open the file - fs.open(name, CREATE_FLAGS, opts.mode || FILE_MODE, function _fileCreated(err, fd) { - /* istanbul ignore else */ - if (err) return cb(err); + if (n === 0) + return cb() - if (opts.discardDescriptor) { - return fs.close(fd, function _discardCallback(err) { - /* istanbul ignore else */ - if (err) { - // Low probability, and the file exists, so this could be - // ignored. If it isn't we certainly need to unlink the - // file, and if that fails too its error is more - // important. - try { - fs.unlinkSync(name); - } catch (e) { - if (!isENOENT(e)) { - err = e; - } - } - return cb(err); - } - cb(null, name, undefined, _prepareTmpFileRemoveCallback(name, -1, opts)); - }); - } - /* istanbul ignore else */ - if (opts.detachDescriptor) { - return cb(null, name, fd, _prepareTmpFileRemoveCallback(name, -1, opts)); + var set = this.matches[index] = Object.create(null) + found.forEach(function (p, i) { + // If there's a problem with the stat, then it means that + // one or more of the links in the realpath couldn't be + // resolved. just return the abs value in that case. + p = self._makeAbs(p) + rp.realpath(p, self.realpathCache, function (er, real) { + if (!er) + set[real] = true + else if (er.syscall === 'stat') + set[p] = true + else + self.emit('error', er) // srsly wtf right here + + if (--n === 0) { + self.matches[index] = set + cb() } - cb(null, name, fd, _prepareTmpFileRemoveCallback(name, fd, opts)); - }); - }); + }) + }) } -/** - * Synchronous version of file. - * - * @param {Options} options - * @returns {FileSyncObject} object consists of name, fd and removeCallback - * @throws {Error} if cannot create a file - */ -function fileSync(options) { - var - args = _parseArguments(options), - opts = args[0]; +Glob.prototype._mark = function (p) { + return common.mark(this, p) +} - const discardOrDetachDescriptor = opts.discardDescriptor || opts.detachDescriptor; - const name = tmpNameSync(opts); - var fd = fs.openSync(name, CREATE_FLAGS, opts.mode || FILE_MODE); - /* istanbul ignore else */ - if (opts.discardDescriptor) { - fs.closeSync(fd); - fd = undefined; - } +Glob.prototype._makeAbs = function (f) { + return common.makeAbs(this, f) +} - return { - name: name, - fd: fd, - removeCallback: _prepareTmpFileRemoveCallback(name, discardOrDetachDescriptor ? -1 : fd, opts) - }; +Glob.prototype.abort = function () { + this.aborted = true + this.emit('abort') } -/** - * Creates a temporary directory. - * - * @param {(Options|dirCallback)} options the options or the callback function - * @param {?dirCallback} callback - */ -function dir(options, callback) { - var - args = _parseArguments(options, callback), - opts = args[0], - cb = args[1]; +Glob.prototype.pause = function () { + if (!this.paused) { + this.paused = true + this.emit('pause') + } +} - // gets a temporary filename - tmpName(opts, function _tmpNameCreated(err, name) { - /* istanbul ignore else */ - if (err) return cb(err); +Glob.prototype.resume = function () { + if (this.paused) { + this.emit('resume') + this.paused = false + if (this._emitQueue.length) { + var eq = this._emitQueue.slice(0) + this._emitQueue.length = 0 + for (var i = 0; i < eq.length; i ++) { + var e = eq[i] + this._emitMatch(e[0], e[1]) + } + } + if (this._processQueue.length) { + var pq = this._processQueue.slice(0) + this._processQueue.length = 0 + for (var i = 0; i < pq.length; i ++) { + var p = pq[i] + this._processing-- + this._process(p[0], p[1], p[2], p[3]) + } + } + } +} - // create the directory - fs.mkdir(name, opts.mode || DIR_MODE, function _dirCreated(err) { - /* istanbul ignore else */ - if (err) return cb(err); +Glob.prototype._process = function (pattern, index, inGlobStar, cb) { + assert(this instanceof Glob) + assert(typeof cb === 'function') - cb(null, name, _prepareTmpDirRemoveCallback(name, opts)); - }); - }); -} + if (this.aborted) + return -/** - * Synchronous version of dir. - * - * @param {Options} options - * @returns {DirSyncObject} object consists of name and removeCallback - * @throws {Error} if it cannot create a directory - */ -function dirSync(options) { - var - args = _parseArguments(options), - opts = args[0]; - - const name = tmpNameSync(opts); - fs.mkdirSync(name, opts.mode || DIR_MODE); + this._processing++ + if (this.paused) { + this._processQueue.push([pattern, index, inGlobStar, cb]) + return + } - return { - name: name, - removeCallback: _prepareTmpDirRemoveCallback(name, opts) - }; -} + //console.error('PROCESS %d', this._processing, pattern) -/** - * Removes files asynchronously. - * - * @param {Object} fdPath - * @param {Function} next - * @private - */ -function _removeFileAsync(fdPath, next) { - const _handler = function (err) { - if (err && !isENOENT(err)) { - // reraise any unanticipated error - return next(err); - } - next(); + // Get the first [n] parts of pattern that are all strings. + var n = 0 + while (typeof pattern[n] === 'string') { + n ++ } + // now n is the index of the first one that is *not* a string. - if (0 <= fdPath[0]) - fs.close(fdPath[0], function (err) { - fs.unlink(fdPath[1], _handler); - }); - else fs.unlink(fdPath[1], _handler); -} + // see if there's anything else + var prefix + switch (n) { + // if not, then this is rather simple + case pattern.length: + this._processSimple(pattern.join('/'), index, cb) + return -/** - * Removes files synchronously. - * - * @param {Object} fdPath - * @private - */ -function _removeFileSync(fdPath) { - try { - if (0 <= fdPath[0]) fs.closeSync(fdPath[0]); - } catch (e) { - // reraise any unanticipated error - if (!isEBADF(e) && !isENOENT(e)) throw e; - } finally { - try { - fs.unlinkSync(fdPath[1]); - } - catch (e) { - // reraise any unanticipated error - if (!isENOENT(e)) throw e; - } + case 0: + // pattern *starts* with some non-trivial item. + // going to readdir(cwd), but not include the prefix in matches. + prefix = null + break + + default: + // pattern has some string bits in the front. + // whatever it starts with, whether that's 'absolute' like /foo/bar, + // or 'relative' like '../baz' + prefix = pattern.slice(0, n).join('/') + break } -} -/** - * Prepares the callback for removal of the temporary file. - * - * @param {string} name the path of the file - * @param {number} fd file descriptor - * @param {Object} opts - * @returns {fileCallback} - * @private - */ -function _prepareTmpFileRemoveCallback(name, fd, opts) { - const removeCallbackSync = _prepareRemoveCallback(_removeFileSync, [fd, name]); - const removeCallback = _prepareRemoveCallback(_removeFileAsync, [fd, name], removeCallbackSync); + var remain = pattern.slice(n) - if (!opts.keep) _removeObjects.unshift(removeCallbackSync); + // get the list of entries. + var read + if (prefix === null) + read = '.' + else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) { + if (!prefix || !isAbsolute(prefix)) + prefix = '/' + prefix + read = prefix + } else + read = prefix - return removeCallback; -} + var abs = this._makeAbs(read) -/** - * Simple wrapper for rimraf. - * - * @param {string} dirPath - * @param {Function} next - * @private - */ -function _rimrafRemoveDirWrapper(dirPath, next) { - rimraf(dirPath, next); -} + //if ignored, skip _processing + if (childrenIgnored(this, read)) + return cb() -/** - * Simple wrapper for rimraf.sync. - * - * @param {string} dirPath - * @private - */ -function _rimrafRemoveDirSyncWrapper(dirPath, next) { - try { - return next(null, rimraf.sync(dirPath)); - } catch (err) { - return next(err); - } + var isGlobStar = remain[0] === minimatch.GLOBSTAR + if (isGlobStar) + this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb) + else + this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb) } -/** - * Prepares the callback for removal of the temporary directory. - * - * @param {string} name - * @param {Object} opts - * @returns {Function} the callback - * @private - */ -function _prepareTmpDirRemoveCallback(name, opts) { - const removeFunction = opts.unsafeCleanup ? _rimrafRemoveDirWrapper : fs.rmdir.bind(fs); - const removeFunctionSync = opts.unsafeCleanup ? _rimrafRemoveDirSyncWrapper : fs.rmdirSync.bind(fs); - const removeCallbackSync = _prepareRemoveCallback(removeFunctionSync, name); - const removeCallback = _prepareRemoveCallback(removeFunction, name, removeCallbackSync); - if (!opts.keep) _removeObjects.unshift(removeCallbackSync); - - return removeCallback; +Glob.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar, cb) { + var self = this + this._readdir(abs, inGlobStar, function (er, entries) { + return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb) + }) } -/** - * Creates a guarded function wrapping the removeFunction call. - * - * @param {Function} removeFunction - * @param {Object} arg - * @returns {Function} - * @private - */ -function _prepareRemoveCallback(removeFunction, arg, cleanupCallbackSync) { - var called = false; - - return function _cleanupCallback(next) { - next = next || function () {}; - if (!called) { - const toRemove = cleanupCallbackSync || _cleanupCallback; - const index = _removeObjects.indexOf(toRemove); - /* istanbul ignore else */ - if (index >= 0) _removeObjects.splice(index, 1); +Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) { - called = true; - // sync? - if (removeFunction.length === 1) { - try { - removeFunction(arg); - return next(null); - } - catch (err) { - // if no next is provided and since we are - // in silent cleanup mode on process exit, - // we will ignore the error - return next(err); - } - } else return removeFunction(arg, next); - } else return next(new Error('cleanup callback has already been called')); - }; -} + // if the abs isn't a dir, then nothing can match! + if (!entries) + return cb() -/** - * The garbage collector. - * - * @private - */ -function _garbageCollector() { - /* istanbul ignore else */ - if (!_gracefulCleanup) return; + // It will only match dot entries if it starts with a dot, or if + // dot is set. Stuff like @(.foo|.bar) isn't allowed. + var pn = remain[0] + var negate = !!this.minimatch.negate + var rawGlob = pn._glob + var dotOk = this.dot || rawGlob.charAt(0) === '.' - // the function being called removes itself from _removeObjects, - // loop until _removeObjects is empty - while (_removeObjects.length) { - try { - _removeObjects[0](); - } catch (e) { - // already removed? + var matchedEntries = [] + for (var i = 0; i < entries.length; i++) { + var e = entries[i] + if (e.charAt(0) !== '.' || dotOk) { + var m + if (negate && !prefix) { + m = !e.match(pn) + } else { + m = e.match(pn) + } + if (m) + matchedEntries.push(e) } } -} -/** - * Helper for testing against EBADF to compensate changes made to Node 7.x under Windows. - */ -function isEBADF(error) { - return isExpectedError(error, -EBADF, 'EBADF'); -} + //console.error('prd2', prefix, entries, remain[0]._glob, matchedEntries) -/** - * Helper for testing against ENOENT to compensate changes made to Node 7.x under Windows. - */ -function isENOENT(error) { - return isExpectedError(error, -ENOENT, 'ENOENT'); -} + var len = matchedEntries.length + // If there are no matched entries, then nothing matches. + if (len === 0) + return cb() -/** - * Helper to determine whether the expected error code matches the actual code and errno, - * which will differ between the supported node versions. - * - * - Node >= 7.0: - * error.code {string} - * error.errno {string|number} any numerical value will be negated - * - * - Node >= 6.0 < 7.0: - * error.code {string} - * error.errno {number} negated - * - * - Node >= 4.0 < 6.0: introduces SystemError - * error.code {string} - * error.errno {number} negated - * - * - Node >= 0.10 < 4.0: - * error.code {number} negated - * error.errno n/a - */ -function isExpectedError(error, code, errno) { - return error.code === code || error.code === errno; + // if this is the last remaining pattern bit, then no need for + // an additional stat *unless* the user has specified mark or + // stat explicitly. We know they exist, since readdir returned + // them. + + if (remain.length === 1 && !this.mark && !this.stat) { + if (!this.matches[index]) + this.matches[index] = Object.create(null) + + for (var i = 0; i < len; i ++) { + var e = matchedEntries[i] + if (prefix) { + if (prefix !== '/') + e = prefix + '/' + e + else + e = prefix + e + } + + if (e.charAt(0) === '/' && !this.nomount) { + e = path.join(this.root, e) + } + this._emitMatch(index, e) + } + // This was the last one, and no stats were needed + return cb() + } + + // now test all matched entries as stand-ins for that part + // of the pattern. + remain.shift() + for (var i = 0; i < len; i ++) { + var e = matchedEntries[i] + var newPattern + if (prefix) { + if (prefix !== '/') + e = prefix + '/' + e + else + e = prefix + e + } + this._process([e].concat(remain), index, inGlobStar, cb) + } + cb() } -/** - * Helper which determines whether a string s is blank, that is undefined, or empty or null. - * - * @private - * @param {string} s - * @returns {Boolean} true whether the string s is blank, false otherwise - */ -function isBlank(s) { - return s === null || s === undefined || !s.trim(); +Glob.prototype._emitMatch = function (index, e) { + if (this.aborted) + return + + if (isIgnored(this, e)) + return + + if (this.paused) { + this._emitQueue.push([index, e]) + return + } + + var abs = isAbsolute(e) ? e : this._makeAbs(e) + + if (this.mark) + e = this._mark(e) + + if (this.absolute) + e = abs + + if (this.matches[index][e]) + return + + if (this.nodir) { + var c = this.cache[abs] + if (c === 'DIR' || Array.isArray(c)) + return + } + + this.matches[index][e] = true + + var st = this.statCache[abs] + if (st) + this.emit('stat', e, st) + + this.emit('match', e) } -/** - * Sets the graceful cleanup. - */ -function setGracefulCleanup() { - _gracefulCleanup = true; +Glob.prototype._readdirInGlobStar = function (abs, cb) { + if (this.aborted) + return + + // follow all symlinked directories forever + // just proceed as if this is a non-globstar situation + if (this.follow) + return this._readdir(abs, false, cb) + + var lstatkey = 'lstat\0' + abs + var self = this + var lstatcb = inflight(lstatkey, lstatcb_) + + if (lstatcb) + fs.lstat(abs, lstatcb) + + function lstatcb_ (er, lstat) { + if (er && er.code === 'ENOENT') + return cb() + + var isSym = lstat && lstat.isSymbolicLink() + self.symlinks[abs] = isSym + + // If it's not a symlink or a dir, then it's definitely a regular file. + // don't bother doing a readdir in that case. + if (!isSym && lstat && !lstat.isDirectory()) { + self.cache[abs] = 'FILE' + cb() + } else + self._readdir(abs, false, cb) + } } -/** - * Returns the currently configured tmp dir from os.tmpdir(). - * - * @private - * @returns {string} the currently configured tmp dir - */ -function _getTmpDir() { - return os.tmpdir(); +Glob.prototype._readdir = function (abs, inGlobStar, cb) { + if (this.aborted) + return + + cb = inflight('readdir\0'+abs+'\0'+inGlobStar, cb) + if (!cb) + return + + //console.error('RD %j %j', +inGlobStar, abs) + if (inGlobStar && !ownProp(this.symlinks, abs)) + return this._readdirInGlobStar(abs, cb) + + if (ownProp(this.cache, abs)) { + var c = this.cache[abs] + if (!c || c === 'FILE') + return cb() + + if (Array.isArray(c)) + return cb(null, c) + } + + var self = this + fs.readdir(abs, readdirCb(this, abs, cb)) +} + +function readdirCb (self, abs, cb) { + return function (er, entries) { + if (er) + self._readdirError(abs, er, cb) + else + self._readdirEntries(abs, entries, cb) + } +} + +Glob.prototype._readdirEntries = function (abs, entries, cb) { + if (this.aborted) + return + + // if we haven't asked to stat everything, then just + // assume that everything in there exists, so we can avoid + // having to stat it a second time. + if (!this.mark && !this.stat) { + for (var i = 0; i < entries.length; i ++) { + var e = entries[i] + if (abs === '/') + e = abs + e + else + e = abs + '/' + e + this.cache[e] = true + } + } + + this.cache[abs] = entries + return cb(null, entries) +} + +Glob.prototype._readdirError = function (f, er, cb) { + if (this.aborted) + return + + // handle errors, and cache the information + switch (er.code) { + case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205 + case 'ENOTDIR': // totally normal. means it *does* exist. + var abs = this._makeAbs(f) + this.cache[abs] = 'FILE' + if (abs === this.cwdAbs) { + var error = new Error(er.code + ' invalid cwd ' + this.cwd) + error.path = this.cwd + error.code = er.code + this.emit('error', error) + this.abort() + } + break + + case 'ENOENT': // not terribly unusual + case 'ELOOP': + case 'ENAMETOOLONG': + case 'UNKNOWN': + this.cache[this._makeAbs(f)] = false + break + + default: // some unusual error. Treat as failure. + this.cache[this._makeAbs(f)] = false + if (this.strict) { + this.emit('error', er) + // If the error is handled, then we abort + // if not, we threw out of here + this.abort() + } + if (!this.silent) + console.error('glob error', er) + break + } + + return cb() +} + +Glob.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar, cb) { + var self = this + this._readdir(abs, inGlobStar, function (er, entries) { + self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb) + }) +} + + +Glob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) { + //console.error('pgs2', prefix, remain[0], entries) + + // no entries means not a dir, so it can never have matches + // foo.txt/** doesn't match foo.txt + if (!entries) + return cb() + + // test without the globstar, and with every child both below + // and replacing the globstar. + var remainWithoutGlobStar = remain.slice(1) + var gspref = prefix ? [ prefix ] : [] + var noGlobStar = gspref.concat(remainWithoutGlobStar) + + // the noGlobStar pattern exits the inGlobStar state + this._process(noGlobStar, index, false, cb) + + var isSym = this.symlinks[abs] + var len = entries.length + + // If it's a symlink, and we're in a globstar, then stop + if (isSym && inGlobStar) + return cb() + + for (var i = 0; i < len; i++) { + var e = entries[i] + if (e.charAt(0) === '.' && !this.dot) + continue + + // these two cases enter the inGlobStar state + var instead = gspref.concat(entries[i], remainWithoutGlobStar) + this._process(instead, index, true, cb) + + var below = gspref.concat(entries[i], remain) + this._process(below, index, true, cb) + } + + cb() } -/** - * If there are multiple different versions of tmp in place, make sure that - * we recognize the old listeners. - * - * @param {Function} listener - * @private - * @returns {Boolean} true whether listener is a legacy listener - */ -function _is_legacy_listener(listener) { - return (listener.name === '_exit' || listener.name === '_uncaughtExceptionThrown') - && listener.toString().indexOf('_garbageCollector();') > -1; +Glob.prototype._processSimple = function (prefix, index, cb) { + // XXX review this. Shouldn't it be doing the mounting etc + // before doing stat? kinda weird? + var self = this + this._stat(prefix, function (er, exists) { + self._processSimple2(prefix, index, er, exists, cb) + }) } +Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) { -/** - * Safely install SIGINT listener. - * - * NOTE: this will only work on OSX and Linux. - * - * @private - */ -function _safely_install_sigint_listener() { + //console.error('ps2', prefix, exists) - const listeners = process.listeners(SIGINT); - const existingListeners = []; - for (let i = 0, length = listeners.length; i < length; i++) { - const lstnr = listeners[i]; - /* istanbul ignore else */ - if (lstnr.name === '_tmp$sigint_listener') { - existingListeners.push(lstnr); - process.removeListener(SIGINT, lstnr); - } - } - process.on(SIGINT, function _tmp$sigint_listener(doExit) { - for (let i = 0, length = existingListeners.length; i < length; i++) { - // let the existing listener do the garbage collection (e.g. jest sandbox) - try { - existingListeners[i](false); - } catch (err) { - // ignore - } - } - try { - // force the garbage collector even it is called again in the exit listener - _garbageCollector(); - } finally { - if (!!doExit) { - process.exit(0); - } - } - }); -} + if (!this.matches[index]) + this.matches[index] = Object.create(null) -/** - * Safely install process exit listener. - * - * @private - */ -function _safely_install_exit_listener() { - const listeners = process.listeners(EXIT); + // If it doesn't exist, then just mark the lack of results + if (!exists) + return cb() - // collect any existing listeners - const existingListeners = []; - for (let i = 0, length = listeners.length; i < length; i++) { - const lstnr = listeners[i]; - /* istanbul ignore else */ - // TODO: remove support for legacy listeners once release 1.0.0 is out - if (lstnr.name === '_tmp$safe_listener' || _is_legacy_listener(lstnr)) { - // we must forget about the uncaughtException listener, hopefully it is ours - if (lstnr.name !== '_uncaughtExceptionThrown') { - existingListeners.push(lstnr); - } - process.removeListener(EXIT, lstnr); + if (prefix && isAbsolute(prefix) && !this.nomount) { + var trail = /[\/\\]$/.test(prefix) + if (prefix.charAt(0) === '/') { + prefix = path.join(this.root, prefix) + } else { + prefix = path.resolve(this.root, prefix) + if (trail) + prefix += '/' } } - // TODO: what was the data parameter good for? - process.addListener(EXIT, function _tmp$safe_listener(data) { - for (let i = 0, length = existingListeners.length; i < length; i++) { - // let the existing listener do the garbage collection (e.g. jest sandbox) - try { - existingListeners[i](data); - } catch (err) { - // ignore - } - } - _garbageCollector(); - }); + + if (process.platform === 'win32') + prefix = prefix.replace(/\\/g, '/') + + // Mark this as a match + this._emitMatch(index, prefix) + cb() } -_safely_install_exit_listener(); -_safely_install_sigint_listener(); +// Returns either 'DIR', 'FILE', or false +Glob.prototype._stat = function (f, cb) { + var abs = this._makeAbs(f) + var needDir = f.slice(-1) === '/' -/** - * Configuration options. - * - * @typedef {Object} Options - * @property {?number} tries the number of tries before give up the name generation - * @property {?string} template the "mkstemp" like filename template - * @property {?string} name fix name - * @property {?string} dir the tmp directory to use - * @property {?string} prefix prefix for the generated name - * @property {?string} postfix postfix for the generated name - * @property {?boolean} unsafeCleanup recursively removes the created temporary directory, even when it's not empty - */ + if (f.length > this.maxLength) + return cb() -/** - * @typedef {Object} FileSyncObject - * @property {string} name the name of the file - * @property {string} fd the file descriptor - * @property {fileCallback} removeCallback the callback function to remove the file - */ + if (!this.stat && ownProp(this.cache, abs)) { + var c = this.cache[abs] -/** - * @typedef {Object} DirSyncObject - * @property {string} name the name of the directory - * @property {fileCallback} removeCallback the callback function to remove the directory - */ + if (Array.isArray(c)) + c = 'DIR' -/** - * @callback tmpNameCallback - * @param {?Error} err the error object if anything goes wrong - * @param {string} name the temporary file name - */ + // It exists, but maybe not how we need it + if (!needDir || c === 'DIR') + return cb(null, c) -/** - * @callback fileCallback - * @param {?Error} err the error object if anything goes wrong - * @param {string} name the temporary file name - * @param {number} fd the file descriptor - * @param {cleanupCallback} fn the cleanup callback function - */ + if (needDir && c === 'FILE') + return cb() -/** - * @callback dirCallback - * @param {?Error} err the error object if anything goes wrong - * @param {string} name the temporary file name - * @param {cleanupCallback} fn the cleanup callback function - */ + // otherwise we have to stat, because maybe c=true + // if we know it exists, but not what it is. + } -/** - * Removes the temporary created file or directory. - * - * @callback cleanupCallback - * @param {simpleCallback} [next] function to call after entry was removed - */ + var exists + var stat = this.statCache[abs] + if (stat !== undefined) { + if (stat === false) + return cb(null, stat) + else { + var type = stat.isDirectory() ? 'DIR' : 'FILE' + if (needDir && type === 'FILE') + return cb() + else + return cb(null, type, stat) + } + } -/** - * Callback function for function composition. - * @see {@link https://github.com/raszi/node-tmp/issues/57|raszi/node-tmp#57} - * - * @callback simpleCallback - */ + var self = this + var statcb = inflight('stat\0' + abs, lstatcb_) + if (statcb) + fs.lstat(abs, statcb) -// exporting all the needed methods + function lstatcb_ (er, lstat) { + if (lstat && lstat.isSymbolicLink()) { + // If it's a symlink, then treat it as the target, unless + // the target does not exist, then treat it as a file. + return fs.stat(abs, function (er, stat) { + if (er) + self._stat2(f, abs, null, lstat, cb) + else + self._stat2(f, abs, er, stat, cb) + }) + } else { + self._stat2(f, abs, er, lstat, cb) + } + } +} -// evaluate os.tmpdir() lazily, mainly for simplifying testing but it also will -// allow users to reconfigure the temporary directory -Object.defineProperty(module.exports, 'tmpdir', { - enumerable: true, - configurable: false, - get: function () { - return _getTmpDir(); +Glob.prototype._stat2 = function (f, abs, er, stat, cb) { + if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) { + this.statCache[abs] = false + return cb() } -}); -module.exports.dir = dir; -module.exports.dirSync = dirSync; + var needDir = f.slice(-1) === '/' + this.statCache[abs] = stat -module.exports.file = file; -module.exports.fileSync = fileSync; + if (abs.slice(-1) === '/' && stat && !stat.isDirectory()) + return cb(null, false, stat) -module.exports.tmpName = tmpName; -module.exports.tmpNameSync = tmpNameSync; + var c = true + if (stat) + c = stat.isDirectory() ? 'DIR' : 'FILE' + this.cache[abs] = this.cache[abs] || c -module.exports.setGracefulCleanup = setGracefulCleanup; + if (needDir && c === 'FILE') + return cb() + + return cb(null, c, stat) +} /***/ }), @@ -5921,7 +5921,9 @@ class HttpClient { maxSockets: maxSockets, keepAlive: this._keepAlive, proxy: { - proxyAuth: `${proxyUrl.username}:${proxyUrl.password}`, + ...((proxyUrl.username || proxyUrl.password) && { + proxyAuth: `${proxyUrl.username}:${proxyUrl.password}` + }), host: proxyUrl.hostname, port: proxyUrl.port } @@ -6040,7 +6042,7 @@ rimraf.sync = rimrafSync var assert = __webpack_require__(357) var path = __webpack_require__(622) var fs = __webpack_require__(747) -var glob = __webpack_require__(120) +var glob = __webpack_require__(402) var _0666 = parseInt('666', 8) var defaultGlobOpts = { @@ -8428,7 +8430,7 @@ exports.sleep = sleep; /***/ (function(module, __unusedexports, __webpack_require__) { const {promisify} = __webpack_require__(669); -const tmp = __webpack_require__(402); +const tmp = __webpack_require__(150); // file module.exports.fileSync = tmp.fileSync; diff --git a/package-lock.json b/package-lock.json index 4c59618d..28bf54c2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,25 +5,15 @@ "requires": true, "dependencies": { "@actions/artifact": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/@actions/artifact/-/artifact-0.5.0.tgz", - "integrity": "sha512-uo9zlqm8sZBysFVaBZh8iAe2xNf9x2fDQZZMHiKyBEShvCB2S2nA4+Kt3Xsi9eG5O1E8fVMwEVuwLR3/Zy3mrA==", + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/@actions/artifact/-/artifact-0.5.1.tgz", + "integrity": "sha512-wKXEa4fhvgsw3kPu74F3J6eAi92rqv7BvpjEAmiqmDFeuDj6cyqWDWXx6axWfiBmmln1/LVf1DLWikbciKkoVQ==", "requires": { "@actions/core": "^1.2.6", - "@actions/http-client": "^1.0.7", + "@actions/http-client": "^1.0.11", "@types/tmp": "^0.1.0", "tmp": "^0.1.0", "tmp-promise": "^2.0.2" - }, - "dependencies": { - "tmp": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.1.0.tgz", - "integrity": "sha512-J7Z2K08jbGcdA1kkQpJSqLF6T0tdQqpR2pnSUXsIchbPdTI9v3e85cLW0d6WDhwuAleOV71j2xWs8qMPfK7nKw==", - "requires": { - "rimraf": "^2.6.3" - } - } } }, "@actions/core": { @@ -41,9 +31,9 @@ } }, "@actions/http-client": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.9.tgz", - "integrity": "sha512-0O4SsJ7q+MK0ycvXPl2e6bMXV7dxAXOGjrXS1eTF9s2S401Tp6c/P3c3Joz04QefC1J6Gt942Wl2jbm3f4mLcg==", + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz", + "integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==", "requires": { "tunnel": "0.0.6" } @@ -9576,22 +9566,20 @@ "integrity": "sha512-fcwX4mndzpLQKBS1DVYhGAcYaYt7vsHNIvQV+WXMvnow5cgjPphq5CaayLaGsjRdSCKZFNGt7/GYAuXaNOiYCA==", "dev": true }, + "tmp": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.1.0.tgz", + "integrity": "sha512-J7Z2K08jbGcdA1kkQpJSqLF6T0tdQqpR2pnSUXsIchbPdTI9v3e85cLW0d6WDhwuAleOV71j2xWs8qMPfK7nKw==", + "requires": { + "rimraf": "^2.6.3" + } + }, "tmp-promise": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/tmp-promise/-/tmp-promise-2.1.1.tgz", "integrity": "sha512-Z048AOz/w9b6lCbJUpevIJpRpUztENl8zdv1bmAKVHimfqRFl92ROkmT9rp7TVBnrEw2gtMTol/2Cp2S2kJa4Q==", "requires": { "tmp": "0.1.0" - }, - "dependencies": { - "tmp": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.1.0.tgz", - "integrity": "sha512-J7Z2K08jbGcdA1kkQpJSqLF6T0tdQqpR2pnSUXsIchbPdTI9v3e85cLW0d6WDhwuAleOV71j2xWs8qMPfK7nKw==", - "requires": { - "rimraf": "^2.6.3" - } - } } }, "tmpl": { diff --git a/package.json b/package.json index d65969c8..fc56ab08 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ }, "homepage": "https://github.com/actions/upload-artifact#readme", "dependencies": { - "@actions/artifact": "^0.5.0", + "@actions/artifact": "^0.5.1", "@actions/core": "^1.2.6", "@actions/glob": "^0.1.0", "@actions/io": "^1.0.2" From 8e778380f6f362097160f895210e5650889c79ea Mon Sep 17 00:00:00 2001 From: konradpabjan Date: Tue, 6 Apr 2021 15:11:30 -0400 Subject: [PATCH 2/2] Update license versions --- .licenses/npm/@actions/artifact.dep.yml | 2 +- .licenses/npm/@actions/http-client.dep.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.licenses/npm/@actions/artifact.dep.yml b/.licenses/npm/@actions/artifact.dep.yml index e340b6c4..02700720 100644 --- a/.licenses/npm/@actions/artifact.dep.yml +++ b/.licenses/npm/@actions/artifact.dep.yml @@ -1,6 +1,6 @@ --- name: "@actions/artifact" -version: 0.5.0 +version: 0.5.1 type: npm summary: homepage: diff --git a/.licenses/npm/@actions/http-client.dep.yml b/.licenses/npm/@actions/http-client.dep.yml index 2e3a4243..43316cbc 100644 --- a/.licenses/npm/@actions/http-client.dep.yml +++ b/.licenses/npm/@actions/http-client.dep.yml @@ -1,6 +1,6 @@ --- name: "@actions/http-client" -version: 1.0.9 +version: 1.0.11 type: npm summary: Actions Http Client homepage: https://github.com/actions/http-client#readme