diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 9dc4e67b..00000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,51 +0,0 @@ ---- -version: 2 - -scripts: &scripts - steps: - - checkout - - run: yarn - - run: yarn test - - run: yarn lint - - run: yarn build - -uptodate: &uptodate - steps: - - checkout - - run: yarn - - run: yarn build - - run: git diff --exit-code build - -jobs: - node-10: - <<: *scripts - docker: - - image: circleci/node:10 - node-12: - <<: *scripts - docker: - - image: circleci/node:12 - node-13: - <<: *scripts - docker: - - image: circleci/node:13 - node-14: - <<: *scripts - docker: - - image: circleci/node:14 - uptodate: - <<: *uptodate - requires: - - node-12 - docker: - - image: circleci/node:12 - -workflows: - version: 2 - build: - jobs: - - node-10 - - node-12 - - node-13 - - node-14 - - uptodate diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..b6c7881e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,55 @@ +--- +name: CI +on: + push: + branches: [master] + pull_request: + types: [opened, synchronize] +jobs: + build: + name: Test and build + runs-on: ${{ matrix.os }} + strategy: + matrix: + node: [12, 14] + os: + - macos-latest + - ubuntu-latest + - windows-latest + include: + - node: 12 + os: macos-latest + checkUpToDate: true + - node: 12 + os: ubuntu-latest + checkUpToDate: true + steps: + - name: Setup repo + uses: actions/checkout@v2 + - name: Setup node + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node }} + - name: Find cache + id: yarn-cache-dir-path + run: echo "::set-output name=dir::$(yarn cache dir)" + - name: Restore cache + uses: actions/cache@v2 + with: + path: ${{ steps.yarn-cache-dir-path.outputs.dir }} + key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} + restore-keys: | + ${{ runner.os }}-yarn- + - name: Install dependencies + run: yarn install --frozen-lockfile --check-files + - name: Lint package + run: yarn lint + - name: Test package + run: yarn test + - name: Build clean + run: yarn clean + - name: Build package + run: yarn build + - name: Build up-to-date + if: ${{ matrix.checkUpToDate }} + run: git diff --stat --exit-code build diff --git a/build/index.js b/build/index.js index d5074be2..de1c7b23 100644 --- a/build/index.js +++ b/build/index.js @@ -1022,7 +1022,384 @@ class ExecState extends events.EventEmitter { //# sourceMappingURL=toolrunner.js.map /***/ }), -/* 10 */, +/* 10 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +module.exports = rimraf +rimraf.sync = rimrafSync + +var assert = __webpack_require__(357) +var path = __webpack_require__(622) +var fs = __webpack_require__(747) +var glob = undefined +try { + glob = __webpack_require__(402) +} catch (_err) { + // treat glob as optional. +} +var _0666 = parseInt('666', 8) + +var defaultGlobOpts = { + nosort: true, + silent: true +} + +// for EMFILE handling +var timeout = 0 + +var isWindows = (process.platform === "win32") + +function defaults (options) { + var methods = [ + 'unlink', + 'chmod', + 'stat', + 'lstat', + 'rmdir', + 'readdir' + ] + methods.forEach(function(m) { + options[m] = options[m] || fs[m] + m = m + 'Sync' + options[m] = options[m] || fs[m] + }) + + options.maxBusyTries = options.maxBusyTries || 3 + options.emfileWait = options.emfileWait || 1000 + if (options.glob === false) { + options.disableGlob = true + } + if (options.disableGlob !== true && glob === undefined) { + throw Error('glob dependency not found, set `options.disableGlob = true` if intentional') + } + options.disableGlob = options.disableGlob || false + options.glob = options.glob || defaultGlobOpts +} + +function rimraf (p, options, cb) { + if (typeof options === 'function') { + cb = options + options = {} + } + + assert(p, 'rimraf: missing path') + assert.equal(typeof p, 'string', 'rimraf: path should be a string') + assert.equal(typeof cb, 'function', 'rimraf: callback function required') + assert(options, 'rimraf: invalid options argument provided') + assert.equal(typeof options, 'object', 'rimraf: options should be object') + + defaults(options) + + var busyTries = 0 + var errState = null + var n = 0 + + if (options.disableGlob || !glob.hasMagic(p)) + return afterGlob(null, [p]) + + options.lstat(p, function (er, stat) { + if (!er) + return afterGlob(null, [p]) + + glob(p, options.glob, afterGlob) + }) + + function next (er) { + errState = errState || er + if (--n === 0) + cb(errState) + } + + function afterGlob (er, results) { + if (er) + return cb(er) + + n = results.length + if (n === 0) + return cb() + + results.forEach(function (p) { + rimraf_(p, options, function CB (er) { + if (er) { + if ((er.code === "EBUSY" || er.code === "ENOTEMPTY" || er.code === "EPERM") && + busyTries < options.maxBusyTries) { + busyTries ++ + var time = busyTries * 100 + // try again, with the same exact callback as this one. + return setTimeout(function () { + rimraf_(p, options, CB) + }, time) + } + + // this one won't happen if graceful-fs is used. + if (er.code === "EMFILE" && timeout < options.emfileWait) { + return setTimeout(function () { + rimraf_(p, options, CB) + }, timeout ++) + } + + // already gone + if (er.code === "ENOENT") er = null + } + + timeout = 0 + next(er) + }) + }) + } +} + +// Two possible strategies. +// 1. Assume it's a file. unlink it, then do the dir stuff on EPERM or EISDIR +// 2. Assume it's a directory. readdir, then do the file stuff on ENOTDIR +// +// Both result in an extra syscall when you guess wrong. However, there +// are likely far more normal files in the world than directories. This +// is based on the assumption that a the average number of files per +// directory is >= 1. +// +// If anyone ever complains about this, then I guess the strategy could +// be made configurable somehow. But until then, YAGNI. +function rimraf_ (p, options, cb) { + assert(p) + assert(options) + assert(typeof cb === 'function') + + // sunos lets the root user unlink directories, which is... weird. + // so we have to lstat here and make sure it's not a dir. + options.lstat(p, function (er, st) { + if (er && er.code === "ENOENT") + return cb(null) + + // Windows can EPERM on stat. Life is suffering. + if (er && er.code === "EPERM" && isWindows) + fixWinEPERM(p, options, er, cb) + + if (st && st.isDirectory()) + return rmdir(p, options, er, cb) + + options.unlink(p, function (er) { + if (er) { + if (er.code === "ENOENT") + return cb(null) + if (er.code === "EPERM") + return (isWindows) + ? fixWinEPERM(p, options, er, cb) + : rmdir(p, options, er, cb) + if (er.code === "EISDIR") + return rmdir(p, options, er, cb) + } + return cb(er) + }) + }) +} + +function fixWinEPERM (p, options, er, cb) { + assert(p) + assert(options) + assert(typeof cb === 'function') + if (er) + assert(er instanceof Error) + + options.chmod(p, _0666, function (er2) { + if (er2) + cb(er2.code === "ENOENT" ? null : er) + else + options.stat(p, function(er3, stats) { + if (er3) + cb(er3.code === "ENOENT" ? null : er) + else if (stats.isDirectory()) + rmdir(p, options, er, cb) + else + options.unlink(p, cb) + }) + }) +} + +function fixWinEPERMSync (p, options, er) { + assert(p) + assert(options) + if (er) + assert(er instanceof Error) + + try { + options.chmodSync(p, _0666) + } catch (er2) { + if (er2.code === "ENOENT") + return + else + throw er + } + + try { + var stats = options.statSync(p) + } catch (er3) { + if (er3.code === "ENOENT") + return + else + throw er + } + + if (stats.isDirectory()) + rmdirSync(p, options, er) + else + options.unlinkSync(p) +} + +function rmdir (p, options, originalEr, cb) { + assert(p) + assert(options) + if (originalEr) + assert(originalEr instanceof Error) + assert(typeof cb === 'function') + + // try to rmdir first, and only readdir on ENOTEMPTY or EEXIST (SunOS) + // if we guessed wrong, and it's not a directory, then + // raise the original error. + options.rmdir(p, function (er) { + if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM")) + rmkids(p, options, cb) + else if (er && er.code === "ENOTDIR") + cb(originalEr) + else + cb(er) + }) +} + +function rmkids(p, options, cb) { + assert(p) + assert(options) + assert(typeof cb === 'function') + + options.readdir(p, function (er, files) { + if (er) + return cb(er) + var n = files.length + if (n === 0) + return options.rmdir(p, cb) + var errState + files.forEach(function (f) { + rimraf(path.join(p, f), options, function (er) { + if (errState) + return + if (er) + return cb(errState = er) + if (--n === 0) + options.rmdir(p, cb) + }) + }) + }) +} + +// this looks simpler, and is strictly *faster*, but will +// tie up the JavaScript thread and fail on excessively +// deep directory trees. +function rimrafSync (p, options) { + options = options || {} + defaults(options) + + assert(p, 'rimraf: missing path') + assert.equal(typeof p, 'string', 'rimraf: path should be a string') + assert(options, 'rimraf: missing options') + assert.equal(typeof options, 'object', 'rimraf: options should be object') + + var results + + if (options.disableGlob || !glob.hasMagic(p)) { + results = [p] + } else { + try { + options.lstatSync(p) + results = [p] + } catch (er) { + results = glob.sync(p, options.glob) + } + } + + if (!results.length) + return + + for (var i = 0; i < results.length; i++) { + var p = results[i] + + try { + var st = options.lstatSync(p) + } catch (er) { + if (er.code === "ENOENT") + return + + // Windows can EPERM on stat. Life is suffering. + if (er.code === "EPERM" && isWindows) + fixWinEPERMSync(p, options, er) + } + + try { + // sunos lets the root user unlink directories, which is... weird. + if (st && st.isDirectory()) + rmdirSync(p, options, null) + else + options.unlinkSync(p) + } catch (er) { + if (er.code === "ENOENT") + return + if (er.code === "EPERM") + return isWindows ? fixWinEPERMSync(p, options, er) : rmdirSync(p, options, er) + if (er.code !== "EISDIR") + throw er + + rmdirSync(p, options, er) + } + } +} + +function rmdirSync (p, options, originalEr) { + assert(p) + assert(options) + if (originalEr) + assert(originalEr instanceof Error) + + try { + options.rmdirSync(p) + } catch (er) { + if (er.code === "ENOENT") + return + if (er.code === "ENOTDIR") + throw originalEr + if (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM") + rmkidsSync(p, options) + } +} + +function rmkidsSync (p, options) { + assert(p) + assert(options) + options.readdirSync(p).forEach(function (f) { + rimrafSync(path.join(p, f), options) + }) + + // We only end up here once we got ENOTEMPTY at least once, and + // at this point, we are guaranteed to have removed all the kids. + // So, we know that it won't be ENOENT or ENOTDIR or anything else. + // try really hard to delete stuff on windows, because it has a + // PROFOUNDLY annoying habit of not closing handles promptly when + // files are deleted, resulting in spurious ENOTEMPTY errors. + var retries = isWindows ? 100 : 1 + var i = 0 + do { + var threw = true + try { + var ret = options.rmdirSync(p, options) + threw = false + return ret + } finally { + if (++i < retries && threw) + continue + } + } while (true) +} + + +/***/ }), /* 11 */ /***/ (function(module) { @@ -1235,7 +1612,7 @@ module.exports = { const path = __webpack_require__(622) const fs = __webpack_require__(598) -const chain = __webpack_require__(993).chain +const chain = __webpack_require__(404).chain const mkdir = __webpack_require__(521) const rm = __webpack_require__(570) const inferOwner = __webpack_require__(686) @@ -2966,7 +3343,7 @@ const fs = __webpack_require__(598) const glob = BB.promisify(__webpack_require__(402)) const index = __webpack_require__(407) const path = __webpack_require__(622) -const rimraf = BB.promisify(__webpack_require__(569)) +const rimraf = BB.promisify(__webpack_require__(503)) const ssri = __webpack_require__(951) BB.promisifyAll(fs) @@ -6451,7 +6828,7 @@ var dirname = __webpack_require__(622).dirname var resolve = __webpack_require__(622).resolve var isInside = __webpack_require__(994) -var rimraf = __webpack_require__(569) +var rimraf = __webpack_require__(376) var lstat = __webpack_require__(598).lstat var readdir = __webpack_require__(598).readdir var rmdir = __webpack_require__(598).rmdir @@ -11826,7 +12203,7 @@ const packDir = __webpack_require__(249) const PassThrough = __webpack_require__(794).PassThrough const path = __webpack_require__(622) const pipe = BB.promisify(__webpack_require__(371).pipe) -const rimraf = BB.promisify(__webpack_require__(569)) +const rimraf = BB.promisify(__webpack_require__(985)) const uniqueFilename = __webpack_require__(106) // `git` dependencies are fetched from git repositories and packed up. @@ -12393,7 +12770,7 @@ RetryOperation.prototype.mainError = function() { module.exports = move var nodeFs = __webpack_require__(747) -var rimraf = __webpack_require__(569) +var rimraf = __webpack_require__(993) var validate = __webpack_require__(463) var copy = __webpack_require__(555) var RunQueue = __webpack_require__(399) @@ -19855,9 +20232,9 @@ const spawn = __webpack_require__(751) const path = __webpack_require__(622) const Stream = __webpack_require__(794).Stream const fs = __webpack_require__(598) -const chain = __webpack_require__(993).chain +const chain = __webpack_require__(404).chain const uidNumber = __webpack_require__(798) -const umask = __webpack_require__(503) +const umask = __webpack_require__(696) const which = __webpack_require__(142) const byline = __webpack_require__(861) const resolveFrom = __webpack_require__(143) @@ -26226,17 +26603,7 @@ module.exports = function (iconv) { /***/ }), -/* 330 */ -/***/ (function(module, __unusedexports, __webpack_require__) { - -"use strict"; - -const ansiRegex = __webpack_require__(448); - -module.exports = input => typeof input === 'string' ? input.replace(ansiRegex(), '') : input; - - -/***/ }), +/* 330 */, /* 331 */, /* 332 */ /***/ (function(module) { @@ -27591,7 +27958,384 @@ module.exports = __webpack_require__(990) /***/ }), /* 375 */, -/* 376 */, +/* 376 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +module.exports = rimraf +rimraf.sync = rimrafSync + +var assert = __webpack_require__(357) +var path = __webpack_require__(622) +var fs = __webpack_require__(747) +var glob = undefined +try { + glob = __webpack_require__(402) +} catch (_err) { + // treat glob as optional. +} +var _0666 = parseInt('666', 8) + +var defaultGlobOpts = { + nosort: true, + silent: true +} + +// for EMFILE handling +var timeout = 0 + +var isWindows = (process.platform === "win32") + +function defaults (options) { + var methods = [ + 'unlink', + 'chmod', + 'stat', + 'lstat', + 'rmdir', + 'readdir' + ] + methods.forEach(function(m) { + options[m] = options[m] || fs[m] + m = m + 'Sync' + options[m] = options[m] || fs[m] + }) + + options.maxBusyTries = options.maxBusyTries || 3 + options.emfileWait = options.emfileWait || 1000 + if (options.glob === false) { + options.disableGlob = true + } + if (options.disableGlob !== true && glob === undefined) { + throw Error('glob dependency not found, set `options.disableGlob = true` if intentional') + } + options.disableGlob = options.disableGlob || false + options.glob = options.glob || defaultGlobOpts +} + +function rimraf (p, options, cb) { + if (typeof options === 'function') { + cb = options + options = {} + } + + assert(p, 'rimraf: missing path') + assert.equal(typeof p, 'string', 'rimraf: path should be a string') + assert.equal(typeof cb, 'function', 'rimraf: callback function required') + assert(options, 'rimraf: invalid options argument provided') + assert.equal(typeof options, 'object', 'rimraf: options should be object') + + defaults(options) + + var busyTries = 0 + var errState = null + var n = 0 + + if (options.disableGlob || !glob.hasMagic(p)) + return afterGlob(null, [p]) + + options.lstat(p, function (er, stat) { + if (!er) + return afterGlob(null, [p]) + + glob(p, options.glob, afterGlob) + }) + + function next (er) { + errState = errState || er + if (--n === 0) + cb(errState) + } + + function afterGlob (er, results) { + if (er) + return cb(er) + + n = results.length + if (n === 0) + return cb() + + results.forEach(function (p) { + rimraf_(p, options, function CB (er) { + if (er) { + if ((er.code === "EBUSY" || er.code === "ENOTEMPTY" || er.code === "EPERM") && + busyTries < options.maxBusyTries) { + busyTries ++ + var time = busyTries * 100 + // try again, with the same exact callback as this one. + return setTimeout(function () { + rimraf_(p, options, CB) + }, time) + } + + // this one won't happen if graceful-fs is used. + if (er.code === "EMFILE" && timeout < options.emfileWait) { + return setTimeout(function () { + rimraf_(p, options, CB) + }, timeout ++) + } + + // already gone + if (er.code === "ENOENT") er = null + } + + timeout = 0 + next(er) + }) + }) + } +} + +// Two possible strategies. +// 1. Assume it's a file. unlink it, then do the dir stuff on EPERM or EISDIR +// 2. Assume it's a directory. readdir, then do the file stuff on ENOTDIR +// +// Both result in an extra syscall when you guess wrong. However, there +// are likely far more normal files in the world than directories. This +// is based on the assumption that a the average number of files per +// directory is >= 1. +// +// If anyone ever complains about this, then I guess the strategy could +// be made configurable somehow. But until then, YAGNI. +function rimraf_ (p, options, cb) { + assert(p) + assert(options) + assert(typeof cb === 'function') + + // sunos lets the root user unlink directories, which is... weird. + // so we have to lstat here and make sure it's not a dir. + options.lstat(p, function (er, st) { + if (er && er.code === "ENOENT") + return cb(null) + + // Windows can EPERM on stat. Life is suffering. + if (er && er.code === "EPERM" && isWindows) + fixWinEPERM(p, options, er, cb) + + if (st && st.isDirectory()) + return rmdir(p, options, er, cb) + + options.unlink(p, function (er) { + if (er) { + if (er.code === "ENOENT") + return cb(null) + if (er.code === "EPERM") + return (isWindows) + ? fixWinEPERM(p, options, er, cb) + : rmdir(p, options, er, cb) + if (er.code === "EISDIR") + return rmdir(p, options, er, cb) + } + return cb(er) + }) + }) +} + +function fixWinEPERM (p, options, er, cb) { + assert(p) + assert(options) + assert(typeof cb === 'function') + if (er) + assert(er instanceof Error) + + options.chmod(p, _0666, function (er2) { + if (er2) + cb(er2.code === "ENOENT" ? null : er) + else + options.stat(p, function(er3, stats) { + if (er3) + cb(er3.code === "ENOENT" ? null : er) + else if (stats.isDirectory()) + rmdir(p, options, er, cb) + else + options.unlink(p, cb) + }) + }) +} + +function fixWinEPERMSync (p, options, er) { + assert(p) + assert(options) + if (er) + assert(er instanceof Error) + + try { + options.chmodSync(p, _0666) + } catch (er2) { + if (er2.code === "ENOENT") + return + else + throw er + } + + try { + var stats = options.statSync(p) + } catch (er3) { + if (er3.code === "ENOENT") + return + else + throw er + } + + if (stats.isDirectory()) + rmdirSync(p, options, er) + else + options.unlinkSync(p) +} + +function rmdir (p, options, originalEr, cb) { + assert(p) + assert(options) + if (originalEr) + assert(originalEr instanceof Error) + assert(typeof cb === 'function') + + // try to rmdir first, and only readdir on ENOTEMPTY or EEXIST (SunOS) + // if we guessed wrong, and it's not a directory, then + // raise the original error. + options.rmdir(p, function (er) { + if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM")) + rmkids(p, options, cb) + else if (er && er.code === "ENOTDIR") + cb(originalEr) + else + cb(er) + }) +} + +function rmkids(p, options, cb) { + assert(p) + assert(options) + assert(typeof cb === 'function') + + options.readdir(p, function (er, files) { + if (er) + return cb(er) + var n = files.length + if (n === 0) + return options.rmdir(p, cb) + var errState + files.forEach(function (f) { + rimraf(path.join(p, f), options, function (er) { + if (errState) + return + if (er) + return cb(errState = er) + if (--n === 0) + options.rmdir(p, cb) + }) + }) + }) +} + +// this looks simpler, and is strictly *faster*, but will +// tie up the JavaScript thread and fail on excessively +// deep directory trees. +function rimrafSync (p, options) { + options = options || {} + defaults(options) + + assert(p, 'rimraf: missing path') + assert.equal(typeof p, 'string', 'rimraf: path should be a string') + assert(options, 'rimraf: missing options') + assert.equal(typeof options, 'object', 'rimraf: options should be object') + + var results + + if (options.disableGlob || !glob.hasMagic(p)) { + results = [p] + } else { + try { + options.lstatSync(p) + results = [p] + } catch (er) { + results = glob.sync(p, options.glob) + } + } + + if (!results.length) + return + + for (var i = 0; i < results.length; i++) { + var p = results[i] + + try { + var st = options.lstatSync(p) + } catch (er) { + if (er.code === "ENOENT") + return + + // Windows can EPERM on stat. Life is suffering. + if (er.code === "EPERM" && isWindows) + fixWinEPERMSync(p, options, er) + } + + try { + // sunos lets the root user unlink directories, which is... weird. + if (st && st.isDirectory()) + rmdirSync(p, options, null) + else + options.unlinkSync(p) + } catch (er) { + if (er.code === "ENOENT") + return + if (er.code === "EPERM") + return isWindows ? fixWinEPERMSync(p, options, er) : rmdirSync(p, options, er) + if (er.code !== "EISDIR") + throw er + + rmdirSync(p, options, er) + } + } +} + +function rmdirSync (p, options, originalEr) { + assert(p) + assert(options) + if (originalEr) + assert(originalEr instanceof Error) + + try { + options.rmdirSync(p) + } catch (er) { + if (er.code === "ENOENT") + return + if (er.code === "ENOTDIR") + throw originalEr + if (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM") + rmkidsSync(p, options) + } +} + +function rmkidsSync (p, options) { + assert(p) + assert(options) + options.readdirSync(p).forEach(function (f) { + rimrafSync(path.join(p, f), options) + }) + + // We only end up here once we got ENOTEMPTY at least once, and + // at this point, we are guaranteed to have removed all the kids. + // So, we know that it won't be ENOENT or ENOTDIR or anything else. + // try really hard to delete stuff on windows, because it has a + // PROFOUNDLY annoying habit of not closing handles promptly when + // files are deleted, resulting in spurious ENOTEMPTY errors. + var retries = isWindows ? 100 : 1 + var i = 0 + do { + var threw = true + try { + var ret = options.rmdirSync(p, options) + threw = false + return ret + } finally { + if (++i < retries && threw) + continue + } + } while (true) +} + + +/***/ }), /* 377 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -29578,7 +30322,15 @@ Glob.prototype._stat2 = function (f, abs, er, stat, cb) { /***/ }), /* 403 */, -/* 404 */, +/* 404 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +exports.asyncMap = __webpack_require__(943) +exports.bindActor = __webpack_require__(111) +exports.chain = __webpack_require__(955) + + +/***/ }), /* 405 */, /* 406 */, /* 407 */ @@ -37610,86 +38362,380 @@ module.exports = bufferFrom /***/ }), /* 502 */, /* 503 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { +/***/ (function(module, __unusedexports, __webpack_require__) { -"use strict"; +module.exports = rimraf +rimraf.sync = rimrafSync +var assert = __webpack_require__(357) +var path = __webpack_require__(622) +var fs = __webpack_require__(747) +var glob = undefined +try { + glob = __webpack_require__(402) +} catch (_err) { + // treat glob as optional. +} +var _0666 = parseInt('666', 8) -var util = __webpack_require__(669); +var defaultGlobOpts = { + nosort: true, + silent: true +} -function toString(val) { - val = val.toString(8); - while (val.length < 4) { - val = "0" + val; - } - return val; +// for EMFILE handling +var timeout = 0 + +var isWindows = (process.platform === "win32") + +function defaults (options) { + var methods = [ + 'unlink', + 'chmod', + 'stat', + 'lstat', + 'rmdir', + 'readdir' + ] + methods.forEach(function(m) { + options[m] = options[m] || fs[m] + m = m + 'Sync' + options[m] = options[m] || fs[m] + }) + + options.maxBusyTries = options.maxBusyTries || 3 + options.emfileWait = options.emfileWait || 1000 + if (options.glob === false) { + options.disableGlob = true + } + if (options.disableGlob !== true && glob === undefined) { + throw Error('glob dependency not found, set `options.disableGlob = true` if intentional') + } + options.disableGlob = options.disableGlob || false + options.glob = options.glob || defaultGlobOpts } -var defaultUmask = 18; // 0022; -var defaultUmaskString = toString(defaultUmask); +function rimraf (p, options, cb) { + if (typeof options === 'function') { + cb = options + options = {} + } -function validate(data, k, val) { - // must be either an integer or an octal string. - if (typeof val === "number" && !isNaN(val)) { - data[k] = val; - return true; - } + assert(p, 'rimraf: missing path') + assert.equal(typeof p, 'string', 'rimraf: path should be a string') + assert.equal(typeof cb, 'function', 'rimraf: callback function required') + assert(options, 'rimraf: invalid options argument provided') + assert.equal(typeof options, 'object', 'rimraf: options should be object') - if (typeof val === "string") { - if (val.charAt(0) !== "0") { - return false; + defaults(options) + + var busyTries = 0 + var errState = null + var n = 0 + + if (options.disableGlob || !glob.hasMagic(p)) + return afterGlob(null, [p]) + + options.lstat(p, function (er, stat) { + if (!er) + return afterGlob(null, [p]) + + glob(p, options.glob, afterGlob) + }) + + function next (er) { + errState = errState || er + if (--n === 0) + cb(errState) + } + + function afterGlob (er, results) { + if (er) + return cb(er) + + n = results.length + if (n === 0) + return cb() + + results.forEach(function (p) { + rimraf_(p, options, function CB (er) { + if (er) { + if ((er.code === "EBUSY" || er.code === "ENOTEMPTY" || er.code === "EPERM") && + busyTries < options.maxBusyTries) { + busyTries ++ + var time = busyTries * 100 + // try again, with the same exact callback as this one. + return setTimeout(function () { + rimraf_(p, options, CB) + }, time) + } + + // this one won't happen if graceful-fs is used. + if (er.code === "EMFILE" && timeout < options.emfileWait) { + return setTimeout(function () { + rimraf_(p, options, CB) + }, timeout ++) + } + + // already gone + if (er.code === "ENOENT") er = null } - data[k] = parseInt(val, 8); - return true; - } - return false; + timeout = 0 + next(er) + }) + }) + } } -function convert_fromString(val, cb) { - if (typeof val === "string") { - // check for octal string first - if (val.charAt(0) === '0' && /^[0-7]+$/.test(val)) { - val = parseInt(val, 8); - } else if (val.charAt(0) !== '0' && /^[0-9]+$/.test(val)) { - // legacy support for decimal strings - val = parseInt(val, 10); - } else { - return cb(new Error(util.format("Expected octal string, got %j, defaulting to %j", - val, defaultUmaskString)), - defaultUmask); - } - } else if (typeof val !== "number") { - return cb(new Error(util.format("Expected number or octal string, got %j, defaulting to %j", - val, defaultUmaskString)), - defaultUmask); +// Two possible strategies. +// 1. Assume it's a file. unlink it, then do the dir stuff on EPERM or EISDIR +// 2. Assume it's a directory. readdir, then do the file stuff on ENOTDIR +// +// Both result in an extra syscall when you guess wrong. However, there +// are likely far more normal files in the world than directories. This +// is based on the assumption that a the average number of files per +// directory is >= 1. +// +// If anyone ever complains about this, then I guess the strategy could +// be made configurable somehow. But until then, YAGNI. +function rimraf_ (p, options, cb) { + assert(p) + assert(options) + assert(typeof cb === 'function') + + // sunos lets the root user unlink directories, which is... weird. + // so we have to lstat here and make sure it's not a dir. + options.lstat(p, function (er, st) { + if (er && er.code === "ENOENT") + return cb(null) + + // Windows can EPERM on stat. Life is suffering. + if (er && er.code === "EPERM" && isWindows) + fixWinEPERM(p, options, er, cb) + + if (st && st.isDirectory()) + return rmdir(p, options, er, cb) + + options.unlink(p, function (er) { + if (er) { + if (er.code === "ENOENT") + return cb(null) + if (er.code === "EPERM") + return (isWindows) + ? fixWinEPERM(p, options, er, cb) + : rmdir(p, options, er, cb) + if (er.code === "EISDIR") + return rmdir(p, options, er, cb) + } + return cb(er) + }) + }) +} + +function fixWinEPERM (p, options, er, cb) { + assert(p) + assert(options) + assert(typeof cb === 'function') + if (er) + assert(er instanceof Error) + + options.chmod(p, _0666, function (er2) { + if (er2) + cb(er2.code === "ENOENT" ? null : er) + else + options.stat(p, function(er3, stats) { + if (er3) + cb(er3.code === "ENOENT" ? null : er) + else if (stats.isDirectory()) + rmdir(p, options, er, cb) + else + options.unlink(p, cb) + }) + }) +} + +function fixWinEPERMSync (p, options, er) { + assert(p) + assert(options) + if (er) + assert(er instanceof Error) + + try { + options.chmodSync(p, _0666) + } catch (er2) { + if (er2.code === "ENOENT") + return + else + throw er + } + + try { + var stats = options.statSync(p) + } catch (er3) { + if (er3.code === "ENOENT") + return + else + throw er + } + + if (stats.isDirectory()) + rmdirSync(p, options, er) + else + options.unlinkSync(p) +} + +function rmdir (p, options, originalEr, cb) { + assert(p) + assert(options) + if (originalEr) + assert(originalEr instanceof Error) + assert(typeof cb === 'function') + + // try to rmdir first, and only readdir on ENOTEMPTY or EEXIST (SunOS) + // if we guessed wrong, and it's not a directory, then + // raise the original error. + options.rmdir(p, function (er) { + if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM")) + rmkids(p, options, cb) + else if (er && er.code === "ENOTDIR") + cb(originalEr) + else + cb(er) + }) +} + +function rmkids(p, options, cb) { + assert(p) + assert(options) + assert(typeof cb === 'function') + + options.readdir(p, function (er, files) { + if (er) + return cb(er) + var n = files.length + if (n === 0) + return options.rmdir(p, cb) + var errState + files.forEach(function (f) { + rimraf(path.join(p, f), options, function (er) { + if (errState) + return + if (er) + return cb(errState = er) + if (--n === 0) + options.rmdir(p, cb) + }) + }) + }) +} + +// this looks simpler, and is strictly *faster*, but will +// tie up the JavaScript thread and fail on excessively +// deep directory trees. +function rimrafSync (p, options) { + options = options || {} + defaults(options) + + assert(p, 'rimraf: missing path') + assert.equal(typeof p, 'string', 'rimraf: path should be a string') + assert(options, 'rimraf: missing options') + assert.equal(typeof options, 'object', 'rimraf: options should be object') + + var results + + if (options.disableGlob || !glob.hasMagic(p)) { + results = [p] + } else { + try { + options.lstatSync(p) + results = [p] + } catch (er) { + results = glob.sync(p, options.glob) } + } - val = Math.floor(val); + if (!results.length) + return - if ((val < 0) || (val > 511)) { - return cb(new Error(util.format("Must be in range 0..511 (0000..0777), got %j", val)), - defaultUmask); + for (var i = 0; i < results.length; i++) { + var p = results[i] + + try { + var st = options.lstatSync(p) + } catch (er) { + if (er.code === "ENOENT") + return + + // Windows can EPERM on stat. Life is suffering. + if (er.code === "EPERM" && isWindows) + fixWinEPERMSync(p, options, er) } - cb(null, val); -} + try { + // sunos lets the root user unlink directories, which is... weird. + if (st && st.isDirectory()) + rmdirSync(p, options, null) + else + options.unlinkSync(p) + } catch (er) { + if (er.code === "ENOENT") + return + if (er.code === "EPERM") + return isWindows ? fixWinEPERMSync(p, options, er) : rmdirSync(p, options, er) + if (er.code !== "EISDIR") + throw er -function fromString(val, cb) { + rmdirSync(p, options, er) + } + } +} - // synchronous callback, no zalgo - convert_fromString(val, cb || function (err, result) { - /*jslint unparam:true*/ - val = result; - }); +function rmdirSync (p, options, originalEr) { + assert(p) + assert(options) + if (originalEr) + assert(originalEr instanceof Error) - return val; + try { + options.rmdirSync(p) + } catch (er) { + if (er.code === "ENOENT") + return + if (er.code === "ENOTDIR") + throw originalEr + if (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM") + rmkidsSync(p, options) + } } -exports.toString = toString; -exports.fromString = fromString; -exports.validate = validate; +function rmkidsSync (p, options) { + assert(p) + assert(options) + options.readdirSync(p).forEach(function (f) { + rimrafSync(path.join(p, f), options) + }) + // We only end up here once we got ENOTEMPTY at least once, and + // at this point, we are guaranteed to have removed all the kids. + // So, we know that it won't be ENOENT or ENOTDIR or anything else. + // try really hard to delete stuff on windows, because it has a + // PROFOUNDLY annoying habit of not closing handles promptly when + // files are deleted, resulting in spurious ENOTEMPTY errors. + var retries = isWindows ? 100 : 1 + var i = 0 + do { + var threw = true + try { + var ret = options.rmdirSync(p, options) + threw = false + return ret + } finally { + if (++i < retries && threw) + continue + } + } while (true) +} /***/ }), @@ -39983,7 +41029,7 @@ const moveFile = __webpack_require__(762) const PassThrough = __webpack_require__(794).PassThrough const path = __webpack_require__(622) const pipe = BB.promisify(__webpack_require__(371).pipe) -const rimraf = BB.promisify(__webpack_require__(569)) +const rimraf = BB.promisify(__webpack_require__(503)) const ssri = __webpack_require__(951) const to = __webpack_require__(371).to const uniqueFilename = __webpack_require__(106) @@ -42112,7 +43158,7 @@ var path = __webpack_require__(622) var validate = __webpack_require__(140) var stockWriteStreamAtomic = __webpack_require__(490) var mkdirp = __webpack_require__(626) -var rimraf = __webpack_require__(569) +var rimraf = __webpack_require__(10) var isWindows = __webpack_require__(725) var RunQueue = __webpack_require__(399) var extend = Object.assign || __webpack_require__(669)._extend @@ -43453,378 +44499,11 @@ Gauge.prototype._doRedraw = function () { /* 569 */ /***/ (function(module, __unusedexports, __webpack_require__) { -module.exports = rimraf -rimraf.sync = rimrafSync - -var assert = __webpack_require__(357) -var path = __webpack_require__(622) -var fs = __webpack_require__(747) -var glob = undefined -try { - glob = __webpack_require__(402) -} catch (_err) { - // treat glob as optional. -} -var _0666 = parseInt('666', 8) - -var defaultGlobOpts = { - nosort: true, - silent: true -} - -// for EMFILE handling -var timeout = 0 - -var isWindows = (process.platform === "win32") - -function defaults (options) { - var methods = [ - 'unlink', - 'chmod', - 'stat', - 'lstat', - 'rmdir', - 'readdir' - ] - methods.forEach(function(m) { - options[m] = options[m] || fs[m] - m = m + 'Sync' - options[m] = options[m] || fs[m] - }) - - options.maxBusyTries = options.maxBusyTries || 3 - options.emfileWait = options.emfileWait || 1000 - if (options.glob === false) { - options.disableGlob = true - } - if (options.disableGlob !== true && glob === undefined) { - throw Error('glob dependency not found, set `options.disableGlob = true` if intentional') - } - options.disableGlob = options.disableGlob || false - options.glob = options.glob || defaultGlobOpts -} - -function rimraf (p, options, cb) { - if (typeof options === 'function') { - cb = options - options = {} - } - - assert(p, 'rimraf: missing path') - assert.equal(typeof p, 'string', 'rimraf: path should be a string') - assert.equal(typeof cb, 'function', 'rimraf: callback function required') - assert(options, 'rimraf: invalid options argument provided') - assert.equal(typeof options, 'object', 'rimraf: options should be object') - - defaults(options) - - var busyTries = 0 - var errState = null - var n = 0 - - if (options.disableGlob || !glob.hasMagic(p)) - return afterGlob(null, [p]) - - options.lstat(p, function (er, stat) { - if (!er) - return afterGlob(null, [p]) - - glob(p, options.glob, afterGlob) - }) - - function next (er) { - errState = errState || er - if (--n === 0) - cb(errState) - } - - function afterGlob (er, results) { - if (er) - return cb(er) - - n = results.length - if (n === 0) - return cb() - - results.forEach(function (p) { - rimraf_(p, options, function CB (er) { - if (er) { - if ((er.code === "EBUSY" || er.code === "ENOTEMPTY" || er.code === "EPERM") && - busyTries < options.maxBusyTries) { - busyTries ++ - var time = busyTries * 100 - // try again, with the same exact callback as this one. - return setTimeout(function () { - rimraf_(p, options, CB) - }, time) - } - - // this one won't happen if graceful-fs is used. - if (er.code === "EMFILE" && timeout < options.emfileWait) { - return setTimeout(function () { - rimraf_(p, options, CB) - }, timeout ++) - } - - // already gone - if (er.code === "ENOENT") er = null - } - - timeout = 0 - next(er) - }) - }) - } -} - -// Two possible strategies. -// 1. Assume it's a file. unlink it, then do the dir stuff on EPERM or EISDIR -// 2. Assume it's a directory. readdir, then do the file stuff on ENOTDIR -// -// Both result in an extra syscall when you guess wrong. However, there -// are likely far more normal files in the world than directories. This -// is based on the assumption that a the average number of files per -// directory is >= 1. -// -// If anyone ever complains about this, then I guess the strategy could -// be made configurable somehow. But until then, YAGNI. -function rimraf_ (p, options, cb) { - assert(p) - assert(options) - assert(typeof cb === 'function') - - // sunos lets the root user unlink directories, which is... weird. - // so we have to lstat here and make sure it's not a dir. - options.lstat(p, function (er, st) { - if (er && er.code === "ENOENT") - return cb(null) - - // Windows can EPERM on stat. Life is suffering. - if (er && er.code === "EPERM" && isWindows) - fixWinEPERM(p, options, er, cb) - - if (st && st.isDirectory()) - return rmdir(p, options, er, cb) - - options.unlink(p, function (er) { - if (er) { - if (er.code === "ENOENT") - return cb(null) - if (er.code === "EPERM") - return (isWindows) - ? fixWinEPERM(p, options, er, cb) - : rmdir(p, options, er, cb) - if (er.code === "EISDIR") - return rmdir(p, options, er, cb) - } - return cb(er) - }) - }) -} - -function fixWinEPERM (p, options, er, cb) { - assert(p) - assert(options) - assert(typeof cb === 'function') - if (er) - assert(er instanceof Error) - - options.chmod(p, _0666, function (er2) { - if (er2) - cb(er2.code === "ENOENT" ? null : er) - else - options.stat(p, function(er3, stats) { - if (er3) - cb(er3.code === "ENOENT" ? null : er) - else if (stats.isDirectory()) - rmdir(p, options, er, cb) - else - options.unlink(p, cb) - }) - }) -} - -function fixWinEPERMSync (p, options, er) { - assert(p) - assert(options) - if (er) - assert(er instanceof Error) - - try { - options.chmodSync(p, _0666) - } catch (er2) { - if (er2.code === "ENOENT") - return - else - throw er - } - - try { - var stats = options.statSync(p) - } catch (er3) { - if (er3.code === "ENOENT") - return - else - throw er - } - - if (stats.isDirectory()) - rmdirSync(p, options, er) - else - options.unlinkSync(p) -} - -function rmdir (p, options, originalEr, cb) { - assert(p) - assert(options) - if (originalEr) - assert(originalEr instanceof Error) - assert(typeof cb === 'function') - - // try to rmdir first, and only readdir on ENOTEMPTY or EEXIST (SunOS) - // if we guessed wrong, and it's not a directory, then - // raise the original error. - options.rmdir(p, function (er) { - if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM")) - rmkids(p, options, cb) - else if (er && er.code === "ENOTDIR") - cb(originalEr) - else - cb(er) - }) -} - -function rmkids(p, options, cb) { - assert(p) - assert(options) - assert(typeof cb === 'function') - - options.readdir(p, function (er, files) { - if (er) - return cb(er) - var n = files.length - if (n === 0) - return options.rmdir(p, cb) - var errState - files.forEach(function (f) { - rimraf(path.join(p, f), options, function (er) { - if (errState) - return - if (er) - return cb(errState = er) - if (--n === 0) - options.rmdir(p, cb) - }) - }) - }) -} - -// this looks simpler, and is strictly *faster*, but will -// tie up the JavaScript thread and fail on excessively -// deep directory trees. -function rimrafSync (p, options) { - options = options || {} - defaults(options) - - assert(p, 'rimraf: missing path') - assert.equal(typeof p, 'string', 'rimraf: path should be a string') - assert(options, 'rimraf: missing options') - assert.equal(typeof options, 'object', 'rimraf: options should be object') - - var results - - if (options.disableGlob || !glob.hasMagic(p)) { - results = [p] - } else { - try { - options.lstatSync(p) - results = [p] - } catch (er) { - results = glob.sync(p, options.glob) - } - } - - if (!results.length) - return - - for (var i = 0; i < results.length; i++) { - var p = results[i] - - try { - var st = options.lstatSync(p) - } catch (er) { - if (er.code === "ENOENT") - return - - // Windows can EPERM on stat. Life is suffering. - if (er.code === "EPERM" && isWindows) - fixWinEPERMSync(p, options, er) - } - - try { - // sunos lets the root user unlink directories, which is... weird. - if (st && st.isDirectory()) - rmdirSync(p, options, null) - else - options.unlinkSync(p) - } catch (er) { - if (er.code === "ENOENT") - return - if (er.code === "EPERM") - return isWindows ? fixWinEPERMSync(p, options, er) : rmdirSync(p, options, er) - if (er.code !== "EISDIR") - throw er - - rmdirSync(p, options, er) - } - } -} - -function rmdirSync (p, options, originalEr) { - assert(p) - assert(options) - if (originalEr) - assert(originalEr instanceof Error) - - try { - options.rmdirSync(p) - } catch (er) { - if (er.code === "ENOENT") - return - if (er.code === "ENOTDIR") - throw originalEr - if (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM") - rmkidsSync(p, options) - } -} +"use strict"; -function rmkidsSync (p, options) { - assert(p) - assert(options) - options.readdirSync(p).forEach(function (f) { - rimrafSync(path.join(p, f), options) - }) +const ansiRegex = __webpack_require__(448); - // We only end up here once we got ENOTEMPTY at least once, and - // at this point, we are guaranteed to have removed all the kids. - // So, we know that it won't be ENOENT or ENOTDIR or anything else. - // try really hard to delete stuff on windows, because it has a - // PROFOUNDLY annoying habit of not closing handles promptly when - // files are deleted, resulting in spurious ENOTEMPTY errors. - var retries = isWindows ? 100 : 1 - var i = 0 - do { - var threw = true - try { - var ret = options.rmdirSync(p, options) - threw = false - return ret - } finally { - if (++i < retries && threw) - continue - } - } while (true) -} +module.exports = input => typeof input === 'string' ? input.replace(ansiRegex(), '') : input; /***/ }), @@ -43839,8 +44518,8 @@ const validate = __webpack_require__(408) const fs = __webpack_require__(598) const isInside = __webpack_require__(994) const vacuum = __webpack_require__(107) -const chain = __webpack_require__(993).chain -const asyncMap = __webpack_require__(993).asyncMap +const chain = __webpack_require__(404).chain +const asyncMap = __webpack_require__(404).asyncMap const readCmdShim = __webpack_require__(647) const iferr = __webpack_require__(332) @@ -52532,7 +53211,90 @@ Promise.prototype.asCallback = Promise.prototype.nodeify = function (nodeback, /***/ }), /* 695 */, -/* 696 */, +/* 696 */ +/***/ (function(__unusedmodule, exports, __webpack_require__) { + +"use strict"; + + +var util = __webpack_require__(669); + +function toString(val) { + val = val.toString(8); + while (val.length < 4) { + val = "0" + val; + } + return val; +} + +var defaultUmask = 18; // 0022; +var defaultUmaskString = toString(defaultUmask); + +function validate(data, k, val) { + // must be either an integer or an octal string. + if (typeof val === "number" && !isNaN(val)) { + data[k] = val; + return true; + } + + if (typeof val === "string") { + if (val.charAt(0) !== "0") { + return false; + } + data[k] = parseInt(val, 8); + return true; + } + + return false; +} + +function convert_fromString(val, cb) { + if (typeof val === "string") { + // check for octal string first + if (val.charAt(0) === '0' && /^[0-7]+$/.test(val)) { + val = parseInt(val, 8); + } else if (val.charAt(0) !== '0' && /^[0-9]+$/.test(val)) { + // legacy support for decimal strings + val = parseInt(val, 10); + } else { + return cb(new Error(util.format("Expected octal string, got %j, defaulting to %j", + val, defaultUmaskString)), + defaultUmask); + } + } else if (typeof val !== "number") { + return cb(new Error(util.format("Expected number or octal string, got %j, defaulting to %j", + val, defaultUmaskString)), + defaultUmask); + } + + val = Math.floor(val); + + if ((val < 0) || (val > 511)) { + return cb(new Error(util.format("Must be in range 0..511 (0000..0777), got %j", val)), + defaultUmask); + } + + cb(null, val); +} + +function fromString(val, cb) { + + // synchronous callback, no zalgo + convert_fromString(val, cb || function (err, result) { + /*jslint unparam:true*/ + val = result; + }); + + return val; +} + +exports.toString = toString; +exports.fromString = fromString; +exports.validate = validate; + + + +/***/ }), /* 697 */ /***/ (function(module, __unusedexports, __webpack_require__) { @@ -52942,7 +53704,7 @@ const BB = __webpack_require__(440) const index = __webpack_require__(407) const memo = __webpack_require__(69) const path = __webpack_require__(622) -const rimraf = BB.promisify(__webpack_require__(569)) +const rimraf = BB.promisify(__webpack_require__(503)) const rmContent = __webpack_require__(849) module.exports = entry @@ -60644,7 +61406,7 @@ const BB = __webpack_require__(440) const contentPath = __webpack_require__(969) const hasContent = __webpack_require__(185).hasContent -const rimraf = BB.promisify(__webpack_require__(569)) +const rimraf = BB.promisify(__webpack_require__(503)) module.exports = rm function rm (cache, integrity) { @@ -61856,7 +62618,7 @@ const BB = __webpack_require__(440) const figgyPudding = __webpack_require__(122) const fixOwner = __webpack_require__(133) const path = __webpack_require__(622) -const rimraf = BB.promisify(__webpack_require__(569)) +const rimraf = BB.promisify(__webpack_require__(503)) const uniqueFilename = __webpack_require__(106) const TmpOpts = figgyPudding({ @@ -64666,7 +65428,7 @@ module.exports = __webpack_require__(968) "use strict"; -const stripAnsi = __webpack_require__(330); +const stripAnsi = __webpack_require__(569); const isFullwidthCodePoint = __webpack_require__(363); module.exports = str => { @@ -68009,7 +68771,7 @@ const mkdirp = BB.promisify(__webpack_require__(626)) const npa = __webpack_require__(482) const optCheck = __webpack_require__(420) const path = __webpack_require__(622) -const rimraf = BB.promisify(__webpack_require__(569)) +const rimraf = BB.promisify(__webpack_require__(985)) const withTarballStream = __webpack_require__(803) const inferOwner = __webpack_require__(686) const chown = BB.promisify(__webpack_require__(427)) @@ -68316,7 +69078,7 @@ const npa = __webpack_require__(482) const optCheck = __webpack_require__(420) const PassThrough = __webpack_require__(794).PassThrough const path = __webpack_require__(622) -const rimraf = BB.promisify(__webpack_require__(569)) +const rimraf = BB.promisify(__webpack_require__(985)) const withTarballStream = __webpack_require__(803) module.exports = tarball @@ -69740,7 +70502,384 @@ __webpack_require__(610)(Promise, INTERNAL); /***/ }), /* 984 */, -/* 985 */, +/* 985 */ +/***/ (function(module, __unusedexports, __webpack_require__) { + +module.exports = rimraf +rimraf.sync = rimrafSync + +var assert = __webpack_require__(357) +var path = __webpack_require__(622) +var fs = __webpack_require__(747) +var glob = undefined +try { + glob = __webpack_require__(402) +} catch (_err) { + // treat glob as optional. +} +var _0666 = parseInt('666', 8) + +var defaultGlobOpts = { + nosort: true, + silent: true +} + +// for EMFILE handling +var timeout = 0 + +var isWindows = (process.platform === "win32") + +function defaults (options) { + var methods = [ + 'unlink', + 'chmod', + 'stat', + 'lstat', + 'rmdir', + 'readdir' + ] + methods.forEach(function(m) { + options[m] = options[m] || fs[m] + m = m + 'Sync' + options[m] = options[m] || fs[m] + }) + + options.maxBusyTries = options.maxBusyTries || 3 + options.emfileWait = options.emfileWait || 1000 + if (options.glob === false) { + options.disableGlob = true + } + if (options.disableGlob !== true && glob === undefined) { + throw Error('glob dependency not found, set `options.disableGlob = true` if intentional') + } + options.disableGlob = options.disableGlob || false + options.glob = options.glob || defaultGlobOpts +} + +function rimraf (p, options, cb) { + if (typeof options === 'function') { + cb = options + options = {} + } + + assert(p, 'rimraf: missing path') + assert.equal(typeof p, 'string', 'rimraf: path should be a string') + assert.equal(typeof cb, 'function', 'rimraf: callback function required') + assert(options, 'rimraf: invalid options argument provided') + assert.equal(typeof options, 'object', 'rimraf: options should be object') + + defaults(options) + + var busyTries = 0 + var errState = null + var n = 0 + + if (options.disableGlob || !glob.hasMagic(p)) + return afterGlob(null, [p]) + + options.lstat(p, function (er, stat) { + if (!er) + return afterGlob(null, [p]) + + glob(p, options.glob, afterGlob) + }) + + function next (er) { + errState = errState || er + if (--n === 0) + cb(errState) + } + + function afterGlob (er, results) { + if (er) + return cb(er) + + n = results.length + if (n === 0) + return cb() + + results.forEach(function (p) { + rimraf_(p, options, function CB (er) { + if (er) { + if ((er.code === "EBUSY" || er.code === "ENOTEMPTY" || er.code === "EPERM") && + busyTries < options.maxBusyTries) { + busyTries ++ + var time = busyTries * 100 + // try again, with the same exact callback as this one. + return setTimeout(function () { + rimraf_(p, options, CB) + }, time) + } + + // this one won't happen if graceful-fs is used. + if (er.code === "EMFILE" && timeout < options.emfileWait) { + return setTimeout(function () { + rimraf_(p, options, CB) + }, timeout ++) + } + + // already gone + if (er.code === "ENOENT") er = null + } + + timeout = 0 + next(er) + }) + }) + } +} + +// Two possible strategies. +// 1. Assume it's a file. unlink it, then do the dir stuff on EPERM or EISDIR +// 2. Assume it's a directory. readdir, then do the file stuff on ENOTDIR +// +// Both result in an extra syscall when you guess wrong. However, there +// are likely far more normal files in the world than directories. This +// is based on the assumption that a the average number of files per +// directory is >= 1. +// +// If anyone ever complains about this, then I guess the strategy could +// be made configurable somehow. But until then, YAGNI. +function rimraf_ (p, options, cb) { + assert(p) + assert(options) + assert(typeof cb === 'function') + + // sunos lets the root user unlink directories, which is... weird. + // so we have to lstat here and make sure it's not a dir. + options.lstat(p, function (er, st) { + if (er && er.code === "ENOENT") + return cb(null) + + // Windows can EPERM on stat. Life is suffering. + if (er && er.code === "EPERM" && isWindows) + fixWinEPERM(p, options, er, cb) + + if (st && st.isDirectory()) + return rmdir(p, options, er, cb) + + options.unlink(p, function (er) { + if (er) { + if (er.code === "ENOENT") + return cb(null) + if (er.code === "EPERM") + return (isWindows) + ? fixWinEPERM(p, options, er, cb) + : rmdir(p, options, er, cb) + if (er.code === "EISDIR") + return rmdir(p, options, er, cb) + } + return cb(er) + }) + }) +} + +function fixWinEPERM (p, options, er, cb) { + assert(p) + assert(options) + assert(typeof cb === 'function') + if (er) + assert(er instanceof Error) + + options.chmod(p, _0666, function (er2) { + if (er2) + cb(er2.code === "ENOENT" ? null : er) + else + options.stat(p, function(er3, stats) { + if (er3) + cb(er3.code === "ENOENT" ? null : er) + else if (stats.isDirectory()) + rmdir(p, options, er, cb) + else + options.unlink(p, cb) + }) + }) +} + +function fixWinEPERMSync (p, options, er) { + assert(p) + assert(options) + if (er) + assert(er instanceof Error) + + try { + options.chmodSync(p, _0666) + } catch (er2) { + if (er2.code === "ENOENT") + return + else + throw er + } + + try { + var stats = options.statSync(p) + } catch (er3) { + if (er3.code === "ENOENT") + return + else + throw er + } + + if (stats.isDirectory()) + rmdirSync(p, options, er) + else + options.unlinkSync(p) +} + +function rmdir (p, options, originalEr, cb) { + assert(p) + assert(options) + if (originalEr) + assert(originalEr instanceof Error) + assert(typeof cb === 'function') + + // try to rmdir first, and only readdir on ENOTEMPTY or EEXIST (SunOS) + // if we guessed wrong, and it's not a directory, then + // raise the original error. + options.rmdir(p, function (er) { + if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM")) + rmkids(p, options, cb) + else if (er && er.code === "ENOTDIR") + cb(originalEr) + else + cb(er) + }) +} + +function rmkids(p, options, cb) { + assert(p) + assert(options) + assert(typeof cb === 'function') + + options.readdir(p, function (er, files) { + if (er) + return cb(er) + var n = files.length + if (n === 0) + return options.rmdir(p, cb) + var errState + files.forEach(function (f) { + rimraf(path.join(p, f), options, function (er) { + if (errState) + return + if (er) + return cb(errState = er) + if (--n === 0) + options.rmdir(p, cb) + }) + }) + }) +} + +// this looks simpler, and is strictly *faster*, but will +// tie up the JavaScript thread and fail on excessively +// deep directory trees. +function rimrafSync (p, options) { + options = options || {} + defaults(options) + + assert(p, 'rimraf: missing path') + assert.equal(typeof p, 'string', 'rimraf: path should be a string') + assert(options, 'rimraf: missing options') + assert.equal(typeof options, 'object', 'rimraf: options should be object') + + var results + + if (options.disableGlob || !glob.hasMagic(p)) { + results = [p] + } else { + try { + options.lstatSync(p) + results = [p] + } catch (er) { + results = glob.sync(p, options.glob) + } + } + + if (!results.length) + return + + for (var i = 0; i < results.length; i++) { + var p = results[i] + + try { + var st = options.lstatSync(p) + } catch (er) { + if (er.code === "ENOENT") + return + + // Windows can EPERM on stat. Life is suffering. + if (er.code === "EPERM" && isWindows) + fixWinEPERMSync(p, options, er) + } + + try { + // sunos lets the root user unlink directories, which is... weird. + if (st && st.isDirectory()) + rmdirSync(p, options, null) + else + options.unlinkSync(p) + } catch (er) { + if (er.code === "ENOENT") + return + if (er.code === "EPERM") + return isWindows ? fixWinEPERMSync(p, options, er) : rmdirSync(p, options, er) + if (er.code !== "EISDIR") + throw er + + rmdirSync(p, options, er) + } + } +} + +function rmdirSync (p, options, originalEr) { + assert(p) + assert(options) + if (originalEr) + assert(originalEr instanceof Error) + + try { + options.rmdirSync(p) + } catch (er) { + if (er.code === "ENOENT") + return + if (er.code === "ENOTDIR") + throw originalEr + if (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM") + rmkidsSync(p, options) + } +} + +function rmkidsSync (p, options) { + assert(p) + assert(options) + options.readdirSync(p).forEach(function (f) { + rimrafSync(path.join(p, f), options) + }) + + // We only end up here once we got ENOTEMPTY at least once, and + // at this point, we are guaranteed to have removed all the kids. + // So, we know that it won't be ENOENT or ENOTDIR or anything else. + // try really hard to delete stuff on windows, because it has a + // PROFOUNDLY annoying habit of not closing handles promptly when + // files are deleted, resulting in spurious ENOTEMPTY errors. + var retries = isWindows ? 100 : 1 + var i = 0 + do { + var threw = true + try { + var ret = options.rmdirSync(p, options) + threw = false + return ret + } finally { + if (++i < retries && threw) + continue + } + } while (true) +} + + +/***/ }), /* 986 */ /***/ (function(__unusedmodule, exports, __webpack_require__) { @@ -70171,11 +71310,380 @@ function alignCenter (str, width) { /***/ }), /* 992 */, /* 993 */ -/***/ (function(__unusedmodule, exports, __webpack_require__) { +/***/ (function(module, __unusedexports, __webpack_require__) { -exports.asyncMap = __webpack_require__(943) -exports.bindActor = __webpack_require__(111) -exports.chain = __webpack_require__(955) +module.exports = rimraf +rimraf.sync = rimrafSync + +var assert = __webpack_require__(357) +var path = __webpack_require__(622) +var fs = __webpack_require__(747) +var glob = undefined +try { + glob = __webpack_require__(402) +} catch (_err) { + // treat glob as optional. +} +var _0666 = parseInt('666', 8) + +var defaultGlobOpts = { + nosort: true, + silent: true +} + +// for EMFILE handling +var timeout = 0 + +var isWindows = (process.platform === "win32") + +function defaults (options) { + var methods = [ + 'unlink', + 'chmod', + 'stat', + 'lstat', + 'rmdir', + 'readdir' + ] + methods.forEach(function(m) { + options[m] = options[m] || fs[m] + m = m + 'Sync' + options[m] = options[m] || fs[m] + }) + + options.maxBusyTries = options.maxBusyTries || 3 + options.emfileWait = options.emfileWait || 1000 + if (options.glob === false) { + options.disableGlob = true + } + if (options.disableGlob !== true && glob === undefined) { + throw Error('glob dependency not found, set `options.disableGlob = true` if intentional') + } + options.disableGlob = options.disableGlob || false + options.glob = options.glob || defaultGlobOpts +} + +function rimraf (p, options, cb) { + if (typeof options === 'function') { + cb = options + options = {} + } + + assert(p, 'rimraf: missing path') + assert.equal(typeof p, 'string', 'rimraf: path should be a string') + assert.equal(typeof cb, 'function', 'rimraf: callback function required') + assert(options, 'rimraf: invalid options argument provided') + assert.equal(typeof options, 'object', 'rimraf: options should be object') + + defaults(options) + + var busyTries = 0 + var errState = null + var n = 0 + + if (options.disableGlob || !glob.hasMagic(p)) + return afterGlob(null, [p]) + + options.lstat(p, function (er, stat) { + if (!er) + return afterGlob(null, [p]) + + glob(p, options.glob, afterGlob) + }) + + function next (er) { + errState = errState || er + if (--n === 0) + cb(errState) + } + + function afterGlob (er, results) { + if (er) + return cb(er) + + n = results.length + if (n === 0) + return cb() + + results.forEach(function (p) { + rimraf_(p, options, function CB (er) { + if (er) { + if ((er.code === "EBUSY" || er.code === "ENOTEMPTY" || er.code === "EPERM") && + busyTries < options.maxBusyTries) { + busyTries ++ + var time = busyTries * 100 + // try again, with the same exact callback as this one. + return setTimeout(function () { + rimraf_(p, options, CB) + }, time) + } + + // this one won't happen if graceful-fs is used. + if (er.code === "EMFILE" && timeout < options.emfileWait) { + return setTimeout(function () { + rimraf_(p, options, CB) + }, timeout ++) + } + + // already gone + if (er.code === "ENOENT") er = null + } + + timeout = 0 + next(er) + }) + }) + } +} + +// Two possible strategies. +// 1. Assume it's a file. unlink it, then do the dir stuff on EPERM or EISDIR +// 2. Assume it's a directory. readdir, then do the file stuff on ENOTDIR +// +// Both result in an extra syscall when you guess wrong. However, there +// are likely far more normal files in the world than directories. This +// is based on the assumption that a the average number of files per +// directory is >= 1. +// +// If anyone ever complains about this, then I guess the strategy could +// be made configurable somehow. But until then, YAGNI. +function rimraf_ (p, options, cb) { + assert(p) + assert(options) + assert(typeof cb === 'function') + + // sunos lets the root user unlink directories, which is... weird. + // so we have to lstat here and make sure it's not a dir. + options.lstat(p, function (er, st) { + if (er && er.code === "ENOENT") + return cb(null) + + // Windows can EPERM on stat. Life is suffering. + if (er && er.code === "EPERM" && isWindows) + fixWinEPERM(p, options, er, cb) + + if (st && st.isDirectory()) + return rmdir(p, options, er, cb) + + options.unlink(p, function (er) { + if (er) { + if (er.code === "ENOENT") + return cb(null) + if (er.code === "EPERM") + return (isWindows) + ? fixWinEPERM(p, options, er, cb) + : rmdir(p, options, er, cb) + if (er.code === "EISDIR") + return rmdir(p, options, er, cb) + } + return cb(er) + }) + }) +} + +function fixWinEPERM (p, options, er, cb) { + assert(p) + assert(options) + assert(typeof cb === 'function') + if (er) + assert(er instanceof Error) + + options.chmod(p, _0666, function (er2) { + if (er2) + cb(er2.code === "ENOENT" ? null : er) + else + options.stat(p, function(er3, stats) { + if (er3) + cb(er3.code === "ENOENT" ? null : er) + else if (stats.isDirectory()) + rmdir(p, options, er, cb) + else + options.unlink(p, cb) + }) + }) +} + +function fixWinEPERMSync (p, options, er) { + assert(p) + assert(options) + if (er) + assert(er instanceof Error) + + try { + options.chmodSync(p, _0666) + } catch (er2) { + if (er2.code === "ENOENT") + return + else + throw er + } + + try { + var stats = options.statSync(p) + } catch (er3) { + if (er3.code === "ENOENT") + return + else + throw er + } + + if (stats.isDirectory()) + rmdirSync(p, options, er) + else + options.unlinkSync(p) +} + +function rmdir (p, options, originalEr, cb) { + assert(p) + assert(options) + if (originalEr) + assert(originalEr instanceof Error) + assert(typeof cb === 'function') + + // try to rmdir first, and only readdir on ENOTEMPTY or EEXIST (SunOS) + // if we guessed wrong, and it's not a directory, then + // raise the original error. + options.rmdir(p, function (er) { + if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM")) + rmkids(p, options, cb) + else if (er && er.code === "ENOTDIR") + cb(originalEr) + else + cb(er) + }) +} + +function rmkids(p, options, cb) { + assert(p) + assert(options) + assert(typeof cb === 'function') + + options.readdir(p, function (er, files) { + if (er) + return cb(er) + var n = files.length + if (n === 0) + return options.rmdir(p, cb) + var errState + files.forEach(function (f) { + rimraf(path.join(p, f), options, function (er) { + if (errState) + return + if (er) + return cb(errState = er) + if (--n === 0) + options.rmdir(p, cb) + }) + }) + }) +} + +// this looks simpler, and is strictly *faster*, but will +// tie up the JavaScript thread and fail on excessively +// deep directory trees. +function rimrafSync (p, options) { + options = options || {} + defaults(options) + + assert(p, 'rimraf: missing path') + assert.equal(typeof p, 'string', 'rimraf: path should be a string') + assert(options, 'rimraf: missing options') + assert.equal(typeof options, 'object', 'rimraf: options should be object') + + var results + + if (options.disableGlob || !glob.hasMagic(p)) { + results = [p] + } else { + try { + options.lstatSync(p) + results = [p] + } catch (er) { + results = glob.sync(p, options.glob) + } + } + + if (!results.length) + return + + for (var i = 0; i < results.length; i++) { + var p = results[i] + + try { + var st = options.lstatSync(p) + } catch (er) { + if (er.code === "ENOENT") + return + + // Windows can EPERM on stat. Life is suffering. + if (er.code === "EPERM" && isWindows) + fixWinEPERMSync(p, options, er) + } + + try { + // sunos lets the root user unlink directories, which is... weird. + if (st && st.isDirectory()) + rmdirSync(p, options, null) + else + options.unlinkSync(p) + } catch (er) { + if (er.code === "ENOENT") + return + if (er.code === "EPERM") + return isWindows ? fixWinEPERMSync(p, options, er) : rmdirSync(p, options, er) + if (er.code !== "EISDIR") + throw er + + rmdirSync(p, options, er) + } + } +} + +function rmdirSync (p, options, originalEr) { + assert(p) + assert(options) + if (originalEr) + assert(originalEr instanceof Error) + + try { + options.rmdirSync(p) + } catch (er) { + if (er.code === "ENOENT") + return + if (er.code === "ENOTDIR") + throw originalEr + if (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM") + rmkidsSync(p, options) + } +} + +function rmkidsSync (p, options) { + assert(p) + assert(options) + options.readdirSync(p).forEach(function (f) { + rimrafSync(path.join(p, f), options) + }) + + // We only end up here once we got ENOTEMPTY at least once, and + // at this point, we are guaranteed to have removed all the kids. + // So, we know that it won't be ENOENT or ENOTDIR or anything else. + // try really hard to delete stuff on windows, because it has a + // PROFOUNDLY annoying habit of not closing handles promptly when + // files are deleted, resulting in spurious ENOTEMPTY errors. + var retries = isWindows ? 100 : 1 + var i = 0 + do { + var threw = true + try { + var ret = options.rmdirSync(p, options) + threw = false + return ret + } finally { + if (++i < retries && threw) + continue + } + } while (true) +} /***/ }), diff --git a/package.json b/package.json index 2a329ec4..2c7337f7 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,8 @@ "scripts": { "test": "jest", "lint": "tsc --noEmit && eslint --ext ts ./src ./tests", - "build": "ncc build src/index.ts --out build" + "build": "ncc build src/index.ts --out build", + "clean": "rimraf build" }, "dependencies": { "@actions/cache": "github:cypress-io/github-actions-cache#8bec6cc", @@ -38,12 +39,13 @@ "husky": "^3.1.0", "jest": "^26.0.1", "jest-circus": "^26.0.1", + "rimraf": "^3.0.2", "ts-jest": "^25.5.0", "typescript": "^3.8.3" }, "husky": { "hooks": { - "pre-commit": "npm run build && git add build" + "pre-commit": "yarn build && git add build" } } } diff --git a/tests/cache.test.ts b/tests/cache.test.ts index 620c76b8..e7ff87b0 100644 --- a/tests/cache.test.ts +++ b/tests/cache.test.ts @@ -1,12 +1,13 @@ +import os from 'os'; +import { join } from 'path'; import * as remoteCache from '@actions/cache/lib'; import * as toolCache from '@actions/tool-cache'; -import os from 'os'; import * as cache from '../src/cache'; import * as utils from './utils'; describe('fromLocalCache', () => { it('fetches the version specific cache', async () => { - const path = '/path/to/local/cache'; + const path = join('path', 'to', 'local', 'cache'); // todo: check why jest wants `never` instead of `string` const find = jest.spyOn(toolCache, 'find').mockResolvedValue(path as never); const result = await cache.fromLocalCache('3.20.1'); @@ -17,8 +18,8 @@ describe('fromLocalCache', () => { describe('toLocalCache', () => { it('stores the version specific cache', async () => { - const path = '/path/to/local/cache'; - const root = '/path/from/source'; + const path = join('path', 'to', 'local', 'cache'); + const root = join('path', 'from', 'source'); const cacheDir = jest.spyOn(toolCache, 'cacheDir').mockResolvedValue(path); const result = await cache.toLocalCache(root, '3.20.1'); expect(result).toBe(path); @@ -32,7 +33,7 @@ describe('fromRemoteCache', () => { }; beforeAll(() => { - utils.setEnv('RUNNER_TOOL_CACHE', '/cache/path'); + utils.setEnv('RUNNER_TOOL_CACHE', join('cache', 'path')); }); afterAll(() => { @@ -42,7 +43,7 @@ describe('fromRemoteCache', () => { it('restores remote cache with default key', async () => { expect(await cache.fromRemoteCache('3.20.1', 'yarn')).toBeUndefined(); expect(remoteCache.restoreCache).toBeCalledWith( - `/cache/path/expo-cli/3.20.1/${os.arch()}`, + join('cache', 'path', 'expo-cli', '3.20.1', os.arch()), `expo-cli-${process.platform}-${os.arch()}-yarn-3.20.1`, `expo-cli-${process.platform}-${os.arch()}-yarn-3.20.1`, ); @@ -51,7 +52,7 @@ describe('fromRemoteCache', () => { it('restores remote cache with custom key', async () => { expect(await cache.fromRemoteCache('3.20.0', 'yarn', 'custom-cache-key')).toBeUndefined(); expect(remoteCache.restoreCache).toBeCalledWith( - `/cache/path/expo-cli/3.20.0/${os.arch()}`, + join('cache', 'path', 'expo-cli', '3.20.0', os.arch()), 'custom-cache-key', 'custom-cache-key', ); @@ -60,7 +61,7 @@ describe('fromRemoteCache', () => { it('returns path when remote cache exists', async () => { spy.restore.mockResolvedValueOnce(true); await expect(cache.fromRemoteCache('3.20.1', 'npm')).resolves.toBe( - `/cache/path/expo-cli/3.20.1/${os.arch()}`, + join('cache', 'path', 'expo-cli', '3.20.1', os.arch()), ); }); @@ -77,21 +78,21 @@ describe('toRemoteCache', () => { }; it('saves remote cache with default key', async () => { - expect(await cache.toRemoteCache('/local/path', '3.20.1', 'npm')).toBeUndefined(); + expect(await cache.toRemoteCache(join('local', 'path'), '3.20.1', 'npm')).toBeUndefined(); expect(remoteCache.saveCache).toBeCalledWith( - '/local/path', + join('local', 'path'), `expo-cli-${process.platform}-${os.arch()}-npm-3.20.1`, ); }); it('saves remote cache with custom key', async () => { - expect(await cache.toRemoteCache('/local/path', '3.20.1', 'yarn', 'custom-cache-key')).toBeUndefined(); - expect(remoteCache.saveCache).toBeCalledWith('/local/path', 'custom-cache-key'); + expect(await cache.toRemoteCache(join('local', 'path'), '3.20.1', 'yarn', 'custom-cache-key')).toBeUndefined(); + expect(remoteCache.saveCache).toBeCalledWith(join('local', 'path'), 'custom-cache-key'); }); it('fails when remote cache throws', async () => { const error = new Error('Remote cache save failed'); spy.save.mockRejectedValueOnce(error); - await expect(cache.toRemoteCache('/local/path', '3.20.1', 'yarn')).rejects.toBe(error); + await expect(cache.toRemoteCache(join('local', 'path'), '3.20.1', 'yarn')).rejects.toBe(error); }); }); diff --git a/tests/expo.test.ts b/tests/expo.test.ts index 1baf8751..eee781b9 100644 --- a/tests/expo.test.ts +++ b/tests/expo.test.ts @@ -25,7 +25,6 @@ describe('authenticate', () => { utils.setEnv('TEST_INCLUDED', 'hellyeah'); await expo.authenticate('bycedric', 'mypassword'); expect(spy.exec).toBeCalled(); - expect(spy.exec.mock.calls[0][0]).toBe('expo'); expect(spy.exec.mock.calls[0][1]).toStrictEqual(['login', '--username=bycedric']) expect(spy.exec.mock.calls[0][2]).toMatchObject({ env: { @@ -36,7 +35,23 @@ describe('authenticate', () => { utils.restoreEnv(); }); - it('executes login command with `.cmd` suffix on windows', async () => { + it('executes login command with `expo` on macos', async () => { + utils.setPlatform('darwin'); + await expo.authenticate('bycedric', 'mypassword'); + expect(spy.exec).toBeCalled(); + expect(spy.exec.mock.calls[0][0]).toBe('expo'); + utils.restorePlatform(); + }); + + it('executes login command with `expo` on ubuntu', async () => { + utils.setPlatform('linux'); + await expo.authenticate('bycedric', 'mypassword'); + expect(spy.exec).toBeCalled(); + expect(spy.exec.mock.calls[0][0]).toBe('expo'); + utils.restorePlatform(); + }); + + it('executes login command with `expo.cmd` on windows', async () => { utils.setPlatform('win32'); await expo.authenticate('bycedric', 'mypassword'); expect(spy.exec).toBeCalled(); diff --git a/tests/install.test.ts b/tests/install.test.ts index 4565b5ef..deea0510 100644 --- a/tests/install.test.ts +++ b/tests/install.test.ts @@ -13,6 +13,7 @@ jest.mock('@actions/io', () => io); jest.mock('libnpm', () => registry); jest.mock('../src/cache', () => cache); +import { join } from 'path'; import * as install from '../src/install'; import * as utils from './utils'; @@ -26,39 +27,39 @@ describe('resolve', () => { describe('install', () => { it('installs path from local cache', async () => { - cache.fromLocalCache.mockResolvedValue('/cache/path'); + cache.fromLocalCache.mockResolvedValue(join('cache', 'path')); const expoPath = await install.install({ version: '3.0.10', packager: 'npm' }); - expect(expoPath).toBe('/cache/path/node_modules/.bin'); + expect(expoPath).toBe(join('cache', 'path', 'node_modules', '.bin')); }); it('installs path from packager and cache it locally', async () => { - utils.setEnv('RUNNER_TEMP', '/temp/path'); + utils.setEnv('RUNNER_TEMP', join('temp', 'path')); cache.fromLocalCache.mockResolvedValue(undefined); - cache.toLocalCache.mockResolvedValue('/cache/path'); + cache.toLocalCache.mockResolvedValue(join('cache', 'path')); const expoPath = await install.install({ version: '3.0.10', packager: 'npm' }); - expect(expoPath).toBe('/cache/path/node_modules/.bin'); - expect(cache.toLocalCache).toBeCalledWith('/temp/path', '3.0.10'); + expect(expoPath).toBe(join('cache', 'path', 'node_modules', '.bin')); + expect(cache.toLocalCache).toBeCalledWith(join('temp', 'path'), '3.0.10'); utils.restoreEnv(); }); it('installs path from remote cache', async () => { cache.fromLocalCache.mockResolvedValue(undefined); - cache.fromRemoteCache.mockResolvedValue('/cache/path'); + cache.fromRemoteCache.mockResolvedValue(join('cache', 'path')); registry.manifest.mockResolvedValue({ version: '3.20.0' }); const expoPath = await install.install({ version: '3.20.1', packager: 'npm', cache: true }); - expect(expoPath).toBe('/cache/path/node_modules/.bin'); + expect(expoPath).toBe(join('cache', 'path', 'node_modules', '.bin')); expect(cache.fromRemoteCache).toBeCalledWith('3.20.0', 'npm', undefined); }); it('installs path from packager and cache it remotely', async () => { - utils.setEnv('RUNNER_TEMP', '/temp/path'); + utils.setEnv('RUNNER_TEMP', join('temp', 'path')); cache.fromLocalCache.mockResolvedValue(undefined); cache.fromRemoteCache.mockResolvedValue(undefined); - cache.toLocalCache.mockResolvedValue('/cache/path'); + cache.toLocalCache.mockResolvedValue(join('cache', 'path')); registry.manifest.mockResolvedValue({ version: '3.20.1' }); const expoPath = await install.install({ version: '3.20.1', packager: 'npm', cache: true }); - expect(expoPath).toBe('/cache/path/node_modules/.bin'); - expect(cache.toRemoteCache).toBeCalledWith('/cache/path', '3.20.1', 'npm', undefined); + expect(expoPath).toBe(join('cache', 'path', 'node_modules', '.bin')); + expect(cache.toRemoteCache).toBeCalledWith(join('cache', 'path'), '3.20.1', 'npm', undefined); utils.restoreEnv(); }); }); @@ -70,21 +71,21 @@ describe('fromPackager', () => { }); it('creates temporary folder', async () => { - utils.setEnv('RUNNER_TEMP', '/temp/path'); + utils.setEnv('RUNNER_TEMP', join('temp', 'path')); await install.fromPackager('latest', 'yarn'); - expect(io.mkdirP).toBeCalledWith('/temp/path'); + expect(io.mkdirP).toBeCalledWith(join('temp', 'path')); utils.restoreEnv(); }); it('installs expo with tool', async () => { - utils.setEnv('RUNNER_TEMP', '/temp/path'); + utils.setEnv('RUNNER_TEMP', join('temp', 'path')); io.which.mockResolvedValue('npm'); const expoPath = await install.fromPackager('beta', 'npm'); - expect(expoPath).toBe('/temp/path'); + expect(expoPath).toBe(join('temp', 'path')); expect(cli.exec).toBeCalled(); expect(cli.exec.mock.calls[0][0]).toBe('npm'); expect(cli.exec.mock.calls[0][1]).toStrictEqual(['add', 'expo-cli@beta']); - expect(cli.exec.mock.calls[0][2]).toMatchObject({ cwd: '/temp/path' }); + expect(cli.exec.mock.calls[0][2]).toMatchObject({ cwd: join('temp', 'path') }); utils.restoreEnv(); }); }); diff --git a/yarn.lock b/yarn.lock index 21d3d344..be956f0a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4706,7 +4706,7 @@ rimraf@^2.5.2, rimraf@^2.5.4, rimraf@^2.6.2, rimraf@^2.6.3: dependencies: glob "^7.1.3" -rimraf@^3.0.0: +rimraf@^3.0.0, rimraf@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==