From 8f441166485d8c04cd4d6ca700351987c6279569 Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Wed, 15 Jun 2022 20:36:04 +0800 Subject: [PATCH 01/12] improve --- .github/workflows/ci.yml | 5 +- Gulpfile.mjs | 45 +++-- Makefile | 5 +- Makefile.mjs | 341 ++++++++++++++++++++++++++++++++ make.cmd | 2 + package.json | 1 + scripts/assert-dir-git-clean.js | 12 ++ scripts/assert-dir-git-clean.sh | 8 - scripts/clone-license.js | 19 ++ scripts/clone-license.sh | 4 - yarn.lock | 14 ++ 11 files changed, 420 insertions(+), 36 deletions(-) create mode 100644 Makefile.mjs create mode 100644 make.cmd create mode 100644 scripts/assert-dir-git-clean.js delete mode 100755 scripts/assert-dir-git-clean.sh create mode 100644 scripts/clone-license.js delete mode 100755 scripts/clone-license.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 539ce7cc321b..ce464e14c925 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -116,7 +116,7 @@ jobs: STRIP_BABEL_8_FLAG: true - name: Ensure cwd does not contain uncommitted changes run: | - ./scripts/assert-dir-git-clean.sh + node ./scripts/assert-dir-git-clean.js - uses: actions/upload-artifact@v3 with: name: babel-artifact @@ -149,9 +149,8 @@ jobs: BABEL_8_BREAKING: false STRIP_BABEL_8_FLAG: true - name: Ensure cwd does not contain uncommitted changes - shell: bash run: | - ./scripts/assert-dir-git-clean.sh + node ./scripts/assert-dir-git-clean.js lint: name: Lint diff --git a/Gulpfile.mjs b/Gulpfile.mjs index 88944110363c..79890b745082 100644 --- a/Gulpfile.mjs +++ b/Gulpfile.mjs @@ -673,24 +673,33 @@ gulp.task( ) ); -gulp.task( - "watch", - gulp.series("build-dev", function watch() { - gulp.watch(defaultSourcesGlob, gulp.task("build-no-bundle-watch")); - gulp.watch( - babelStandalonePluginConfigGlob, - gulp.task("generate-standalone") - ); - gulp.watch(buildTypingsWatchGlob, gulp.task("generate-type-helpers")); +function watch() { + gulp.watch(defaultSourcesGlob, gulp.task("build-no-bundle-watch")); + gulp.watch(babelStandalonePluginConfigGlob, gulp.task("generate-standalone")); + gulp.watch(buildTypingsWatchGlob, gulp.task("generate-type-helpers")); + gulp.watch( + "./packages/babel-helpers/src/helpers/*.js", + gulp.task("generate-runtime-helpers") + ); +} + +function watch() { + gulp.watch(defaultSourcesGlob, gulp.task("build-no-bundle-watch")); + gulp.watch(babelStandalonePluginConfigGlob, gulp.task("generate-standalone")); + gulp.watch(buildTypingsWatchGlob, gulp.task("generate-type-helpers")); + gulp.watch( + "./packages/babel-helpers/src/helpers/*.js", + gulp.task("generate-runtime-helpers") + ); + if (USE_ESM) { gulp.watch( - "./packages/babel-helpers/src/helpers/*.js", - gulp.task("generate-runtime-helpers") + cjsBundles.map(({ src }) => `./${src}/lib/**.js`), + gulp.task("build-cjs-bundles") ); - if (USE_ESM) { - gulp.watch( - cjsBundles.map(({ src }) => `./${src}/lib/**.js`), - gulp.task("build-cjs-bundles") - ); - } - }) + } +} + +gulp.task( + "watch", + process.env.WATCH_SKIP_BUILD ? watch : gulp.series("build-dev", watch) ); diff --git a/Makefile b/Makefile index 85fc59a6b4f0..48c235fe0d3a 100644 --- a/Makefile +++ b/Makefile @@ -72,7 +72,7 @@ build-plugin-transform-runtime-dist: $(NODE) scripts/build-dist.js watch: build-no-bundle - BABEL_ENV=development $(YARN) gulp watch + BABEL_ENV=development WATCH_SKIP_BUILD=true $(YARN) gulp watch code-quality: tscheck lint @@ -165,9 +165,8 @@ test-test262: test-test262-update-allowlist: $(NODE) scripts/parser-tests/test262 --update-allowlist -# Does not work on Windows clone-license: - ./scripts/clone-license.sh + $(NODE) ./scripts/clone-license.js prepublish-build: clean-lib clean-runtime-helpers NODE_ENV=production BABEL_ENV=production STRIP_BABEL_8_FLAG=true $(MAKE) build-bundle diff --git a/Makefile.mjs b/Makefile.mjs new file mode 100644 index 000000000000..12f8834cddd7 --- /dev/null +++ b/Makefile.mjs @@ -0,0 +1,341 @@ +import "shelljs/make.js"; +import { default as path } from "path"; +import { execFileSync } from "child_process"; +import { writeFileSync } from "fs"; + +/** + * @type {import("shelljs")} + */ +const shell = global; +const target = global.target; + +const SOURCES = ["packages", "codemods", "eslint"]; + +const YARN_PATH = shell.which("yarn").stdout; +const NODE_PATH = process.execPath; // `yarn node` is so slow on Windows + +shell.config.verbose = true; + +function print(msg) { + console.log(msg); +} + +function exec(executable, args, cwd, inheritStdio = true) { + print( + `${(executable.replaceAll(YARN_PATH), "yarn").replaceAll( + NODE_PATH, + "node" + )} ${args.join(" ")}` + ); + + try { + return execFileSync(executable, args, { + stdio: inheritStdio ? "inherit" : undefined, + cwd: cwd && path.resolve(cwd), + env: process.env, + }); + } catch (error) { + if (inheritStdio && error.status != 0) { + console.error( + new Error( + `\ncommand: ${executable} ${args.join(" ")}\ncode: ${error.status}` + ) + ); + // eslint-disable-next-line no-process-exit + process.exit(error.status); + } + throw error; + } +} + +function yarn(args, cwd, inheritStdio) { + return exec(YARN_PATH, args, cwd, inheritStdio); +} + +function node(args, cwd, inheritStdio) { + return exec(NODE_PATH, args, cwd, inheritStdio); +} + +function env(fun, env) { + const envBak = process.env; + process.env = { ...envBak, ...env }; + fun(); + process.env = envBak; +} + +/** + * CLEAN + */ + +target["clean-all"] = function () { + ["node_modules", "package-lock.json", ".changelog"].forEach(path => { + shell.rm("-rf", path); + }); + + SOURCES.forEach(source => { + shell.rm("-rf", `${source}/*/test/tmp`); + shell.rm("-rf", `${source}/*/package-lock.json`); + }); + + target["clean"](); + target["clean-lib"](); +}; + +target["clean"] = function () { + target["test-clean"](); + + [ + ".npmrc", + "coverage", + "packages/*/npm-debug*", + "node_modules/.cache", + ].forEach(path => { + shell.rm("-rf", path); + }); +}; + +target["test-clean"] = function () { + SOURCES.forEach(source => { + shell.rm("-rf", `${source}/*/test/tmp`); + shell.rm("-rf", `${source}/*/test-fixtures.json`); + }); +}; + +target["clean-lib"] = function () { + SOURCES.forEach(source => { + shell.rm("-rf", `${source}/*/lib`); + }); +}; + +target["clean-runtime-helpers"] = function () { + [ + "packages/babel-runtime/helpers/**/*.js", + "packages/babel-runtime-corejs2/helpers/**/*.js", + "packages/babel-runtime-corejs3/helpers/**/*.js", + "packages/babel-runtime/helpers/**/*.mjs", + "packages/babel-runtime-corejs2/helpers/**/*.mjs", + "packages/babel-runtime-corejs3/helpers/**/*.mjs", + "packages/babel-runtime-corejs2/core-js", + ].forEach(path => { + shell.rm("-rf", path); + }); +}; + +/** + * BUILD + */ + +target["bootstrap-only"] = function () { + target["clean-all"](); + + yarn(["install"]); +}; + +target["bootstrap"] = function () { + target["bootstrap-only"](); + + target["generate-tsconfig"](); + target["build"](); +}; + +target["build"] = function () { + target["build-bundle"](); + + if (process.env.BABEL_COVERAGE != "true") { + target["build-standalone"](); + } +}; + +target["build-standalone"] = function () { + yarn(["gulp", "build-babel-standalone"]); +}; + +target["build-bundle"] = function () { + target["clean"](); + target["clean-lib"](); + + yarn(["gulp", "build"]); + + target["build-flow-typings"](); + target["build-dist"](); +}; + +target["build-no-bundle"] = function () { + target["clean"](); + target["clean-lib"](); + + env( + () => { + yarn(["gulp", "build-dev"]); + }, + { BABEL_ENV: "development" } + ); + + target["build-flow-typings"](); + target["build-dist"](); +}; + +target["build-flow-typings"] = function () { + writeFileSync( + "packages/babel-types/lib/index.js.flow", + node(["packages/babel-types/scripts/generators/flow.js"], undefined, false) + ); +}; + +target["build-dist"] = function () { + target["build-plugin-transform-runtime-dist"](); +}; + +target["build-plugin-transform-runtime-dist"] = function () { + node(["scripts/build-dist.js"], "packages/babel-plugin-transform-runtime"); +}; + +target["prepublish-build"] = function () { + target["clean-lib"](); + target["clean-runtime-helpers"](); + + env( + () => { + target["build-bundle"](); + }, + { + NODE_ENV: "production", + BABEL_ENV: "production", + STRIP_BABEL_8_FLAG: "true", + } + ); + + env( + () => { + target["prepublish-build-standalone"](); + target["clone-license"](); + target["prepublish-prepare-dts"](); + }, + { + STRIP_BABEL_8_FLAG: "true", + } + ); +}; + +target["prepublish-build-standalone"] = function () { + env( + () => { + target["build-standalone"](); + }, + { + BABEL_ENV: "production", + IS_PUBLISH: "true", + } + ); +}; + +target["prepublish-prepare-dts"] = function () { + target["tscheck"](); + + yarn(["gulp", "bundle-dts"]); + + target["build-typescript-legacy-typings"](); +}; + +target["tscheck"] = function () { + target["generate-tsconfig"](); + + shell.rm("-rf", "dts"); + yarn(["tsc", "-b", "."]); +}; + +target["generate-tsconfig"] = function () { + node(["scripts/generators/tsconfig.js"]); + node(["scripts/generators/archived-libs-typings.js"]); +}; + +target["clone-license"] = function () { + node(["scripts/clone-license.js"]); +}; + +target["build-typescript-legacy-typings"] = function () { + writeFileSync( + "packages/babel-types/lib/index-legacy.d.ts", + node( + ["packages/babel-types/scripts/generators/typescript-legacy.js"], + undefined, + false + ) + ); +}; + +/** + * DEV + */ + +target["lint"] = function () { + env( + () => { + yarn([ + "eslint", + "scripts", + "benchmark", + ...SOURCES, + "*.{js,cjs,mjs,ts}", + "--format=codeframe", + "--ext .js,.cjs,.mjs,.ts", + ]); + }, + { + BABEL_ENV: "test", + } + ); +}; + +target["fix"] = function () { + target["fix-json"](); + target["fix-js"](); +}; + +target["fix-js"] = function () { + yarn([ + "eslint", + "scripts", + "benchmark", + ...SOURCES, + "*.{js,cjs,mjs,ts}", + "--format", + "codeframe", + "--ext", + ".js,.cjs,.mjs,.ts", + "--fix", + ]); +}; + +target["fix-json"] = function () { + yarn([ + "prettier", + `{${SOURCES.join(",")}}/*/test/fixtures/**/options.json`, + "--write", + "--loglevel", + "warn", + ]); +}; + +target["watch"] = function () { + target["build-no-bundle"](); + + env( + () => { + yarn(["gulp", "watch"]); + }, + { + BABEL_ENV: "development", + WATCH_SKIP_BUILD: "true", + } + ); +}; + +target["test"] = function () { + target["lint"](); + target["test-only"](); +}; + +target["test-only"] = function (args) { + yarn(["jest", ...args]); +}; diff --git a/make.cmd b/make.cmd new file mode 100644 index 000000000000..d5e72cc85c8c --- /dev/null +++ b/make.cmd @@ -0,0 +1,2 @@ +@cd /d "%~dp0" +@yarn node ./Makefile.mjs %* diff --git a/package.json b/package.json index 698baa8c673b..1bff9a8c2822 100644 --- a/package.json +++ b/package.json @@ -69,6 +69,7 @@ "rollup-plugin-polyfill-node": "^0.9.0", "rollup-plugin-terser": "^7.0.2", "semver": "^6.3.0", + "shelljs": "^0.8.5", "test262-stream": "^1.4.0", "through2": "^4.0.0", "typescript": "~4.7.4" diff --git a/scripts/assert-dir-git-clean.js b/scripts/assert-dir-git-clean.js new file mode 100644 index 000000000000..b3ceeb6c0ee0 --- /dev/null +++ b/scripts/assert-dir-git-clean.js @@ -0,0 +1,12 @@ +// Must run at a git working dir + +import { execSync } from "child_process"; + +if (execSync("git status --porcelain=v1", { encoding: "utf8" })) { + console.log( + 'Please re-run "make build" and checkout the following changes to git' + ); + execSync("git status", { stdio: "inherit" }); + // eslint-disable-next-line no-process-exit + process.exit(1); +} diff --git a/scripts/assert-dir-git-clean.sh b/scripts/assert-dir-git-clean.sh deleted file mode 100755 index 2dcefe0119cd..000000000000 --- a/scripts/assert-dir-git-clean.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -# Must run at a git working dir -if [ -n "$(git status --porcelain=v1 2>/dev/null)" ]; then - echo "Please re-run \"make build\" and checkout the following changes to git" - git status - exit 1 -fi diff --git a/scripts/clone-license.js b/scripts/clone-license.js new file mode 100644 index 000000000000..fbcd35dce01c --- /dev/null +++ b/scripts/clone-license.js @@ -0,0 +1,19 @@ +import { default as shell } from "shelljs"; + +console.log("Cloning LICENSE to babel packages"); + +shell.ls("-d", "./packages/*/").forEach(dir => { + if ( + !dir.match( + /.*packages\/(babel-parser|babel-plugin-transform-object-assign)\/?$/ + ) + ) { + shell.cp("LICENSE", dir); + } +}); + +shell.ls("-d", "./eslint/*/").forEach(dir => { + if (!dir.match(/.*eslint\/(babel-eslint-plugin)\/?$/)) { + shell.cp("LICENSE", dir); + } +}); diff --git a/scripts/clone-license.sh b/scripts/clone-license.sh deleted file mode 100755 index 8c025097cbcb..000000000000 --- a/scripts/clone-license.sh +++ /dev/null @@ -1,4 +0,0 @@ -echo "Cloning LICENSE to babel packages" -cat LICENSE -ls -db ./packages/*/ | egrep -v '.*packages\/(babel-parser|babel-plugin-transform-object-assign)\/?$' | xargs -n 1 cp LICENSE -ls -db ./eslint/*/ | egrep -v '.*eslint\/(babel-eslint-plugin)\/?$' | xargs -n 1 cp LICENSE diff --git a/yarn.lock b/yarn.lock index 1a38ccbd7287..3d91b87d2c77 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5885,6 +5885,7 @@ __metadata: rollup-plugin-polyfill-node: ^0.9.0 rollup-plugin-terser: ^7.0.2 semver: ^6.3.0 + shelljs: ^0.8.5 test262-stream: ^1.4.0 through2: ^4.0.0 typescript: ~4.7.4 @@ -13748,6 +13749,19 @@ fsevents@^1.2.7: languageName: node linkType: hard +"shelljs@npm:^0.8.5": + version: 0.8.5 + resolution: "shelljs@npm:0.8.5" + dependencies: + glob: ^7.0.0 + interpret: ^1.0.0 + rechoir: ^0.6.2 + bin: + shjs: bin/shjs + checksum: 7babc46f732a98f4c054ec1f048b55b9149b98aa2da32f6cf9844c434b43c6251efebd6eec120937bd0999e13811ebd45efe17410edb3ca938f82f9381302748 + languageName: node + linkType: hard + "side-channel@npm:^1.0.4": version: 1.0.4 resolution: "side-channel@npm:1.0.4" From 702fcdea607507e77db643ad4056d2eba8941682 Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Wed, 15 Jun 2022 20:52:52 +0800 Subject: [PATCH 02/12] doc --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d64fe3b599e2..499b75591580 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -43,8 +43,8 @@ _Yarn_: Make sure that Yarn 1 is [installed](https://classic.yarnpkg.com/en/docs _Make_: If you are running Windows 10, you'll need to do one of the following: -- Clone the repository and run the commands inside [WSL 2](https://docs.microsoft.com/en-us/windows/wsl/install-win10). -- Install [Make for Windows](http://gnuwin32.sourceforge.net/packages/make.htm). +- Run the commands inside [WSL 2](https://docs.microsoft.com/en-us/windows/wsl/install-win10). +- Using make normally (`make` or `./make`), it will automatically call the cross-platform `Makefile.mjs`. (There may be a small part of the function not implemented.) ### Setup From b0d60fb332d6558373cc32f51a560072f5d7fa07 Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Wed, 15 Jun 2022 22:17:20 +0800 Subject: [PATCH 03/12] fix --- Makefile.mjs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile.mjs b/Makefile.mjs index 12f8834cddd7..e5844e6fb3b1 100644 --- a/Makefile.mjs +++ b/Makefile.mjs @@ -278,7 +278,8 @@ target["lint"] = function () { ...SOURCES, "*.{js,cjs,mjs,ts}", "--format=codeframe", - "--ext .js,.cjs,.mjs,.ts", + "--ext", + ".js,.cjs,.mjs,.ts", ]); }, { @@ -336,6 +337,6 @@ target["test"] = function () { target["test-only"](); }; -target["test-only"] = function (args) { +target["test-only"] = function (args = []) { yarn(["jest", ...args]); }; From 1c705723e730718bcf165a89ea8a8cfdfb6302d7 Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Wed, 15 Jun 2022 22:33:04 +0800 Subject: [PATCH 04/12] improve --- Makefile.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile.mjs b/Makefile.mjs index e5844e6fb3b1..a82411efb823 100644 --- a/Makefile.mjs +++ b/Makefile.mjs @@ -277,7 +277,8 @@ target["lint"] = function () { "benchmark", ...SOURCES, "*.{js,cjs,mjs,ts}", - "--format=codeframe", + "--format", + "codeframe", "--ext", ".js,.cjs,.mjs,.ts", ]); From 4d2cee0f56a659197d248db932f64571841ae91b Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Tue, 21 Jun 2022 00:28:21 +0800 Subject: [PATCH 05/12] improve --- Makefile.mjs | 2 +- scripts/clone-license.js | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Makefile.mjs b/Makefile.mjs index a82411efb823..567788439db0 100644 --- a/Makefile.mjs +++ b/Makefile.mjs @@ -1,5 +1,5 @@ import "shelljs/make.js"; -import { default as path } from "path"; +import path from "path"; import { execFileSync } from "child_process"; import { writeFileSync } from "fs"; diff --git a/scripts/clone-license.js b/scripts/clone-license.js index fbcd35dce01c..289519fe592a 100644 --- a/scripts/clone-license.js +++ b/scripts/clone-license.js @@ -1,19 +1,25 @@ -import { default as shell } from "shelljs"; +import { readFileSync, writeFileSync } from "fs"; +import shell from "shelljs"; +import path from "path"; console.log("Cloning LICENSE to babel packages"); +const LICENSE = readFileSync("LICENSE", "utf8"); + +console.log(LICENSE); + shell.ls("-d", "./packages/*/").forEach(dir => { if ( !dir.match( /.*packages\/(babel-parser|babel-plugin-transform-object-assign)\/?$/ ) ) { - shell.cp("LICENSE", dir); + writeFileSync(path.join(dir, "LICENSE"), LICENSE); } }); shell.ls("-d", "./eslint/*/").forEach(dir => { if (!dir.match(/.*eslint\/(babel-eslint-plugin)\/?$/)) { - shell.cp("LICENSE", dir); + writeFileSync(path.join(dir, "LICENSE"), LICENSE); } }); From 6527805b5e61e4dd26429eb331adfad80451e040 Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Thu, 14 Jul 2022 04:32:28 +0800 Subject: [PATCH 06/12] update and fix --- Gulpfile.mjs | 10 ---------- Makefile.mjs | 16 ++++++++++++++++ scripts/set-module-type.js | 5 ++++- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/Gulpfile.mjs b/Gulpfile.mjs index 79890b745082..bd6b896e280c 100644 --- a/Gulpfile.mjs +++ b/Gulpfile.mjs @@ -673,16 +673,6 @@ gulp.task( ) ); -function watch() { - gulp.watch(defaultSourcesGlob, gulp.task("build-no-bundle-watch")); - gulp.watch(babelStandalonePluginConfigGlob, gulp.task("generate-standalone")); - gulp.watch(buildTypingsWatchGlob, gulp.task("generate-type-helpers")); - gulp.watch( - "./packages/babel-helpers/src/helpers/*.js", - gulp.task("generate-runtime-helpers") - ); -} - function watch() { gulp.watch(defaultSourcesGlob, gulp.task("build-no-bundle-watch")); gulp.watch(babelStandalonePluginConfigGlob, gulp.task("generate-standalone")); diff --git a/Makefile.mjs b/Makefile.mjs index 567788439db0..caf62baa702d 100644 --- a/Makefile.mjs +++ b/Makefile.mjs @@ -125,6 +125,18 @@ target["clean-runtime-helpers"] = function () { * BUILD */ +target["use-cjs"] = function () { + node(["scripts/set-module-type.js", "script"]); + + target["bootstrap"](); +}; + +target["use-esm"] = function () { + node(["scripts/set-module-type.js", "module"]); + + target["bootstrap"](); +}; + target["bootstrap-only"] = function () { target["clean-all"](); @@ -151,6 +163,8 @@ target["build-standalone"] = function () { }; target["build-bundle"] = function () { + node(["scripts/set-module-type.js"]); + target["clean"](); target["clean-lib"](); @@ -161,6 +175,8 @@ target["build-bundle"] = function () { }; target["build-no-bundle"] = function () { + node(["scripts/set-module-type.js"]); + target["clean"](); target["clean-lib"](); diff --git a/scripts/set-module-type.js b/scripts/set-module-type.js index fe5b7dd25fd6..fa4dce6ff1dc 100755 --- a/scripts/set-module-type.js +++ b/scripts/set-module-type.js @@ -1,8 +1,11 @@ #!/usr/bin/env node import fs from "fs"; +import { fileURLToPath } from "url"; +import path from "path"; -const root = rel => new URL(`../${rel}`, import.meta.url).pathname; +const root = rel => + path.join(fileURLToPath(path.dirname(import.meta.url)), "../", rel); // prettier-ignore let moduleType; From 5b71a9fce0d283b17c97a556eeb36609881d791d Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Thu, 14 Jul 2022 21:13:43 +0800 Subject: [PATCH 07/12] pack dependencies --- Makefile.mjs | 7502 +++++++++++++++++++++++++++++++++++++++- Makefile.source.mjs | 359 ++ scripts/pack-script.js | 36 + 3 files changed, 7892 insertions(+), 5 deletions(-) create mode 100644 Makefile.source.mjs create mode 100644 scripts/pack-script.js diff --git a/Makefile.mjs b/Makefile.mjs index caf62baa702d..cc2179d1a466 100644 --- a/Makefile.mjs +++ b/Makefile.mjs @@ -1,7 +1,7499 @@ -import "shelljs/make.js"; -import path from "path"; -import { execFileSync } from "child_process"; -import { writeFileSync } from "fs"; +/* eslint-disable */ + //prettier-ignore + import require$$0 from 'os'; +import require$$1, { writeFileSync } from 'fs'; +import require$$2 from 'path'; +import require$$4 from 'events'; +import require$$6 from 'assert'; +import require$$4$1 from 'util'; +import require$$0$1, { execFileSync } from 'child_process'; + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +var common$2 = {}; + +var old = {}; + +var hasRequiredOld; + +function requireOld () { + if (hasRequiredOld) return old; + hasRequiredOld = 1; + // Copyright Joyent, Inc. and other Node contributors. + // + // Permission is hereby granted, free of charge, to any person obtaining a + // copy of this software and associated documentation files (the + // "Software"), to deal in the Software without restriction, including + // without limitation the rights to use, copy, modify, merge, publish, + // distribute, sublicense, and/or sell copies of the Software, and to permit + // persons to whom the Software is furnished to do so, subject to the + // following conditions: + // + // The above copyright notice and this permission notice shall be included + // in all copies or substantial portions of the Software. + // + // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN + // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, + // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + // USE OR OTHER DEALINGS IN THE SOFTWARE. + + var pathModule = require$$2; + var isWindows = process.platform === 'win32'; + var fs = require$$1; + + // JavaScript implementation of realpath, ported from node pre-v6 + + var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG); + + function rethrow() { + // Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and + // is fairly slow to generate. + var callback; + if (DEBUG) { + var backtrace = new Error; + callback = debugCallback; + } else + callback = missingCallback; + + return callback; + + function debugCallback(err) { + if (err) { + backtrace.message = err.message; + err = backtrace; + missingCallback(err); + } + } + + function missingCallback(err) { + if (err) { + if (process.throwDeprecation) + throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs + else if (!process.noDeprecation) { + var msg = 'fs: missing callback ' + (err.stack || err.message); + if (process.traceDeprecation) + console.trace(msg); + else + console.error(msg); + } + } + } + } + + function maybeCallback(cb) { + return typeof cb === 'function' ? cb : rethrow(); + } + + pathModule.normalize; + + // Regexp that finds the next partion of a (partial) path + // result is [base_with_slash, base], e.g. ['somedir/', 'somedir'] + if (isWindows) { + var nextPartRe = /(.*?)(?:[\/\\]+|$)/g; + } else { + var nextPartRe = /(.*?)(?:[\/]+|$)/g; + } + + // Regex to find the device root, including trailing slash. E.g. 'c:\\'. + if (isWindows) { + var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/; + } else { + var splitRootRe = /^[\/]*/; + } + + old.realpathSync = function realpathSync(p, cache) { + // make p is absolute + p = pathModule.resolve(p); + + if (cache && Object.prototype.hasOwnProperty.call(cache, p)) { + return cache[p]; + } + + var original = p, + seenLinks = {}, + knownHard = {}; + + // current character position in p + var pos; + // the partial path so far, including a trailing slash if any + var current; + // the partial path without a trailing slash (except when pointing at a root) + var base; + // the partial path scanned in the previous round, with slash + var previous; + + start(); + + function start() { + // Skip over roots + var m = splitRootRe.exec(p); + pos = m[0].length; + current = m[0]; + base = m[0]; + previous = ''; + + // On windows, check that the root exists. On unix there is no need. + if (isWindows && !knownHard[base]) { + fs.lstatSync(base); + knownHard[base] = true; + } + } + + // walk down the path, swapping out linked pathparts for their real + // values + // NB: p.length changes. + while (pos < p.length) { + // find the next part + nextPartRe.lastIndex = pos; + var result = nextPartRe.exec(p); + previous = current; + current += result[0]; + base = previous + result[1]; + pos = nextPartRe.lastIndex; + + // continue if not a symlink + if (knownHard[base] || (cache && cache[base] === base)) { + continue; + } + + var resolvedLink; + if (cache && Object.prototype.hasOwnProperty.call(cache, base)) { + // some known symbolic link. no need to stat again. + resolvedLink = cache[base]; + } else { + var stat = fs.lstatSync(base); + if (!stat.isSymbolicLink()) { + knownHard[base] = true; + if (cache) cache[base] = base; + continue; + } + + // read the link if it wasn't read before + // dev/ino always return 0 on windows, so skip the check. + var linkTarget = null; + if (!isWindows) { + var id = stat.dev.toString(32) + ':' + stat.ino.toString(32); + if (seenLinks.hasOwnProperty(id)) { + linkTarget = seenLinks[id]; + } + } + if (linkTarget === null) { + fs.statSync(base); + linkTarget = fs.readlinkSync(base); + } + resolvedLink = pathModule.resolve(previous, linkTarget); + // track this, if given a cache. + if (cache) cache[base] = resolvedLink; + if (!isWindows) seenLinks[id] = linkTarget; + } + + // resolve the link, then start over + p = pathModule.resolve(resolvedLink, p.slice(pos)); + start(); + } + + if (cache) cache[original] = p; + + return p; + }; + + + old.realpath = function realpath(p, cache, cb) { + if (typeof cb !== 'function') { + cb = maybeCallback(cache); + cache = null; + } + + // make p is absolute + p = pathModule.resolve(p); + + if (cache && Object.prototype.hasOwnProperty.call(cache, p)) { + return process.nextTick(cb.bind(null, null, cache[p])); + } + + var original = p, + seenLinks = {}, + knownHard = {}; + + // current character position in p + var pos; + // the partial path so far, including a trailing slash if any + var current; + // the partial path without a trailing slash (except when pointing at a root) + var base; + // the partial path scanned in the previous round, with slash + var previous; + + start(); + + function start() { + // Skip over roots + var m = splitRootRe.exec(p); + pos = m[0].length; + current = m[0]; + base = m[0]; + previous = ''; + + // On windows, check that the root exists. On unix there is no need. + if (isWindows && !knownHard[base]) { + fs.lstat(base, function(err) { + if (err) return cb(err); + knownHard[base] = true; + LOOP(); + }); + } else { + process.nextTick(LOOP); + } + } + + // walk down the path, swapping out linked pathparts for their real + // values + function LOOP() { + // stop if scanned past end of path + if (pos >= p.length) { + if (cache) cache[original] = p; + return cb(null, p); + } + + // find the next part + nextPartRe.lastIndex = pos; + var result = nextPartRe.exec(p); + previous = current; + current += result[0]; + base = previous + result[1]; + pos = nextPartRe.lastIndex; + + // continue if not a symlink + if (knownHard[base] || (cache && cache[base] === base)) { + return process.nextTick(LOOP); + } + + if (cache && Object.prototype.hasOwnProperty.call(cache, base)) { + // known symbolic link. no need to stat again. + return gotResolvedLink(cache[base]); + } + + return fs.lstat(base, gotStat); + } + + function gotStat(err, stat) { + if (err) return cb(err); + + // if not a symlink, skip to the next path part + if (!stat.isSymbolicLink()) { + knownHard[base] = true; + if (cache) cache[base] = base; + return process.nextTick(LOOP); + } + + // stat & read the link if not read before + // call gotTarget as soon as the link target is known + // dev/ino always return 0 on windows, so skip the check. + if (!isWindows) { + var id = stat.dev.toString(32) + ':' + stat.ino.toString(32); + if (seenLinks.hasOwnProperty(id)) { + return gotTarget(null, seenLinks[id], base); + } + } + fs.stat(base, function(err) { + if (err) return cb(err); + + fs.readlink(base, function(err, target) { + if (!isWindows) seenLinks[id] = target; + gotTarget(err, target); + }); + }); + } + + function gotTarget(err, target, base) { + if (err) return cb(err); + + var resolvedLink = pathModule.resolve(previous, target); + if (cache) cache[base] = resolvedLink; + gotResolvedLink(resolvedLink); + } + + function gotResolvedLink(resolvedLink) { + // resolve the link, then start over + p = pathModule.resolve(resolvedLink, p.slice(pos)); + start(); + } + }; + return old; +} + +var fs_realpath; +var hasRequiredFs_realpath; + +function requireFs_realpath () { + if (hasRequiredFs_realpath) return fs_realpath; + hasRequiredFs_realpath = 1; + fs_realpath = realpath; + realpath.realpath = realpath; + realpath.sync = realpathSync; + realpath.realpathSync = realpathSync; + realpath.monkeypatch = monkeypatch; + realpath.unmonkeypatch = unmonkeypatch; + + var fs = require$$1; + var origRealpath = fs.realpath; + var origRealpathSync = fs.realpathSync; + + var version = process.version; + var ok = /^v[0-5]\./.test(version); + var old = requireOld(); + + function newError (er) { + return er && er.syscall === 'realpath' && ( + er.code === 'ELOOP' || + er.code === 'ENOMEM' || + er.code === 'ENAMETOOLONG' + ) + } + + function realpath (p, cache, cb) { + if (ok) { + return origRealpath(p, cache, cb) + } + + if (typeof cache === 'function') { + cb = cache; + cache = null; + } + origRealpath(p, cache, function (er, result) { + if (newError(er)) { + old.realpath(p, cache, cb); + } else { + cb(er, result); + } + }); + } + + function realpathSync (p, cache) { + if (ok) { + return origRealpathSync(p, cache) + } + + try { + return origRealpathSync(p, cache) + } catch (er) { + if (newError(er)) { + return old.realpathSync(p, cache) + } else { + throw er + } + } + } + + function monkeypatch () { + fs.realpath = realpath; + fs.realpathSync = realpathSync; + } + + function unmonkeypatch () { + fs.realpath = origRealpath; + fs.realpathSync = origRealpathSync; + } + return fs_realpath; +} + +var concatMap; +var hasRequiredConcatMap; + +function requireConcatMap () { + if (hasRequiredConcatMap) return concatMap; + hasRequiredConcatMap = 1; + concatMap = function (xs, fn) { + var res = []; + for (var i = 0; i < xs.length; i++) { + var x = fn(xs[i], i); + if (isArray(x)) res.push.apply(res, x); + else res.push(x); + } + return res; + }; + + var isArray = Array.isArray || function (xs) { + return Object.prototype.toString.call(xs) === '[object Array]'; + }; + return concatMap; +} + +var balancedMatch; +var hasRequiredBalancedMatch; + +function requireBalancedMatch () { + if (hasRequiredBalancedMatch) return balancedMatch; + hasRequiredBalancedMatch = 1; + balancedMatch = balanced; + function balanced(a, b, str) { + if (a instanceof RegExp) a = maybeMatch(a, str); + if (b instanceof RegExp) b = maybeMatch(b, str); + + var r = range(a, b, str); + + return r && { + start: r[0], + end: r[1], + pre: str.slice(0, r[0]), + body: str.slice(r[0] + a.length, r[1]), + post: str.slice(r[1] + b.length) + }; + } + + function maybeMatch(reg, str) { + var m = str.match(reg); + return m ? m[0] : null; + } + + balanced.range = range; + function range(a, b, str) { + var begs, beg, left, right, result; + var ai = str.indexOf(a); + var bi = str.indexOf(b, ai + 1); + var i = ai; + + if (ai >= 0 && bi > 0) { + begs = []; + left = str.length; + + while (i >= 0 && !result) { + if (i == ai) { + begs.push(i); + ai = str.indexOf(a, i + 1); + } else if (begs.length == 1) { + result = [ begs.pop(), bi ]; + } else { + beg = begs.pop(); + if (beg < left) { + left = beg; + right = bi; + } + + bi = str.indexOf(b, i + 1); + } + + i = ai < bi && ai >= 0 ? ai : bi; + } + + if (begs.length) { + result = [ left, right ]; + } + } + + return result; + } + return balancedMatch; +} + +var braceExpansion; +var hasRequiredBraceExpansion; + +function requireBraceExpansion () { + if (hasRequiredBraceExpansion) return braceExpansion; + hasRequiredBraceExpansion = 1; + var concatMap = requireConcatMap(); + var balanced = requireBalancedMatch(); + + braceExpansion = expandTop; + + var escSlash = '\0SLASH'+Math.random()+'\0'; + var escOpen = '\0OPEN'+Math.random()+'\0'; + var escClose = '\0CLOSE'+Math.random()+'\0'; + var escComma = '\0COMMA'+Math.random()+'\0'; + var escPeriod = '\0PERIOD'+Math.random()+'\0'; + + function numeric(str) { + return parseInt(str, 10) == str + ? parseInt(str, 10) + : str.charCodeAt(0); + } + + function escapeBraces(str) { + return str.split('\\\\').join(escSlash) + .split('\\{').join(escOpen) + .split('\\}').join(escClose) + .split('\\,').join(escComma) + .split('\\.').join(escPeriod); + } + + function unescapeBraces(str) { + return str.split(escSlash).join('\\') + .split(escOpen).join('{') + .split(escClose).join('}') + .split(escComma).join(',') + .split(escPeriod).join('.'); + } + + + // Basically just str.split(","), but handling cases + // where we have nested braced sections, which should be + // treated as individual members, like {a,{b,c},d} + function parseCommaParts(str) { + if (!str) + return ['']; + + var parts = []; + var m = balanced('{', '}', str); + + if (!m) + return str.split(','); + + var pre = m.pre; + var body = m.body; + var post = m.post; + var p = pre.split(','); + + p[p.length-1] += '{' + body + '}'; + var postParts = parseCommaParts(post); + if (post.length) { + p[p.length-1] += postParts.shift(); + p.push.apply(p, postParts); + } + + parts.push.apply(parts, p); + + return parts; + } + + function expandTop(str) { + if (!str) + return []; + + // I don't know why Bash 4.3 does this, but it does. + // Anything starting with {} will have the first two bytes preserved + // but *only* at the top level, so {},a}b will not expand to anything, + // but a{},b}c will be expanded to [a}c,abc]. + // One could argue that this is a bug in Bash, but since the goal of + // this module is to match Bash's rules, we escape a leading {} + if (str.substr(0, 2) === '{}') { + str = '\\{\\}' + str.substr(2); + } + + return expand(escapeBraces(str), true).map(unescapeBraces); + } + + function embrace(str) { + return '{' + str + '}'; + } + function isPadded(el) { + return /^-?0\d/.test(el); + } + + function lte(i, y) { + return i <= y; + } + function gte(i, y) { + return i >= y; + } + + function expand(str, isTop) { + var expansions = []; + + var m = balanced('{', '}', str); + if (!m || /\$$/.test(m.pre)) return [str]; + + var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body); + var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body); + var isSequence = isNumericSequence || isAlphaSequence; + var isOptions = m.body.indexOf(',') >= 0; + if (!isSequence && !isOptions) { + // {a},b} + if (m.post.match(/,.*\}/)) { + str = m.pre + '{' + m.body + escClose + m.post; + return expand(str); + } + return [str]; + } + + var n; + if (isSequence) { + n = m.body.split(/\.\./); + } else { + n = parseCommaParts(m.body); + if (n.length === 1) { + // x{{a,b}}y ==> x{a}y x{b}y + n = expand(n[0], false).map(embrace); + if (n.length === 1) { + var post = m.post.length + ? expand(m.post, false) + : ['']; + return post.map(function(p) { + return m.pre + n[0] + p; + }); + } + } + } + + // at this point, n is the parts, and we know it's not a comma set + // with a single entry. + + // no need to expand pre, since it is guaranteed to be free of brace-sets + var pre = m.pre; + var post = m.post.length + ? expand(m.post, false) + : ['']; + + var N; + + if (isSequence) { + var x = numeric(n[0]); + var y = numeric(n[1]); + var width = Math.max(n[0].length, n[1].length); + var incr = n.length == 3 + ? Math.abs(numeric(n[2])) + : 1; + var test = lte; + var reverse = y < x; + if (reverse) { + incr *= -1; + test = gte; + } + var pad = n.some(isPadded); + + N = []; + + for (var i = x; test(i, y); i += incr) { + var c; + if (isAlphaSequence) { + c = String.fromCharCode(i); + if (c === '\\') + c = ''; + } else { + c = String(i); + if (pad) { + var need = width - c.length; + if (need > 0) { + var z = new Array(need + 1).join('0'); + if (i < 0) + c = '-' + z + c.slice(1); + else + c = z + c; + } + } + } + N.push(c); + } + } else { + N = concatMap(n, function(el) { return expand(el, false) }); + } + + for (var j = 0; j < N.length; j++) { + for (var k = 0; k < post.length; k++) { + var expansion = pre + N[j] + post[k]; + if (!isTop || isSequence || expansion) + expansions.push(expansion); + } + } + + return expansions; + } + return braceExpansion; +} + +var minimatch_1; +var hasRequiredMinimatch; + +function requireMinimatch () { + if (hasRequiredMinimatch) return minimatch_1; + hasRequiredMinimatch = 1; + minimatch_1 = minimatch; + minimatch.Minimatch = Minimatch; + + var path = { sep: '/' }; + try { + path = require('path'); + } catch (er) {} + + var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}; + var expand = requireBraceExpansion(); + + var plTypes = { + '!': { open: '(?:(?!(?:', close: '))[^/]*?)'}, + '?': { open: '(?:', close: ')?' }, + '+': { open: '(?:', close: ')+' }, + '*': { open: '(?:', close: ')*' }, + '@': { open: '(?:', close: ')' } + }; + + // any single thing other than / + // don't need to escape / when using new RegExp() + var qmark = '[^/]'; + + // * => any number of characters + var star = qmark + '*?'; + + // ** when dots are allowed. Anything goes, except .. and . + // not (^ or / followed by one or two dots followed by $ or /), + // followed by anything, any number of times. + var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?'; + + // not a ^ or / followed by a dot, + // followed by anything, any number of times. + var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?'; + + // characters that need to be escaped in RegExp. + var reSpecials = charSet('().*{}+?[]^$\\!'); + + // "abc" -> { a:true, b:true, c:true } + function charSet (s) { + return s.split('').reduce(function (set, c) { + set[c] = true; + return set + }, {}) + } + + // normalizes slashes. + var slashSplit = /\/+/; + + minimatch.filter = filter; + function filter (pattern, options) { + options = options || {}; + return function (p, i, list) { + return minimatch(p, pattern, options) + } + } + + function ext (a, b) { + a = a || {}; + b = b || {}; + var t = {}; + Object.keys(b).forEach(function (k) { + t[k] = b[k]; + }); + Object.keys(a).forEach(function (k) { + t[k] = a[k]; + }); + return t + } + + minimatch.defaults = function (def) { + if (!def || !Object.keys(def).length) return minimatch + + var orig = minimatch; + + var m = function minimatch (p, pattern, options) { + return orig.minimatch(p, pattern, ext(def, options)) + }; + + m.Minimatch = function Minimatch (pattern, options) { + return new orig.Minimatch(pattern, ext(def, options)) + }; + + return m + }; + + Minimatch.defaults = function (def) { + if (!def || !Object.keys(def).length) return Minimatch + return minimatch.defaults(def).Minimatch + }; + + function minimatch (p, pattern, options) { + if (typeof pattern !== 'string') { + throw new TypeError('glob pattern string required') + } + + if (!options) options = {}; + + // shortcut: comments match nothing. + if (!options.nocomment && pattern.charAt(0) === '#') { + return false + } + + // "" only matches "" + if (pattern.trim() === '') return p === '' + + return new Minimatch(pattern, options).match(p) + } + + function Minimatch (pattern, options) { + if (!(this instanceof Minimatch)) { + return new Minimatch(pattern, options) + } + + if (typeof pattern !== 'string') { + throw new TypeError('glob pattern string required') + } + + if (!options) options = {}; + pattern = pattern.trim(); + + // windows support: need to use /, not \ + if (path.sep !== '/') { + pattern = pattern.split(path.sep).join('/'); + } + + this.options = options; + this.set = []; + this.pattern = pattern; + this.regexp = null; + this.negate = false; + this.comment = false; + this.empty = false; + + // make the set of regexps etc. + this.make(); + } + + Minimatch.prototype.debug = function () {}; + + Minimatch.prototype.make = make; + function make () { + // don't do it more than once. + if (this._made) return + + var pattern = this.pattern; + var options = this.options; + + // empty patterns and comments match nothing. + if (!options.nocomment && pattern.charAt(0) === '#') { + this.comment = true; + return + } + if (!pattern) { + this.empty = true; + return + } + + // step 1: figure out negation, etc. + this.parseNegate(); + + // step 2: expand braces + var set = this.globSet = this.braceExpand(); + + if (options.debug) this.debug = console.error; + + this.debug(this.pattern, set); + + // step 3: now we have a set, so turn each one into a series of path-portion + // matching patterns. + // These will be regexps, except in the case of "**", which is + // set to the GLOBSTAR object for globstar behavior, + // and will not contain any / characters + set = this.globParts = set.map(function (s) { + return s.split(slashSplit) + }); + + this.debug(this.pattern, set); + + // glob --> regexps + set = set.map(function (s, si, set) { + return s.map(this.parse, this) + }, this); + + this.debug(this.pattern, set); + + // filter out everything that didn't compile properly. + set = set.filter(function (s) { + return s.indexOf(false) === -1 + }); + + this.debug(this.pattern, set); + + this.set = set; + } + + Minimatch.prototype.parseNegate = parseNegate; + function parseNegate () { + var pattern = this.pattern; + var negate = false; + var options = this.options; + var negateOffset = 0; + + if (options.nonegate) return + + for (var i = 0, l = pattern.length + ; i < l && pattern.charAt(i) === '!' + ; i++) { + negate = !negate; + negateOffset++; + } + + if (negateOffset) this.pattern = pattern.substr(negateOffset); + this.negate = negate; + } + + // Brace expansion: + // a{b,c}d -> abd acd + // a{b,}c -> abc ac + // a{0..3}d -> a0d a1d a2d a3d + // a{b,c{d,e}f}g -> abg acdfg acefg + // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg + // + // Invalid sets are not expanded. + // a{2..}b -> a{2..}b + // a{b}c -> a{b}c + minimatch.braceExpand = function (pattern, options) { + return braceExpand(pattern, options) + }; + + Minimatch.prototype.braceExpand = braceExpand; + + function braceExpand (pattern, options) { + if (!options) { + if (this instanceof Minimatch) { + options = this.options; + } else { + options = {}; + } + } + + pattern = typeof pattern === 'undefined' + ? this.pattern : pattern; + + if (typeof pattern === 'undefined') { + throw new TypeError('undefined pattern') + } + + if (options.nobrace || + !pattern.match(/\{.*\}/)) { + // shortcut. no need to expand. + return [pattern] + } + + return expand(pattern) + } + + // parse a component of the expanded set. + // At this point, no pattern may contain "/" in it + // so we're going to return a 2d array, where each entry is the full + // pattern, split on '/', and then turned into a regular expression. + // A regexp is made at the end which joins each array with an + // escaped /, and another full one which joins each regexp with |. + // + // Following the lead of Bash 4.1, note that "**" only has special meaning + // when it is the *only* thing in a path portion. Otherwise, any series + // of * is equivalent to a single *. Globstar behavior is enabled by + // default, and can be disabled by setting options.noglobstar. + Minimatch.prototype.parse = parse; + var SUBPARSE = {}; + function parse (pattern, isSub) { + if (pattern.length > 1024 * 64) { + throw new TypeError('pattern is too long') + } + + var options = this.options; + + // shortcuts + if (!options.noglobstar && pattern === '**') return GLOBSTAR + if (pattern === '') return '' + + var re = ''; + var hasMagic = !!options.nocase; + var escaping = false; + // ? => one single character + var patternListStack = []; + var negativeLists = []; + var stateChar; + var inClass = false; + var reClassStart = -1; + var classStart = -1; + // . and .. never match anything that doesn't start with ., + // even when options.dot is set. + var patternStart = pattern.charAt(0) === '.' ? '' // anything + // not (start or / followed by . or .. followed by / or end) + : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' + : '(?!\\.)'; + var self = this; + + function clearStateChar () { + if (stateChar) { + // we had some state-tracking character + // that wasn't consumed by this pass. + switch (stateChar) { + case '*': + re += star; + hasMagic = true; + break + case '?': + re += qmark; + hasMagic = true; + break + default: + re += '\\' + stateChar; + break + } + self.debug('clearStateChar %j %j', stateChar, re); + stateChar = false; + } + } + + for (var i = 0, len = pattern.length, c + ; (i < len) && (c = pattern.charAt(i)) + ; i++) { + this.debug('%s\t%s %s %j', pattern, i, re, c); + + // skip over any that are escaped. + if (escaping && reSpecials[c]) { + re += '\\' + c; + escaping = false; + continue + } + + switch (c) { + case '/': + // completely not allowed, even escaped. + // Should already be path-split by now. + return false + + case '\\': + clearStateChar(); + escaping = true; + continue + + // the various stateChar values + // for the "extglob" stuff. + case '?': + case '*': + case '+': + case '@': + case '!': + this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c); + + // all of those are literals inside a class, except that + // the glob [!a] means [^a] in regexp + if (inClass) { + this.debug(' in class'); + if (c === '!' && i === classStart + 1) c = '^'; + re += c; + continue + } + + // if we already have a stateChar, then it means + // that there was something like ** or +? in there. + // Handle the stateChar, then proceed with this one. + self.debug('call clearStateChar %j', stateChar); + clearStateChar(); + stateChar = c; + // if extglob is disabled, then +(asdf|foo) isn't a thing. + // just clear the statechar *now*, rather than even diving into + // the patternList stuff. + if (options.noext) clearStateChar(); + continue + + case '(': + if (inClass) { + re += '('; + continue + } + + if (!stateChar) { + re += '\\('; + continue + } + + patternListStack.push({ + type: stateChar, + start: i - 1, + reStart: re.length, + open: plTypes[stateChar].open, + close: plTypes[stateChar].close + }); + // negation is (?:(?!js)[^/]*) + re += stateChar === '!' ? '(?:(?!(?:' : '(?:'; + this.debug('plType %j %j', stateChar, re); + stateChar = false; + continue + + case ')': + if (inClass || !patternListStack.length) { + re += '\\)'; + continue + } + + clearStateChar(); + hasMagic = true; + var pl = patternListStack.pop(); + // negation is (?:(?!js)[^/]*) + // The others are (?:) + re += pl.close; + if (pl.type === '!') { + negativeLists.push(pl); + } + pl.reEnd = re.length; + continue + + case '|': + if (inClass || !patternListStack.length || escaping) { + re += '\\|'; + escaping = false; + continue + } + + clearStateChar(); + re += '|'; + continue + + // these are mostly the same in regexp and glob + case '[': + // swallow any state-tracking char before the [ + clearStateChar(); + + if (inClass) { + re += '\\' + c; + continue + } + + inClass = true; + classStart = i; + reClassStart = re.length; + re += c; + continue + + case ']': + // a right bracket shall lose its special + // meaning and represent itself in + // a bracket expression if it occurs + // first in the list. -- POSIX.2 2.8.3.2 + if (i === classStart + 1 || !inClass) { + re += '\\' + c; + escaping = false; + continue + } + + // handle the case where we left a class open. + // "[z-a]" is valid, equivalent to "\[z-a\]" + if (inClass) { + // split where the last [ was, make sure we don't have + // an invalid re. if so, re-walk the contents of the + // would-be class to re-translate any characters that + // were passed through as-is + // TODO: It would probably be faster to determine this + // without a try/catch and a new RegExp, but it's tricky + // to do safely. For now, this is safe and works. + var cs = pattern.substring(classStart + 1, i); + try { + RegExp('[' + cs + ']'); + } catch (er) { + // not a valid class! + var sp = this.parse(cs, SUBPARSE); + re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'; + hasMagic = hasMagic || sp[1]; + inClass = false; + continue + } + } + + // finish up the class. + hasMagic = true; + inClass = false; + re += c; + continue + + default: + // swallow any state char that wasn't consumed + clearStateChar(); + + if (escaping) { + // no need + escaping = false; + } else if (reSpecials[c] + && !(c === '^' && inClass)) { + re += '\\'; + } + + re += c; + + } // switch + } // for + + // handle the case where we left a class open. + // "[abc" is valid, equivalent to "\[abc" + if (inClass) { + // split where the last [ was, and escape it + // this is a huge pita. We now have to re-walk + // the contents of the would-be class to re-translate + // any characters that were passed through as-is + cs = pattern.substr(classStart + 1); + sp = this.parse(cs, SUBPARSE); + re = re.substr(0, reClassStart) + '\\[' + sp[0]; + hasMagic = hasMagic || sp[1]; + } + + // handle the case where we had a +( thing at the *end* + // of the pattern. + // each pattern list stack adds 3 chars, and we need to go through + // and escape any | chars that were passed through as-is for the regexp. + // Go through and escape them, taking care not to double-escape any + // | chars that were already escaped. + for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) { + var tail = re.slice(pl.reStart + pl.open.length); + this.debug('setting tail', re, pl); + // maybe some even number of \, then maybe 1 \, followed by a | + tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) { + if (!$2) { + // the | isn't already escaped, so escape it. + $2 = '\\'; + } + + // need to escape all those slashes *again*, without escaping the + // one that we need for escaping the | character. As it works out, + // escaping an even number of slashes can be done by simply repeating + // it exactly after itself. That's why this trick works. + // + // I am sorry that you have to see this. + return $1 + $1 + $2 + '|' + }); + + this.debug('tail=%j\n %s', tail, tail, pl, re); + var t = pl.type === '*' ? star + : pl.type === '?' ? qmark + : '\\' + pl.type; + + hasMagic = true; + re = re.slice(0, pl.reStart) + t + '\\(' + tail; + } + + // handle trailing things that only matter at the very end. + clearStateChar(); + if (escaping) { + // trailing \\ + re += '\\\\'; + } + + // only need to apply the nodot start if the re starts with + // something that could conceivably capture a dot + var addPatternStart = false; + switch (re.charAt(0)) { + case '.': + case '[': + case '(': addPatternStart = true; + } + + // Hack to work around lack of negative lookbehind in JS + // A pattern like: *.!(x).!(y|z) needs to ensure that a name + // like 'a.xyz.yz' doesn't match. So, the first negative + // lookahead, has to look ALL the way ahead, to the end of + // the pattern. + for (var n = negativeLists.length - 1; n > -1; n--) { + var nl = negativeLists[n]; + + var nlBefore = re.slice(0, nl.reStart); + var nlFirst = re.slice(nl.reStart, nl.reEnd - 8); + var nlLast = re.slice(nl.reEnd - 8, nl.reEnd); + var nlAfter = re.slice(nl.reEnd); + + nlLast += nlAfter; + + // Handle nested stuff like *(*.js|!(*.json)), where open parens + // mean that we should *not* include the ) in the bit that is considered + // "after" the negated section. + var openParensBefore = nlBefore.split('(').length - 1; + var cleanAfter = nlAfter; + for (i = 0; i < openParensBefore; i++) { + cleanAfter = cleanAfter.replace(/\)[+*?]?/, ''); + } + nlAfter = cleanAfter; + + var dollar = ''; + if (nlAfter === '' && isSub !== SUBPARSE) { + dollar = '$'; + } + var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast; + re = newRe; + } + + // if the re is not "" at this point, then we need to make sure + // it doesn't match against an empty path part. + // Otherwise a/* will match a/, which it should not. + if (re !== '' && hasMagic) { + re = '(?=.)' + re; + } + + if (addPatternStart) { + re = patternStart + re; + } + + // parsing just a piece of a larger pattern. + if (isSub === SUBPARSE) { + return [re, hasMagic] + } + + // skip the regexp for non-magical patterns + // unescape anything in it, though, so that it'll be + // an exact match against a file etc. + if (!hasMagic) { + return globUnescape(pattern) + } + + var flags = options.nocase ? 'i' : ''; + try { + var regExp = new RegExp('^' + re + '$', flags); + } catch (er) { + // If it was an invalid regular expression, then it can't match + // anything. This trick looks for a character after the end of + // the string, which is of course impossible, except in multi-line + // mode, but it's not a /m regex. + return new RegExp('$.') + } + + regExp._glob = pattern; + regExp._src = re; + + return regExp + } + + minimatch.makeRe = function (pattern, options) { + return new Minimatch(pattern, options || {}).makeRe() + }; + + Minimatch.prototype.makeRe = makeRe; + function makeRe () { + if (this.regexp || this.regexp === false) return this.regexp + + // at this point, this.set is a 2d array of partial + // pattern strings, or "**". + // + // It's better to use .match(). This function shouldn't + // be used, really, but it's pretty convenient sometimes, + // when you just want to work with a regex. + var set = this.set; + + if (!set.length) { + this.regexp = false; + return this.regexp + } + var options = this.options; + + var twoStar = options.noglobstar ? star + : options.dot ? twoStarDot + : twoStarNoDot; + var flags = options.nocase ? 'i' : ''; + + var re = set.map(function (pattern) { + return pattern.map(function (p) { + return (p === GLOBSTAR) ? twoStar + : (typeof p === 'string') ? regExpEscape(p) + : p._src + }).join('\\\/') + }).join('|'); + + // must match entire pattern + // ending in a * or ** will make it less strict. + re = '^(?:' + re + ')$'; + + // can match anything, as long as it's not this. + if (this.negate) re = '^(?!' + re + ').*$'; + + try { + this.regexp = new RegExp(re, flags); + } catch (ex) { + this.regexp = false; + } + return this.regexp + } + + minimatch.match = function (list, pattern, options) { + options = options || {}; + var mm = new Minimatch(pattern, options); + list = list.filter(function (f) { + return mm.match(f) + }); + if (mm.options.nonull && !list.length) { + list.push(pattern); + } + return list + }; + + Minimatch.prototype.match = match; + function match (f, partial) { + this.debug('match', f, this.pattern); + // short-circuit in the case of busted things. + // comments, etc. + if (this.comment) return false + if (this.empty) return f === '' + + if (f === '/' && partial) return true + + var options = this.options; + + // windows: need to use /, not \ + if (path.sep !== '/') { + f = f.split(path.sep).join('/'); + } + + // treat the test path as a set of pathparts. + f = f.split(slashSplit); + this.debug(this.pattern, 'split', f); + + // just ONE of the pattern sets in this.set needs to match + // in order for it to be valid. If negating, then just one + // match means that we have failed. + // Either way, return on the first hit. + + var set = this.set; + this.debug(this.pattern, 'set', set); + + // Find the basename of the path by looking for the last non-empty segment + var filename; + var i; + for (i = f.length - 1; i >= 0; i--) { + filename = f[i]; + if (filename) break + } + + for (i = 0; i < set.length; i++) { + var pattern = set[i]; + var file = f; + if (options.matchBase && pattern.length === 1) { + file = [filename]; + } + var hit = this.matchOne(file, pattern, partial); + if (hit) { + if (options.flipNegate) return true + return !this.negate + } + } + + // didn't get any hits. this is success if it's a negative + // pattern, failure otherwise. + if (options.flipNegate) return false + return this.negate + } + + // set partial to true to test if, for example, + // "/a/b" matches the start of "/*/b/*/d" + // Partial means, if you run out of file before you run + // out of pattern, then that's fine, as long as all + // the parts match. + Minimatch.prototype.matchOne = function (file, pattern, partial) { + var options = this.options; + + this.debug('matchOne', + { 'this': this, file: file, pattern: pattern }); + + this.debug('matchOne', file.length, pattern.length); + + for (var fi = 0, + pi = 0, + fl = file.length, + pl = pattern.length + ; (fi < fl) && (pi < pl) + ; fi++, pi++) { + this.debug('matchOne loop'); + var p = pattern[pi]; + var f = file[fi]; + + this.debug(pattern, p, f); + + // should be impossible. + // some invalid regexp stuff in the set. + if (p === false) return false + + if (p === GLOBSTAR) { + this.debug('GLOBSTAR', [pattern, p, f]); + + // "**" + // a/**/b/**/c would match the following: + // a/b/x/y/z/c + // a/x/y/z/b/c + // a/b/x/b/x/c + // a/b/c + // To do this, take the rest of the pattern after + // the **, and see if it would match the file remainder. + // If so, return success. + // If not, the ** "swallows" a segment, and try again. + // This is recursively awful. + // + // a/**/b/**/c matching a/b/x/y/z/c + // - a matches a + // - doublestar + // - matchOne(b/x/y/z/c, b/**/c) + // - b matches b + // - doublestar + // - matchOne(x/y/z/c, c) -> no + // - matchOne(y/z/c, c) -> no + // - matchOne(z/c, c) -> no + // - matchOne(c, c) yes, hit + var fr = fi; + var pr = pi + 1; + if (pr === pl) { + this.debug('** at the end'); + // a ** at the end will just swallow the rest. + // We have found a match. + // however, it will not swallow /.x, unless + // options.dot is set. + // . and .. are *never* matched by **, for explosively + // exponential reasons. + for (; fi < fl; fi++) { + if (file[fi] === '.' || file[fi] === '..' || + (!options.dot && file[fi].charAt(0) === '.')) return false + } + return true + } + + // ok, let's see if we can swallow whatever we can. + while (fr < fl) { + var swallowee = file[fr]; + + this.debug('\nglobstar while', file, fr, pattern, pr, swallowee); + + // XXX remove this slice. Just pass the start index. + if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) { + this.debug('globstar found match!', fr, fl, swallowee); + // found a match. + return true + } else { + // can't swallow "." or ".." ever. + // can only swallow ".foo" when explicitly asked. + if (swallowee === '.' || swallowee === '..' || + (!options.dot && swallowee.charAt(0) === '.')) { + this.debug('dot detected!', file, fr, pattern, pr); + break + } + + // ** swallows a segment, and continue. + this.debug('globstar swallow a segment, and continue'); + fr++; + } + } + + // no match was found. + // However, in partial mode, we can't say this is necessarily over. + // If there's more *pattern* left, then + if (partial) { + // ran out of file + this.debug('\n>>> no match, partial?', file, fr, pattern, pr); + if (fr === fl) return true + } + return false + } + + // something other than ** + // non-magic patterns just have to match exactly + // patterns with magic have been turned into regexps. + var hit; + if (typeof p === 'string') { + if (options.nocase) { + hit = f.toLowerCase() === p.toLowerCase(); + } else { + hit = f === p; + } + this.debug('string match', p, f, hit); + } else { + hit = f.match(p); + this.debug('pattern match', p, f, hit); + } + + if (!hit) return false + } + + // Note: ending in / means that we'll get a final "" + // at the end of the pattern. This can only match a + // corresponding "" at the end of the file. + // If the file ends in /, then it can only match a + // a pattern that ends in /, unless the pattern just + // doesn't have any more for it. But, a/b/ should *not* + // match "a/b/*", even though "" matches against the + // [^/]*? pattern, except in partial mode, where it might + // simply not be reached yet. + // However, a/b/ should still satisfy a/* + + // now either we fell off the end of the pattern, or we're done. + if (fi === fl && pi === pl) { + // ran out of pattern and filename at the same time. + // an exact hit! + return true + } else if (fi === fl) { + // ran out of file, but still had pattern left. + // this is ok if we're doing the match as part of + // a glob fs traversal. + return partial + } else if (pi === pl) { + // ran out of pattern, still have file left. + // this is only acceptable if we're on the very last + // empty segment of a file with a trailing slash. + // a/* should match a/b/ + var emptyFileEnd = (fi === fl - 1) && (file[fi] === ''); + return emptyFileEnd + } + + // should be unreachable. + throw new Error('wtf?') + }; + + // replace stuff like \* with * + function globUnescape (s) { + return s.replace(/\\(.)/g, '$1') + } + + function regExpEscape (s) { + return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&') + } + return minimatch_1; +} + +var inherits = {exports: {}}; + +var inherits_browser = {exports: {}}; + +var hasRequiredInherits_browser; + +function requireInherits_browser () { + if (hasRequiredInherits_browser) return inherits_browser.exports; + hasRequiredInherits_browser = 1; + if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + inherits_browser.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor; + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + } + }; + } else { + // old school shim for old browsers + inherits_browser.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor; + var TempCtor = function () {}; + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + }; + } + return inherits_browser.exports; +} + +var hasRequiredInherits; + +function requireInherits () { + if (hasRequiredInherits) return inherits.exports; + hasRequiredInherits = 1; + (function (module) { + try { + var util = require('util'); + /* istanbul ignore next */ + if (typeof util.inherits !== 'function') throw ''; + module.exports = util.inherits; + } catch (e) { + /* istanbul ignore next */ + module.exports = requireInherits_browser(); + } +} (inherits)); + return inherits.exports; +} + +var pathIsAbsolute = {exports: {}}; + +var hasRequiredPathIsAbsolute; + +function requirePathIsAbsolute () { + if (hasRequiredPathIsAbsolute) return pathIsAbsolute.exports; + hasRequiredPathIsAbsolute = 1; + + function posix(path) { + return path.charAt(0) === '/'; + } + + function win32(path) { + // https://github.com/nodejs/node/blob/b3fcc245fb25539909ef1d5eaa01dbf92e168633/lib/path.js#L56 + var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/; + var result = splitDeviceRe.exec(path); + var device = result[1] || ''; + var isUnc = Boolean(device && device.charAt(1) !== ':'); + + // UNC paths are always absolute + return Boolean(result[2] || isUnc); + } + + pathIsAbsolute.exports = process.platform === 'win32' ? win32 : posix; + pathIsAbsolute.exports.posix = posix; + pathIsAbsolute.exports.win32 = win32; + return pathIsAbsolute.exports; +} + +var common$1 = {}; + +var hasRequiredCommon$1; + +function requireCommon$1 () { + if (hasRequiredCommon$1) return common$1; + hasRequiredCommon$1 = 1; + common$1.setopts = setopts; + common$1.ownProp = ownProp; + common$1.makeAbs = makeAbs; + common$1.finish = finish; + common$1.mark = mark; + common$1.isIgnored = isIgnored; + common$1.childrenIgnored = childrenIgnored; + + function ownProp (obj, field) { + return Object.prototype.hasOwnProperty.call(obj, field) + } + + var path = require$$2; + var minimatch = requireMinimatch(); + var isAbsolute = requirePathIsAbsolute(); + var Minimatch = minimatch.Minimatch; + + function alphasort (a, b) { + return a.localeCompare(b, 'en') + } + + function setupIgnores (self, options) { + self.ignore = options.ignore || []; + + if (!Array.isArray(self.ignore)) + self.ignore = [self.ignore]; + + if (self.ignore.length) { + self.ignore = self.ignore.map(ignoreMap); + } + } + + // ignore patterns are always in dot:true mode. + function ignoreMap (pattern) { + var gmatcher = null; + if (pattern.slice(-3) === '/**') { + var gpattern = pattern.replace(/(\/\*\*)+$/, ''); + gmatcher = new Minimatch(gpattern, { dot: true }); + } + + return { + matcher: new Minimatch(pattern, { dot: true }), + gmatcher: gmatcher + } + } + + function setopts (self, pattern, options) { + if (!options) + options = {}; + + // base-matching: just use globstar for that. + if (options.matchBase && -1 === pattern.indexOf("/")) { + if (options.noglobstar) { + throw new Error("base matching requires globstar") + } + pattern = "**/" + pattern; + } + + self.silent = !!options.silent; + self.pattern = pattern; + self.strict = options.strict !== false; + self.realpath = !!options.realpath; + self.realpathCache = options.realpathCache || Object.create(null); + self.follow = !!options.follow; + self.dot = !!options.dot; + self.mark = !!options.mark; + self.nodir = !!options.nodir; + if (self.nodir) + self.mark = true; + self.sync = !!options.sync; + self.nounique = !!options.nounique; + self.nonull = !!options.nonull; + self.nosort = !!options.nosort; + self.nocase = !!options.nocase; + self.stat = !!options.stat; + self.noprocess = !!options.noprocess; + self.absolute = !!options.absolute; + + self.maxLength = options.maxLength || Infinity; + self.cache = options.cache || Object.create(null); + self.statCache = options.statCache || Object.create(null); + self.symlinks = options.symlinks || Object.create(null); + + setupIgnores(self, options); + + self.changedCwd = false; + var cwd = process.cwd(); + if (!ownProp(options, "cwd")) + self.cwd = cwd; + else { + self.cwd = path.resolve(options.cwd); + self.changedCwd = self.cwd !== cwd; + } + + self.root = options.root || path.resolve(self.cwd, "/"); + self.root = path.resolve(self.root); + if (process.platform === "win32") + self.root = self.root.replace(/\\/g, "/"); + + // TODO: is an absolute `cwd` supposed to be resolved against `root`? + // e.g. { cwd: '/test', root: __dirname } === path.join(__dirname, '/test') + self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd); + if (process.platform === "win32") + self.cwdAbs = self.cwdAbs.replace(/\\/g, "/"); + self.nomount = !!options.nomount; + + // disable comments and negation in Minimatch. + // Note that they are not supported in Glob itself anyway. + options.nonegate = true; + options.nocomment = true; + + self.minimatch = new Minimatch(pattern, options); + self.options = self.minimatch.options; + } + + function finish (self) { + var nou = self.nounique; + var all = nou ? [] : Object.create(null); + + for (var i = 0, l = self.matches.length; i < l; i ++) { + var matches = self.matches[i]; + if (!matches || Object.keys(matches).length === 0) { + if (self.nonull) { + // do like the shell, and spit out the literal glob + var literal = self.minimatch.globSet[i]; + if (nou) + all.push(literal); + else + all[literal] = true; + } + } else { + // had matches + var m = Object.keys(matches); + if (nou) + all.push.apply(all, m); + else + m.forEach(function (m) { + all[m] = true; + }); + } + } + + if (!nou) + all = Object.keys(all); + + if (!self.nosort) + all = all.sort(alphasort); + + // at *some* point we statted all of these + if (self.mark) { + for (var i = 0; i < all.length; i++) { + all[i] = self._mark(all[i]); + } + if (self.nodir) { + all = all.filter(function (e) { + var notDir = !(/\/$/.test(e)); + var c = self.cache[e] || self.cache[makeAbs(self, e)]; + if (notDir && c) + notDir = c !== 'DIR' && !Array.isArray(c); + return notDir + }); + } + } + + if (self.ignore.length) + all = all.filter(function(m) { + return !isIgnored(self, m) + }); + + self.found = all; + } + + function mark (self, p) { + var abs = makeAbs(self, p); + var c = self.cache[abs]; + var m = p; + if (c) { + var isDir = c === 'DIR' || Array.isArray(c); + var slash = p.slice(-1) === '/'; + + if (isDir && !slash) + m += '/'; + else if (!isDir && slash) + m = m.slice(0, -1); + + if (m !== p) { + var mabs = makeAbs(self, m); + self.statCache[mabs] = self.statCache[abs]; + self.cache[mabs] = self.cache[abs]; + } + } + + return m + } + + // lotta situps... + function makeAbs (self, f) { + var abs = f; + if (f.charAt(0) === '/') { + abs = path.join(self.root, f); + } else if (isAbsolute(f) || f === '') { + abs = f; + } else if (self.changedCwd) { + abs = path.resolve(self.cwd, f); + } else { + abs = path.resolve(f); + } + + if (process.platform === 'win32') + abs = abs.replace(/\\/g, '/'); + + return abs + } + + + // Return true, if pattern ends with globstar '**', for the accompanying parent directory. + // Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents + function isIgnored (self, path) { + if (!self.ignore.length) + return false + + return self.ignore.some(function(item) { + return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path)) + }) + } + + function childrenIgnored (self, path) { + if (!self.ignore.length) + return false + + return self.ignore.some(function(item) { + return !!(item.gmatcher && item.gmatcher.match(path)) + }) + } + return common$1; +} + +var sync; +var hasRequiredSync; + +function requireSync () { + if (hasRequiredSync) return sync; + hasRequiredSync = 1; + sync = globSync; + globSync.GlobSync = GlobSync; + + var fs = require$$1; + var rp = requireFs_realpath(); + var minimatch = requireMinimatch(); + minimatch.Minimatch; + requireGlob().Glob; + var path = require$$2; + var assert = require$$6; + var isAbsolute = requirePathIsAbsolute(); + var common = requireCommon$1(); + var setopts = common.setopts; + var ownProp = common.ownProp; + var childrenIgnored = common.childrenIgnored; + var isIgnored = common.isIgnored; + + function globSync (pattern, options) { + if (typeof options === 'function' || arguments.length === 3) + throw new TypeError('callback provided to sync glob\n'+ + 'See: https://github.com/isaacs/node-glob/issues/167') + + return new GlobSync(pattern, options).found + } + + function GlobSync (pattern, options) { + if (!pattern) + throw new Error('must provide pattern') + + if (typeof options === 'function' || arguments.length === 3) + throw new TypeError('callback provided to sync glob\n'+ + 'See: https://github.com/isaacs/node-glob/issues/167') + + if (!(this instanceof GlobSync)) + return new GlobSync(pattern, options) + + setopts(this, pattern, options); + + if (this.noprocess) + return this + + var n = this.minimatch.set.length; + this.matches = new Array(n); + for (var i = 0; i < n; i ++) { + this._process(this.minimatch.set[i], i, false); + } + this._finish(); + } + + GlobSync.prototype._finish = function () { + assert(this instanceof GlobSync); + if (this.realpath) { + var self = this; + this.matches.forEach(function (matchset, index) { + var set = self.matches[index] = Object.create(null); + for (var p in matchset) { + try { + p = self._makeAbs(p); + var real = rp.realpathSync(p, self.realpathCache); + set[real] = true; + } catch (er) { + if (er.syscall === 'stat') + set[self._makeAbs(p)] = true; + else + throw er + } + } + }); + } + common.finish(this); + }; + + + GlobSync.prototype._process = function (pattern, index, inGlobStar) { + assert(this instanceof GlobSync); + + // 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. + + // 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); + return + + 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 + } + + 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 + + var isGlobStar = remain[0] === minimatch.GLOBSTAR; + if (isGlobStar) + this._processGlobStar(prefix, read, abs, remain, index, inGlobStar); + else + this._processReaddir(prefix, read, abs, remain, index, inGlobStar); + }; + + + GlobSync.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar) { + var entries = this._readdir(abs, inGlobStar); + + // if the abs isn't a dir, then nothing can match! + if (!entries) + 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) === '.'; + + 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); + } + } + + var len = matchedEntries.length; + // If there are no matched entries, then nothing matches. + if (len === 0) + return + + // 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.slice(-1) !== '/') + 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 + } + + // 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) + newPattern = [prefix, e]; + else + newPattern = [e]; + this._process(newPattern.concat(remain), index, inGlobStar); + } + }; + + + GlobSync.prototype._emitMatch = function (index, e) { + if (isIgnored(this, e)) + return + + var abs = 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; + + if (this.stat) + this._stat(e); + }; + + + GlobSync.prototype._readdirInGlobStar = function (abs) { + // follow all symlinked directories forever + // just proceed as if this is a non-globstar situation + if (this.follow) + return this._readdir(abs, false) + + var entries; + var lstat; + try { + lstat = fs.lstatSync(abs); + } catch (er) { + if (er.code === 'ENOENT') { + // lstat failed, doesn't exist + return null + } + } + + var isSym = lstat && lstat.isSymbolicLink(); + this.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()) + this.cache[abs] = 'FILE'; + else + entries = this._readdir(abs, false); + + return entries + }; + + GlobSync.prototype._readdir = function (abs, inGlobStar) { + + if (inGlobStar && !ownProp(this.symlinks, abs)) + return this._readdirInGlobStar(abs) + + if (ownProp(this.cache, abs)) { + var c = this.cache[abs]; + if (!c || c === 'FILE') + return null + + if (Array.isArray(c)) + return c + } + + try { + return this._readdirEntries(abs, fs.readdirSync(abs)) + } catch (er) { + this._readdirError(abs, er); + return null + } + }; + + GlobSync.prototype._readdirEntries = function (abs, entries) { + // 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; + + // mark and cache dir-ness + return entries + }; + + GlobSync.prototype._readdirError = function (f, er) { + // 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; + throw error + } + 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) + throw er + if (!this.silent) + console.error('glob error', er); + break + } + }; + + GlobSync.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar) { + + var entries = this._readdir(abs, inGlobStar); + + // no entries means not a dir, so it can never have matches + // foo.txt/** doesn't match foo.txt + if (!entries) + return + + // 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); + + var len = entries.length; + var isSym = this.symlinks[abs]; + + // If it's a symlink, and we're in a globstar, then stop + if (isSym && inGlobStar) + return + + 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); + + var below = gspref.concat(entries[i], remain); + this._process(below, index, true); + } + }; + + GlobSync.prototype._processSimple = function (prefix, index) { + // XXX review this. Shouldn't it be doing the mounting etc + // before doing stat? kinda weird? + var exists = this._stat(prefix); + + if (!this.matches[index]) + this.matches[index] = Object.create(null); + + // If it doesn't exist, then just mark the lack of results + if (!exists) + return + + 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 += '/'; + } + } + + if (process.platform === 'win32') + prefix = prefix.replace(/\\/g, '/'); + + // Mark this as a match + this._emitMatch(index, prefix); + }; + + // Returns either 'DIR', 'FILE', or false + GlobSync.prototype._stat = function (f) { + var abs = this._makeAbs(f); + var needDir = f.slice(-1) === '/'; + + if (f.length > this.maxLength) + return false + + if (!this.stat && ownProp(this.cache, abs)) { + var c = this.cache[abs]; + + if (Array.isArray(c)) + c = 'DIR'; + + // It exists, but maybe not how we need it + if (!needDir || c === 'DIR') + return c + + if (needDir && c === 'FILE') + return false + + // otherwise we have to stat, because maybe c=true + // if we know it exists, but not what it is. + } + var stat = this.statCache[abs]; + if (!stat) { + var lstat; + try { + lstat = fs.lstatSync(abs); + } catch (er) { + if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) { + this.statCache[abs] = false; + return false + } + } + + if (lstat && lstat.isSymbolicLink()) { + try { + stat = fs.statSync(abs); + } catch (er) { + stat = lstat; + } + } else { + stat = lstat; + } + } + + this.statCache[abs] = stat; + + var c = true; + if (stat) + c = stat.isDirectory() ? 'DIR' : 'FILE'; + + this.cache[abs] = this.cache[abs] || c; + + if (needDir && c === 'FILE') + return false + + return c + }; + + GlobSync.prototype._mark = function (p) { + return common.mark(this, p) + }; + + GlobSync.prototype._makeAbs = function (f) { + return common.makeAbs(this, f) + }; + return sync; +} + +var wrappy_1; +var hasRequiredWrappy; + +function requireWrappy () { + if (hasRequiredWrappy) return wrappy_1; + hasRequiredWrappy = 1; + // Returns a wrapper function that returns a wrapped callback + // The wrapper function should do some stuff, and return a + // presumably different callback function. + // This makes sure that own properties are retained, so that + // decorations and such are not lost along the way. + wrappy_1 = wrappy; + function wrappy (fn, cb) { + if (fn && cb) return wrappy(fn)(cb) + + if (typeof fn !== 'function') + throw new TypeError('need wrapper function') + + Object.keys(fn).forEach(function (k) { + wrapper[k] = fn[k]; + }); + + return wrapper + + function wrapper() { + var args = new Array(arguments.length); + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i]; + } + var ret = fn.apply(this, args); + var cb = args[args.length-1]; + if (typeof ret === 'function' && ret !== cb) { + Object.keys(cb).forEach(function (k) { + ret[k] = cb[k]; + }); + } + return ret + } + } + return wrappy_1; +} + +var once = {exports: {}}; + +var hasRequiredOnce; + +function requireOnce () { + if (hasRequiredOnce) return once.exports; + hasRequiredOnce = 1; + var wrappy = requireWrappy(); + once.exports = wrappy(once$1); + once.exports.strict = wrappy(onceStrict); + + once$1.proto = once$1(function () { + Object.defineProperty(Function.prototype, 'once', { + value: function () { + return once$1(this) + }, + configurable: true + }); + + Object.defineProperty(Function.prototype, 'onceStrict', { + value: function () { + return onceStrict(this) + }, + configurable: true + }); + }); + + function once$1 (fn) { + var f = function () { + if (f.called) return f.value + f.called = true; + return f.value = fn.apply(this, arguments) + }; + f.called = false; + return f + } + + function onceStrict (fn) { + var f = function () { + if (f.called) + throw new Error(f.onceError) + f.called = true; + return f.value = fn.apply(this, arguments) + }; + var name = fn.name || 'Function wrapped with `once`'; + f.onceError = name + " shouldn't be called more than once"; + f.called = false; + return f + } + return once.exports; +} + +var inflight_1; +var hasRequiredInflight; + +function requireInflight () { + if (hasRequiredInflight) return inflight_1; + hasRequiredInflight = 1; + var wrappy = requireWrappy(); + var reqs = Object.create(null); + var once = requireOnce(); + + inflight_1 = wrappy(inflight); + + function inflight (key, cb) { + if (reqs[key]) { + reqs[key].push(cb); + return null + } else { + reqs[key] = [cb]; + return makeres(key) + } + } + + function makeres (key) { + return once(function RES () { + var cbs = reqs[key]; + var len = cbs.length; + var args = slice(arguments); + + // XXX It's somewhat ambiguous whether a new callback added in this + // pass should be queued for later execution if something in the + // list of callbacks throws, or if it should just be discarded. + // However, it's such an edge case that it hardly matters, and either + // choice is likely as surprising as the other. + // As it happens, we do go ahead and schedule it for later execution. + try { + for (var i = 0; i < len; i++) { + cbs[i].apply(null, args); + } + } finally { + if (cbs.length > len) { + // added more in the interim. + // de-zalgo, just in case, but don't call again. + cbs.splice(0, len); + process.nextTick(function () { + RES.apply(null, args); + }); + } else { + delete reqs[key]; + } + } + }) + } + + function slice (args) { + var length = args.length; + var array = []; + + for (var i = 0; i < length; i++) array[i] = args[i]; + return array + } + return inflight_1; +} + +var glob_1; +var hasRequiredGlob; + +function requireGlob () { + if (hasRequiredGlob) return glob_1; + hasRequiredGlob = 1; + // 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. + + glob_1 = glob; + + var fs = require$$1; + var rp = requireFs_realpath(); + var minimatch = requireMinimatch(); + minimatch.Minimatch; + var inherits = requireInherits(); + var EE = require$$4.EventEmitter; + var path = require$$2; + var assert = require$$6; + var isAbsolute = requirePathIsAbsolute(); + var globSync = requireSync(); + var common = requireCommon$1(); + var setopts = common.setopts; + var ownProp = common.ownProp; + var inflight = requireInflight(); + var childrenIgnored = common.childrenIgnored; + var isIgnored = common.isIgnored; + + var once = requireOnce(); + + function glob (pattern, options, cb) { + if (typeof options === 'function') cb = options, options = {}; + if (!options) options = {}; + + if (options.sync) { + if (cb) + throw new TypeError('callback provided to sync glob') + return globSync(pattern, options) + } + + return new Glob(pattern, options, cb) + } + + glob.sync = globSync; + var GlobSync = glob.GlobSync = globSync.GlobSync; + + // old api surface + glob.glob = glob; + + function extend (origin, add) { + if (add === null || typeof add !== 'object') { + return origin + } + + var keys = Object.keys(add); + var i = keys.length; + while (i--) { + origin[keys[i]] = add[keys[i]]; + } + return origin + } + + 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 + }; + + glob.Glob = Glob; + inherits(Glob, EE); + function Glob (pattern, options, cb) { + if (typeof options === 'function') { + cb = options; + options = null; + } + + if (options && options.sync) { + if (cb) + throw new TypeError('callback provided to sync glob') + return new GlobSync(pattern, options) + } + + if (!(this instanceof Glob)) + return new Glob(pattern, options, cb) + + setopts(this, pattern, options); + this._didRealPath = false; + + // process each pattern in the minimatch set + var n = this.minimatch.set.length; + + // 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); + + if (typeof cb === 'function') { + cb = once(cb); + this.on('error', cb); + this.on('end', function (matches) { + cb(null, matches); + }); + } + + var self = this; + this._processing = 0; + + this._emitQueue = []; + this._processQueue = []; + this.paused = false; + + if (this.noprocess) + return this + + if (n === 0) + return done() + + var sync = true; + for (var i = 0; i < n; i ++) { + this._process(this.minimatch.set[i], i, false, done); + } + sync = false; + + function done () { + --self._processing; + if (self._processing <= 0) { + if (sync) { + process.nextTick(function () { + self._finish(); + }); + } else { + self._finish(); + } + } + } + } + + Glob.prototype._finish = function () { + assert(this instanceof Glob); + if (this.aborted) + return + + if (this.realpath && !this._didRealpath) + return this._realpath() + + common.finish(this); + this.emit('end', this.found); + }; + + Glob.prototype._realpath = function () { + if (this._didRealpath) + return + + this._didRealpath = true; + + var n = this.matches.length; + if (n === 0) + return this._finish() + + var self = this; + for (var i = 0; i < this.matches.length; i++) + this._realpathSet(i, next); + + function next () { + if (--n === 0) + self._finish(); + } + }; + + 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() + + 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(); + } + }); + }); + }; + + Glob.prototype._mark = function (p) { + return common.mark(this, p) + }; + + Glob.prototype._makeAbs = function (f) { + return common.makeAbs(this, f) + }; + + Glob.prototype.abort = function () { + this.aborted = true; + this.emit('abort'); + }; + + Glob.prototype.pause = function () { + if (!this.paused) { + this.paused = true; + this.emit('pause'); + } + }; + + 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]); + } + } + } + }; + + Glob.prototype._process = function (pattern, index, inGlobStar, cb) { + assert(this instanceof Glob); + assert(typeof cb === 'function'); + + if (this.aborted) + return + + this._processing++; + if (this.paused) { + this._processQueue.push([pattern, index, inGlobStar, cb]); + return + } + + //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. + + // 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 + + 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 + } + + 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() + + 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); + }; + + 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) + }); + }; + + 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); + } + } + + //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() + + // 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]; + if (prefix) { + if (prefix !== '/') + e = prefix + '/' + e; + else + e = prefix + e; + } + this._process([e].concat(remain), index, inGlobStar, cb); + } + 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 + } + + 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); + }; + + 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); + } + }; + + 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) + } + 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(); + }; + + 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) { + + //console.error('ps2', prefix, exists) + + if (!this.matches[index]) + this.matches[index] = Object.create(null); + + // If it doesn't exist, then just mark the lack of results + if (!exists) + return cb() + + 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 += '/'; + } + } + + if (process.platform === 'win32') + prefix = prefix.replace(/\\/g, '/'); + + // Mark this as a match + this._emitMatch(index, prefix); + cb(); + }; + + // Returns either 'DIR', 'FILE', or false + Glob.prototype._stat = function (f, cb) { + var abs = this._makeAbs(f); + var needDir = f.slice(-1) === '/'; + + if (f.length > this.maxLength) + return cb() + + if (!this.stat && ownProp(this.cache, abs)) { + var c = this.cache[abs]; + + if (Array.isArray(c)) + c = 'DIR'; + + // It exists, but maybe not how we need it + if (!needDir || c === 'DIR') + return cb(null, c) + + if (needDir && c === 'FILE') + return cb() + + // otherwise we have to stat, because maybe c=true + // if we know it exists, but not what it is. + } + 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) + } + } + + var self = this; + var statcb = inflight('stat\0' + abs, lstatcb_); + if (statcb) + fs.lstat(abs, statcb); + + 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); + } + } + }; + + Glob.prototype._stat2 = function (f, abs, er, stat, cb) { + if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) { + this.statCache[abs] = false; + return cb() + } + + var needDir = f.slice(-1) === '/'; + this.statCache[abs] = stat; + + if (abs.slice(-1) === '/' && stat && !stat.isDirectory()) + return cb(null, false, stat) + + var c = true; + if (stat) + c = stat.isDirectory() ? 'DIR' : 'FILE'; + this.cache[abs] = this.cache[abs] || c; + + if (needDir && c === 'FILE') + return cb() + + return cb(null, c, stat) + }; + return glob_1; +} + +var hasRequiredCommon; + +function requireCommon () { + if (hasRequiredCommon) return common$2; + hasRequiredCommon = 1; + + var os = require$$0; + var fs = require$$1; + var glob = requireGlob(); + var shell = requireShell(); + + var shellMethods = Object.create(shell); + + common$2.extend = Object.assign; + + // Check if we're running under electron + var isElectron = Boolean(process.versions.electron); + + // Module globals (assume no execPath by default) + var DEFAULT_CONFIG = { + fatal: false, + globOptions: {}, + maxdepth: 255, + noglob: false, + silent: false, + verbose: false, + execPath: null, + bufLength: 64 * 1024, // 64KB + }; + + var config = { + reset: function () { + Object.assign(this, DEFAULT_CONFIG); + if (!isElectron) { + this.execPath = process.execPath; + } + }, + resetForTesting: function () { + this.reset(); + this.silent = true; + }, + }; + + config.reset(); + common$2.config = config; + + // Note: commands should generally consider these as read-only values. + var state = { + error: null, + errorCode: 0, + currentCmd: 'shell.js', + }; + common$2.state = state; + + delete process.env.OLDPWD; // initially, there's no previous directory + + // Reliably test if something is any sort of javascript object + function isObject(a) { + return typeof a === 'object' && a !== null; + } + common$2.isObject = isObject; + + function log() { + /* istanbul ignore next */ + if (!config.silent) { + console.error.apply(console, arguments); + } + } + common$2.log = log; + + // Converts strings to be equivalent across all platforms. Primarily responsible + // for making sure we use '/' instead of '\' as path separators, but this may be + // expanded in the future if necessary + function convertErrorOutput(msg) { + if (typeof msg !== 'string') { + throw new TypeError('input must be a string'); + } + return msg.replace(/\\/g, '/'); + } + common$2.convertErrorOutput = convertErrorOutput; + + // Shows error message. Throws if config.fatal is true + function error(msg, _code, options) { + // Validate input + if (typeof msg !== 'string') throw new Error('msg must be a string'); + + var DEFAULT_OPTIONS = { + continue: false, + code: 1, + prefix: state.currentCmd + ': ', + silent: false, + }; + + if (typeof _code === 'number' && isObject(options)) { + options.code = _code; + } else if (isObject(_code)) { // no 'code' + options = _code; + } else if (typeof _code === 'number') { // no 'options' + options = { code: _code }; + } else if (typeof _code !== 'number') { // only 'msg' + options = {}; + } + options = Object.assign({}, DEFAULT_OPTIONS, options); + + if (!state.errorCode) state.errorCode = options.code; + + var logEntry = convertErrorOutput(options.prefix + msg); + state.error = state.error ? state.error + '\n' : ''; + state.error += logEntry; + + // Throw an error, or log the entry + if (config.fatal) throw new Error(logEntry); + if (msg.length > 0 && !options.silent) log(logEntry); + + if (!options.continue) { + throw { + msg: 'earlyExit', + retValue: (new ShellString('', state.error, state.errorCode)), + }; + } + } + common$2.error = error; + + //@ + //@ ### ShellString(str) + //@ + //@ Examples: + //@ + //@ ```javascript + //@ var foo = ShellString('hello world'); + //@ ``` + //@ + //@ Turns a regular string into a string-like object similar to what each + //@ command returns. This has special methods, like `.to()` and `.toEnd()`. + function ShellString(stdout, stderr, code) { + var that; + if (stdout instanceof Array) { + that = stdout; + that.stdout = stdout.join('\n'); + if (stdout.length > 0) that.stdout += '\n'; + } else { + that = new String(stdout); + that.stdout = stdout; + } + that.stderr = stderr; + that.code = code; + // A list of all commands that can appear on the right-hand side of a pipe + // (populated by calls to common.wrap()) + pipeMethods.forEach(function (cmd) { + that[cmd] = shellMethods[cmd].bind(that); + }); + return that; + } + + common$2.ShellString = ShellString; + + // Returns {'alice': true, 'bob': false} when passed a string and dictionary as follows: + // parseOptions('-a', {'a':'alice', 'b':'bob'}); + // Returns {'reference': 'string-value', 'bob': false} when passed two dictionaries of the form: + // parseOptions({'-r': 'string-value'}, {'r':'reference', 'b':'bob'}); + // Throws an error when passed a string that does not start with '-': + // parseOptions('a', {'a':'alice'}); // throws + function parseOptions(opt, map, errorOptions) { + // Validate input + if (typeof opt !== 'string' && !isObject(opt)) { + throw new Error('options must be strings or key-value pairs'); + } else if (!isObject(map)) { + throw new Error('parseOptions() internal error: map must be an object'); + } else if (errorOptions && !isObject(errorOptions)) { + throw new Error('parseOptions() internal error: errorOptions must be object'); + } + + if (opt === '--') { + // This means there are no options. + return {}; + } + + // All options are false by default + var options = {}; + Object.keys(map).forEach(function (letter) { + var optName = map[letter]; + if (optName[0] !== '!') { + options[optName] = false; + } + }); + + if (opt === '') return options; // defaults + + if (typeof opt === 'string') { + if (opt[0] !== '-') { + throw new Error("Options string must start with a '-'"); + } + + // e.g. chars = ['R', 'f'] + var chars = opt.slice(1).split(''); + + chars.forEach(function (c) { + if (c in map) { + var optionName = map[c]; + if (optionName[0] === '!') { + options[optionName.slice(1)] = false; + } else { + options[optionName] = true; + } + } else { + error('option not recognized: ' + c, errorOptions || {}); + } + }); + } else { // opt is an Object + Object.keys(opt).forEach(function (key) { + // key is a string of the form '-r', '-d', etc. + var c = key[1]; + if (c in map) { + var optionName = map[c]; + options[optionName] = opt[key]; // assign the given value + } else { + error('option not recognized: ' + c, errorOptions || {}); + } + }); + } + return options; + } + common$2.parseOptions = parseOptions; + + // Expands wildcards with matching (ie. existing) file names. + // For example: + // expand(['file*.js']) = ['file1.js', 'file2.js', ...] + // (if the files 'file1.js', 'file2.js', etc, exist in the current dir) + function expand(list) { + if (!Array.isArray(list)) { + throw new TypeError('must be an array'); + } + var expanded = []; + list.forEach(function (listEl) { + // Don't expand non-strings + if (typeof listEl !== 'string') { + expanded.push(listEl); + } else { + var ret; + try { + ret = glob.sync(listEl, config.globOptions); + // if nothing matched, interpret the string literally + ret = ret.length > 0 ? ret : [listEl]; + } catch (e) { + // if glob fails, interpret the string literally + ret = [listEl]; + } + expanded = expanded.concat(ret); + } + }); + return expanded; + } + common$2.expand = expand; + + // Normalizes Buffer creation, using Buffer.alloc if possible. + // Also provides a good default buffer length for most use cases. + var buffer = typeof Buffer.alloc === 'function' ? + function (len) { + return Buffer.alloc(len || config.bufLength); + } : + function (len) { + return new Buffer(len || config.bufLength); + }; + common$2.buffer = buffer; + + // Normalizes _unlinkSync() across platforms to match Unix behavior, i.e. + // file can be unlinked even if it's read-only, see https://github.com/joyent/node/issues/3006 + function unlinkSync(file) { + try { + fs.unlinkSync(file); + } catch (e) { + // Try to override file permission + /* istanbul ignore next */ + if (e.code === 'EPERM') { + fs.chmodSync(file, '0666'); + fs.unlinkSync(file); + } else { + throw e; + } + } + } + common$2.unlinkSync = unlinkSync; + + // wrappers around common.statFollowLinks and common.statNoFollowLinks that clarify intent + // and improve readability + function statFollowLinks() { + return fs.statSync.apply(fs, arguments); + } + common$2.statFollowLinks = statFollowLinks; + + function statNoFollowLinks() { + return fs.lstatSync.apply(fs, arguments); + } + common$2.statNoFollowLinks = statNoFollowLinks; + + // e.g. 'shelljs_a5f185d0443ca...' + function randomFileName() { + function randomHash(count) { + if (count === 1) { + return parseInt(16 * Math.random(), 10).toString(16); + } + var hash = ''; + for (var i = 0; i < count; i++) { + hash += randomHash(1); + } + return hash; + } + + return 'shelljs_' + randomHash(20); + } + common$2.randomFileName = randomFileName; + + // Common wrapper for all Unix-like commands that performs glob expansion, + // command-logging, and other nice things + function wrap(cmd, fn, options) { + options = options || {}; + return function () { + var retValue = null; + + state.currentCmd = cmd; + state.error = null; + state.errorCode = 0; + + try { + var args = [].slice.call(arguments, 0); + + // Log the command to stderr, if appropriate + if (config.verbose) { + console.error.apply(console, [cmd].concat(args)); + } + + // If this is coming from a pipe, let's set the pipedValue (otherwise, set + // it to the empty string) + state.pipedValue = (this && typeof this.stdout === 'string') ? this.stdout : ''; + + if (options.unix === false) { // this branch is for exec() + retValue = fn.apply(this, args); + } else { // and this branch is for everything else + if (isObject(args[0]) && args[0].constructor.name === 'Object') { + // a no-op, allowing the syntax `touch({'-r': file}, ...)` + } else if (args.length === 0 || typeof args[0] !== 'string' || args[0].length <= 1 || args[0][0] !== '-') { + args.unshift(''); // only add dummy option if '-option' not already present + } + + // flatten out arrays that are arguments, to make the syntax: + // `cp([file1, file2, file3], dest);` + // equivalent to: + // `cp(file1, file2, file3, dest);` + args = args.reduce(function (accum, cur) { + if (Array.isArray(cur)) { + return accum.concat(cur); + } + accum.push(cur); + return accum; + }, []); + + // Convert ShellStrings (basically just String objects) to regular strings + args = args.map(function (arg) { + if (isObject(arg) && arg.constructor.name === 'String') { + return arg.toString(); + } + return arg; + }); + + // Expand the '~' if appropriate + var homeDir = os.homedir(); + args = args.map(function (arg) { + if (typeof arg === 'string' && arg.slice(0, 2) === '~/' || arg === '~') { + return arg.replace(/^~/, homeDir); + } + return arg; + }); + + // Perform glob-expansion on all arguments after globStart, but preserve + // the arguments before it (like regexes for sed and grep) + if (!config.noglob && options.allowGlobbing === true) { + args = args.slice(0, options.globStart).concat(expand(args.slice(options.globStart))); + } + + try { + // parse options if options are provided + if (isObject(options.cmdOptions)) { + args[0] = parseOptions(args[0], options.cmdOptions); + } + + retValue = fn.apply(this, args); + } catch (e) { + /* istanbul ignore else */ + if (e.msg === 'earlyExit') { + retValue = e.retValue; + } else { + throw e; // this is probably a bug that should be thrown up the call stack + } + } + } + } catch (e) { + /* istanbul ignore next */ + if (!state.error) { + // If state.error hasn't been set it's an error thrown by Node, not us - probably a bug... + e.name = 'ShellJSInternalError'; + throw e; + } + if (config.fatal) throw e; + } + + if (options.wrapOutput && + (typeof retValue === 'string' || Array.isArray(retValue))) { + retValue = new ShellString(retValue, state.error, state.errorCode); + } + + state.currentCmd = 'shell.js'; + return retValue; + }; + } // wrap + common$2.wrap = wrap; + + // This returns all the input that is piped into the current command (or the + // empty string, if this isn't on the right-hand side of a pipe + function _readFromPipe() { + return state.pipedValue; + } + common$2.readFromPipe = _readFromPipe; + + var DEFAULT_WRAP_OPTIONS = { + allowGlobbing: true, + canReceivePipe: false, + cmdOptions: null, + globStart: 1, + pipeOnly: false, + wrapOutput: true, + unix: true, + }; + + // This is populated during plugin registration + var pipeMethods = []; + + // Register a new ShellJS command + function _register(name, implementation, wrapOptions) { + wrapOptions = wrapOptions || {}; + + // Validate options + Object.keys(wrapOptions).forEach(function (option) { + if (!DEFAULT_WRAP_OPTIONS.hasOwnProperty(option)) { + throw new Error("Unknown option '" + option + "'"); + } + if (typeof wrapOptions[option] !== typeof DEFAULT_WRAP_OPTIONS[option]) { + throw new TypeError("Unsupported type '" + typeof wrapOptions[option] + + "' for option '" + option + "'"); + } + }); + + // If an option isn't specified, use the default + wrapOptions = Object.assign({}, DEFAULT_WRAP_OPTIONS, wrapOptions); + + if (shell.hasOwnProperty(name)) { + throw new Error('Command `' + name + '` already exists'); + } + + if (wrapOptions.pipeOnly) { + wrapOptions.canReceivePipe = true; + shellMethods[name] = wrap(name, implementation, wrapOptions); + } else { + shell[name] = wrap(name, implementation, wrapOptions); + } + + if (wrapOptions.canReceivePipe) { + pipeMethods.push(name); + } + } + common$2.register = _register; + return common$2; +} + +var cat; +var hasRequiredCat; + +function requireCat () { + if (hasRequiredCat) return cat; + hasRequiredCat = 1; + var common = requireCommon(); + var fs = require$$1; + + common.register('cat', _cat, { + canReceivePipe: true, + cmdOptions: { + 'n': 'number', + }, + }); + + //@ + //@ ### cat([options,] file [, file ...]) + //@ ### cat([options,] file_array) + //@ + //@ Available options: + //@ + //@ + `-n`: number all output lines + //@ + //@ Examples: + //@ + //@ ```javascript + //@ var str = cat('file*.txt'); + //@ var str = cat('file1', 'file2'); + //@ var str = cat(['file1', 'file2']); // same as above + //@ ``` + //@ + //@ Returns a string containing the given file, or a concatenated string + //@ containing the files if more than one file is given (a new line character is + //@ introduced between each file). + function _cat(options, files) { + var cat = common.readFromPipe(); + + if (!files && !cat) common.error('no paths given'); + + files = [].slice.call(arguments, 1); + + files.forEach(function (file) { + if (!fs.existsSync(file)) { + common.error('no such file or directory: ' + file); + } else if (common.statFollowLinks(file).isDirectory()) { + common.error(file + ': Is a directory'); + } + + cat += fs.readFileSync(file, 'utf8'); + }); + + if (options.number) { + cat = addNumbers(cat); + } + + return cat; + } + cat = _cat; + + function addNumbers(cat) { + var lines = cat.split('\n'); + var lastLine = lines.pop(); + + lines = lines.map(function (line, i) { + return numberedLine(i + 1, line); + }); + + if (lastLine.length) { + lastLine = numberedLine(lines.length + 1, lastLine); + } + lines.push(lastLine); + + return lines.join('\n'); + } + + function numberedLine(n, line) { + // GNU cat use six pad start number + tab. See http://lingrok.org/xref/coreutils/src/cat.c#57 + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart + var number = (' ' + n).slice(-6) + '\t'; + return number + line; + } + return cat; +} + +var cd; +var hasRequiredCd; + +function requireCd () { + if (hasRequiredCd) return cd; + hasRequiredCd = 1; + var os = require$$0; + var common = requireCommon(); + + common.register('cd', _cd, {}); + + //@ + //@ ### cd([dir]) + //@ + //@ Changes to directory `dir` for the duration of the script. Changes to home + //@ directory if no argument is supplied. + function _cd(options, dir) { + if (!dir) dir = os.homedir(); + + if (dir === '-') { + if (!process.env.OLDPWD) { + common.error('could not find previous directory'); + } else { + dir = process.env.OLDPWD; + } + } + + try { + var curDir = process.cwd(); + process.chdir(dir); + process.env.OLDPWD = curDir; + } catch (e) { + // something went wrong, let's figure out the error + var err; + try { + common.statFollowLinks(dir); // if this succeeds, it must be some sort of file + err = 'not a directory: ' + dir; + } catch (e2) { + err = 'no such file or directory: ' + dir; + } + if (err) common.error(err); + } + return ''; + } + cd = _cd; + return cd; +} + +var chmod; +var hasRequiredChmod; + +function requireChmod () { + if (hasRequiredChmod) return chmod; + hasRequiredChmod = 1; + var common = requireCommon(); + var fs = require$$1; + var path = require$$2; + + var PERMS = (function (base) { + return { + OTHER_EXEC: base.EXEC, + OTHER_WRITE: base.WRITE, + OTHER_READ: base.READ, + + GROUP_EXEC: base.EXEC << 3, + GROUP_WRITE: base.WRITE << 3, + GROUP_READ: base.READ << 3, + + OWNER_EXEC: base.EXEC << 6, + OWNER_WRITE: base.WRITE << 6, + OWNER_READ: base.READ << 6, + + // Literal octal numbers are apparently not allowed in "strict" javascript. + STICKY: parseInt('01000', 8), + SETGID: parseInt('02000', 8), + SETUID: parseInt('04000', 8), + + TYPE_MASK: parseInt('0770000', 8), + }; + }({ + EXEC: 1, + WRITE: 2, + READ: 4, + })); + + common.register('chmod', _chmod, { + }); + + //@ + //@ ### chmod([options,] octal_mode || octal_string, file) + //@ ### chmod([options,] symbolic_mode, file) + //@ + //@ Available options: + //@ + //@ + `-v`: output a diagnostic for every file processed//@ + //@ + `-c`: like verbose, but report only when a change is made//@ + //@ + `-R`: change files and directories recursively//@ + //@ + //@ Examples: + //@ + //@ ```javascript + //@ chmod(755, '/Users/brandon'); + //@ chmod('755', '/Users/brandon'); // same as above + //@ chmod('u+x', '/Users/brandon'); + //@ chmod('-R', 'a-w', '/Users/brandon'); + //@ ``` + //@ + //@ Alters the permissions of a file or directory by either specifying the + //@ absolute permissions in octal form or expressing the changes in symbols. + //@ This command tries to mimic the POSIX behavior as much as possible. + //@ Notable exceptions: + //@ + //@ + In symbolic modes, `a-r` and `-r` are identical. No consideration is + //@ given to the `umask`. + //@ + There is no "quiet" option, since default behavior is to run silent. + function _chmod(options, mode, filePattern) { + if (!filePattern) { + if (options.length > 0 && options.charAt(0) === '-') { + // Special case where the specified file permissions started with - to subtract perms, which + // get picked up by the option parser as command flags. + // If we are down by one argument and options starts with -, shift everything over. + [].unshift.call(arguments, ''); + } else { + common.error('You must specify a file.'); + } + } + + options = common.parseOptions(options, { + 'R': 'recursive', + 'c': 'changes', + 'v': 'verbose', + }); + + filePattern = [].slice.call(arguments, 2); + + var files; + + // TODO: replace this with a call to common.expand() + if (options.recursive) { + files = []; + filePattern.forEach(function addFile(expandedFile) { + var stat = common.statNoFollowLinks(expandedFile); + + if (!stat.isSymbolicLink()) { + files.push(expandedFile); + + if (stat.isDirectory()) { // intentionally does not follow symlinks. + fs.readdirSync(expandedFile).forEach(function (child) { + addFile(expandedFile + '/' + child); + }); + } + } + }); + } else { + files = filePattern; + } + + files.forEach(function innerChmod(file) { + file = path.resolve(file); + if (!fs.existsSync(file)) { + common.error('File not found: ' + file); + } + + // When recursing, don't follow symlinks. + if (options.recursive && common.statNoFollowLinks(file).isSymbolicLink()) { + return; + } + + var stat = common.statFollowLinks(file); + var isDir = stat.isDirectory(); + var perms = stat.mode; + var type = perms & PERMS.TYPE_MASK; + + var newPerms = perms; + + if (isNaN(parseInt(mode, 8))) { + // parse options + mode.split(',').forEach(function (symbolicMode) { + var pattern = /([ugoa]*)([=\+-])([rwxXst]*)/i; + var matches = pattern.exec(symbolicMode); + + if (matches) { + var applyTo = matches[1]; + var operator = matches[2]; + var change = matches[3]; + + var changeOwner = applyTo.indexOf('u') !== -1 || applyTo === 'a' || applyTo === ''; + var changeGroup = applyTo.indexOf('g') !== -1 || applyTo === 'a' || applyTo === ''; + var changeOther = applyTo.indexOf('o') !== -1 || applyTo === 'a' || applyTo === ''; + + var changeRead = change.indexOf('r') !== -1; + var changeWrite = change.indexOf('w') !== -1; + var changeExec = change.indexOf('x') !== -1; + var changeExecDir = change.indexOf('X') !== -1; + var changeSticky = change.indexOf('t') !== -1; + var changeSetuid = change.indexOf('s') !== -1; + + if (changeExecDir && isDir) { + changeExec = true; + } + + var mask = 0; + if (changeOwner) { + mask |= (changeRead ? PERMS.OWNER_READ : 0) + (changeWrite ? PERMS.OWNER_WRITE : 0) + (changeExec ? PERMS.OWNER_EXEC : 0) + (changeSetuid ? PERMS.SETUID : 0); + } + if (changeGroup) { + mask |= (changeRead ? PERMS.GROUP_READ : 0) + (changeWrite ? PERMS.GROUP_WRITE : 0) + (changeExec ? PERMS.GROUP_EXEC : 0) + (changeSetuid ? PERMS.SETGID : 0); + } + if (changeOther) { + mask |= (changeRead ? PERMS.OTHER_READ : 0) + (changeWrite ? PERMS.OTHER_WRITE : 0) + (changeExec ? PERMS.OTHER_EXEC : 0); + } + + // Sticky bit is special - it's not tied to user, group or other. + if (changeSticky) { + mask |= PERMS.STICKY; + } + + switch (operator) { + case '+': + newPerms |= mask; + break; + + case '-': + newPerms &= ~mask; + break; + + case '=': + newPerms = type + mask; + + // According to POSIX, when using = to explicitly set the + // permissions, setuid and setgid can never be cleared. + if (common.statFollowLinks(file).isDirectory()) { + newPerms |= (PERMS.SETUID + PERMS.SETGID) & perms; + } + break; + default: + common.error('Could not recognize operator: `' + operator + '`'); + } + + if (options.verbose) { + console.log(file + ' -> ' + newPerms.toString(8)); + } + + if (perms !== newPerms) { + if (!options.verbose && options.changes) { + console.log(file + ' -> ' + newPerms.toString(8)); + } + fs.chmodSync(file, newPerms); + perms = newPerms; // for the next round of changes! + } + } else { + common.error('Invalid symbolic mode change: ' + symbolicMode); + } + }); + } else { + // they gave us a full number + newPerms = type + parseInt(mode, 8); + + // POSIX rules are that setuid and setgid can only be added using numeric + // form, but not cleared. + if (common.statFollowLinks(file).isDirectory()) { + newPerms |= (PERMS.SETUID + PERMS.SETGID) & perms; + } + + fs.chmodSync(file, newPerms); + } + }); + return ''; + } + chmod = _chmod; + return chmod; +} + +var cp; +var hasRequiredCp; + +function requireCp () { + if (hasRequiredCp) return cp; + hasRequiredCp = 1; + var fs = require$$1; + var path = require$$2; + var common = requireCommon(); + + common.register('cp', _cp, { + cmdOptions: { + 'f': '!no_force', + 'n': 'no_force', + 'u': 'update', + 'R': 'recursive', + 'r': 'recursive', + 'L': 'followsymlink', + 'P': 'noFollowsymlink', + }, + wrapOutput: false, + }); + + // Buffered file copy, synchronous + // (Using readFileSync() + writeFileSync() could easily cause a memory overflow + // with large files) + function copyFileSync(srcFile, destFile, options) { + if (!fs.existsSync(srcFile)) { + common.error('copyFileSync: no such file or directory: ' + srcFile); + } + + var isWindows = process.platform === 'win32'; + + // Check the mtimes of the files if the '-u' flag is provided + try { + if (options.update && common.statFollowLinks(srcFile).mtime < fs.statSync(destFile).mtime) { + return; + } + } catch (e) { + // If we're here, destFile probably doesn't exist, so just do a normal copy + } + + if (common.statNoFollowLinks(srcFile).isSymbolicLink() && !options.followsymlink) { + try { + common.statNoFollowLinks(destFile); + common.unlinkSync(destFile); // re-link it + } catch (e) { + // it doesn't exist, so no work needs to be done + } + + var symlinkFull = fs.readlinkSync(srcFile); + fs.symlinkSync(symlinkFull, destFile, isWindows ? 'junction' : null); + } else { + var buf = common.buffer(); + var bufLength = buf.length; + var bytesRead = bufLength; + var pos = 0; + var fdr = null; + var fdw = null; + + try { + fdr = fs.openSync(srcFile, 'r'); + } catch (e) { + /* istanbul ignore next */ + common.error('copyFileSync: could not read src file (' + srcFile + ')'); + } + + try { + fdw = fs.openSync(destFile, 'w'); + } catch (e) { + /* istanbul ignore next */ + common.error('copyFileSync: could not write to dest file (code=' + e.code + '):' + destFile); + } + + while (bytesRead === bufLength) { + bytesRead = fs.readSync(fdr, buf, 0, bufLength, pos); + fs.writeSync(fdw, buf, 0, bytesRead); + pos += bytesRead; + } + + fs.closeSync(fdr); + fs.closeSync(fdw); + + fs.chmodSync(destFile, common.statFollowLinks(srcFile).mode); + } + } + + // Recursively copies 'sourceDir' into 'destDir' + // Adapted from https://github.com/ryanmcgrath/wrench-js + // + // Copyright (c) 2010 Ryan McGrath + // Copyright (c) 2012 Artur Adib + // + // Licensed under the MIT License + // http://www.opensource.org/licenses/mit-license.php + function cpdirSyncRecursive(sourceDir, destDir, currentDepth, opts) { + if (!opts) opts = {}; + + // Ensure there is not a run away recursive copy + if (currentDepth >= common.config.maxdepth) return; + currentDepth++; + + var isWindows = process.platform === 'win32'; + + // Create the directory where all our junk is moving to; read the mode of the + // source directory and mirror it + try { + fs.mkdirSync(destDir); + } catch (e) { + // if the directory already exists, that's okay + if (e.code !== 'EEXIST') throw e; + } + + var files = fs.readdirSync(sourceDir); + + for (var i = 0; i < files.length; i++) { + var srcFile = sourceDir + '/' + files[i]; + var destFile = destDir + '/' + files[i]; + var srcFileStat = common.statNoFollowLinks(srcFile); + + var symlinkFull; + if (opts.followsymlink) { + if (cpcheckcycle(sourceDir, srcFile)) { + // Cycle link found. + console.error('Cycle link found.'); + symlinkFull = fs.readlinkSync(srcFile); + fs.symlinkSync(symlinkFull, destFile, isWindows ? 'junction' : null); + continue; + } + } + if (srcFileStat.isDirectory()) { + /* recursion this thing right on back. */ + cpdirSyncRecursive(srcFile, destFile, currentDepth, opts); + } else if (srcFileStat.isSymbolicLink() && !opts.followsymlink) { + symlinkFull = fs.readlinkSync(srcFile); + try { + common.statNoFollowLinks(destFile); + common.unlinkSync(destFile); // re-link it + } catch (e) { + // it doesn't exist, so no work needs to be done + } + fs.symlinkSync(symlinkFull, destFile, isWindows ? 'junction' : null); + } else if (srcFileStat.isSymbolicLink() && opts.followsymlink) { + srcFileStat = common.statFollowLinks(srcFile); + if (srcFileStat.isDirectory()) { + cpdirSyncRecursive(srcFile, destFile, currentDepth, opts); + } else { + copyFileSync(srcFile, destFile, opts); + } + } else { + /* At this point, we've hit a file actually worth copying... so copy it on over. */ + if (fs.existsSync(destFile) && opts.no_force) { + common.log('skipping existing file: ' + files[i]); + } else { + copyFileSync(srcFile, destFile, opts); + } + } + } // for files + + // finally change the mode for the newly created directory (otherwise, we + // couldn't add files to a read-only directory). + var checkDir = common.statFollowLinks(sourceDir); + fs.chmodSync(destDir, checkDir.mode); + } // cpdirSyncRecursive + + // Checks if cureent file was created recently + function checkRecentCreated(sources, index) { + var lookedSource = sources[index]; + return sources.slice(0, index).some(function (src) { + return path.basename(src) === path.basename(lookedSource); + }); + } + + function cpcheckcycle(sourceDir, srcFile) { + var srcFileStat = common.statNoFollowLinks(srcFile); + if (srcFileStat.isSymbolicLink()) { + // Do cycle check. For example: + // $ mkdir -p 1/2/3/4 + // $ cd 1/2/3/4 + // $ ln -s ../../3 link + // $ cd ../../../.. + // $ cp -RL 1 copy + var cyclecheck = common.statFollowLinks(srcFile); + if (cyclecheck.isDirectory()) { + var sourcerealpath = fs.realpathSync(sourceDir); + var symlinkrealpath = fs.realpathSync(srcFile); + var re = new RegExp(symlinkrealpath); + if (re.test(sourcerealpath)) { + return true; + } + } + } + return false; + } + + //@ + //@ ### cp([options,] source [, source ...], dest) + //@ ### cp([options,] source_array, dest) + //@ + //@ Available options: + //@ + //@ + `-f`: force (default behavior) + //@ + `-n`: no-clobber + //@ + `-u`: only copy if `source` is newer than `dest` + //@ + `-r`, `-R`: recursive + //@ + `-L`: follow symlinks + //@ + `-P`: don't follow symlinks + //@ + //@ Examples: + //@ + //@ ```javascript + //@ cp('file1', 'dir1'); + //@ cp('-R', 'path/to/dir/', '~/newCopy/'); + //@ cp('-Rf', '/tmp/*', '/usr/local/*', '/home/tmp'); + //@ cp('-Rf', ['/tmp/*', '/usr/local/*'], '/home/tmp'); // same as above + //@ ``` + //@ + //@ Copies files. + function _cp(options, sources, dest) { + // If we're missing -R, it actually implies -L (unless -P is explicit) + if (options.followsymlink) { + options.noFollowsymlink = false; + } + if (!options.recursive && !options.noFollowsymlink) { + options.followsymlink = true; + } + + // Get sources, dest + if (arguments.length < 3) { + common.error('missing and/or '); + } else { + sources = [].slice.call(arguments, 1, arguments.length - 1); + dest = arguments[arguments.length - 1]; + } + + var destExists = fs.existsSync(dest); + var destStat = destExists && common.statFollowLinks(dest); + + // Dest is not existing dir, but multiple sources given + if ((!destExists || !destStat.isDirectory()) && sources.length > 1) { + common.error('dest is not a directory (too many sources)'); + } + + // Dest is an existing file, but -n is given + if (destExists && destStat.isFile() && options.no_force) { + return new common.ShellString('', '', 0); + } + + sources.forEach(function (src, srcIndex) { + if (!fs.existsSync(src)) { + if (src === '') src = "''"; // if src was empty string, display empty string + common.error('no such file or directory: ' + src, { continue: true }); + return; // skip file + } + var srcStat = common.statFollowLinks(src); + if (!options.noFollowsymlink && srcStat.isDirectory()) { + if (!options.recursive) { + // Non-Recursive + common.error("omitting directory '" + src + "'", { continue: true }); + } else { + // Recursive + // 'cp /a/source dest' should create 'source' in 'dest' + var newDest = (destStat && destStat.isDirectory()) ? + path.join(dest, path.basename(src)) : + dest; + + try { + common.statFollowLinks(path.dirname(dest)); + cpdirSyncRecursive(src, newDest, 0, { no_force: options.no_force, followsymlink: options.followsymlink }); + } catch (e) { + /* istanbul ignore next */ + common.error("cannot create directory '" + dest + "': No such file or directory"); + } + } + } else { + // If here, src is a file + + // When copying to '/path/dir': + // thisDest = '/path/dir/file1' + var thisDest = dest; + if (destStat && destStat.isDirectory()) { + thisDest = path.normalize(dest + '/' + path.basename(src)); + } + + var thisDestExists = fs.existsSync(thisDest); + if (thisDestExists && checkRecentCreated(sources, srcIndex)) { + // cannot overwrite file created recently in current execution, but we want to continue copying other files + if (!options.no_force) { + common.error("will not overwrite just-created '" + thisDest + "' with '" + src + "'", { continue: true }); + } + return; + } + + if (thisDestExists && options.no_force) { + return; // skip file + } + + if (path.relative(src, thisDest) === '') { + // a file cannot be copied to itself, but we want to continue copying other files + common.error("'" + thisDest + "' and '" + src + "' are the same file", { continue: true }); + return; + } + + copyFileSync(src, thisDest, options); + } + }); // forEach(src) + + return new common.ShellString('', common.state.error, common.state.errorCode); + } + cp = _cp; + return cp; +} + +var dirs = {}; + +var hasRequiredDirs; + +function requireDirs () { + if (hasRequiredDirs) return dirs; + hasRequiredDirs = 1; + var common = requireCommon(); + var _cd = requireCd(); + var path = require$$2; + + common.register('dirs', _dirs, { + wrapOutput: false, + }); + common.register('pushd', _pushd, { + wrapOutput: false, + }); + common.register('popd', _popd, { + wrapOutput: false, + }); + + // Pushd/popd/dirs internals + var _dirStack = []; + + function _isStackIndex(index) { + return (/^[\-+]\d+$/).test(index); + } + + function _parseStackIndex(index) { + if (_isStackIndex(index)) { + if (Math.abs(index) < _dirStack.length + 1) { // +1 for pwd + return (/^-/).test(index) ? Number(index) - 1 : Number(index); + } + common.error(index + ': directory stack index out of range'); + } else { + common.error(index + ': invalid number'); + } + } + + function _actualDirStack() { + return [process.cwd()].concat(_dirStack); + } + + //@ + //@ ### pushd([options,] [dir | '-N' | '+N']) + //@ + //@ Available options: + //@ + //@ + `-n`: Suppresses the normal change of directory when adding directories to the stack, so that only the stack is manipulated. + //@ + `-q`: Supresses output to the console. + //@ + //@ Arguments: + //@ + //@ + `dir`: Sets the current working directory to the top of the stack, then executes the equivalent of `cd dir`. + //@ + `+N`: Brings the Nth directory (counting from the left of the list printed by dirs, starting with zero) to the top of the list by rotating the stack. + //@ + `-N`: Brings the Nth directory (counting from the right of the list printed by dirs, starting with zero) to the top of the list by rotating the stack. + //@ + //@ Examples: + //@ + //@ ```javascript + //@ // process.cwd() === '/usr' + //@ pushd('/etc'); // Returns /etc /usr + //@ pushd('+1'); // Returns /usr /etc + //@ ``` + //@ + //@ Save the current directory on the top of the directory stack and then `cd` to `dir`. With no arguments, `pushd` exchanges the top two directories. Returns an array of paths in the stack. + function _pushd(options, dir) { + if (_isStackIndex(options)) { + dir = options; + options = ''; + } + + options = common.parseOptions(options, { + 'n': 'no-cd', + 'q': 'quiet', + }); + + var dirs = _actualDirStack(); + + if (dir === '+0') { + return dirs; // +0 is a noop + } else if (!dir) { + if (dirs.length > 1) { + dirs = dirs.splice(1, 1).concat(dirs); + } else { + return common.error('no other directory'); + } + } else if (_isStackIndex(dir)) { + var n = _parseStackIndex(dir); + dirs = dirs.slice(n).concat(dirs.slice(0, n)); + } else { + if (options['no-cd']) { + dirs.splice(1, 0, dir); + } else { + dirs.unshift(dir); + } + } + + if (options['no-cd']) { + dirs = dirs.slice(1); + } else { + dir = path.resolve(dirs.shift()); + _cd('', dir); + } + + _dirStack = dirs; + return _dirs(options.quiet ? '-q' : ''); + } + dirs.pushd = _pushd; + + //@ + //@ + //@ ### popd([options,] ['-N' | '+N']) + //@ + //@ Available options: + //@ + //@ + `-n`: Suppress the normal directory change when removing directories from the stack, so that only the stack is manipulated. + //@ + `-q`: Supresses output to the console. + //@ + //@ Arguments: + //@ + //@ + `+N`: Removes the Nth directory (counting from the left of the list printed by dirs), starting with zero. + //@ + `-N`: Removes the Nth directory (counting from the right of the list printed by dirs), starting with zero. + //@ + //@ Examples: + //@ + //@ ```javascript + //@ echo(process.cwd()); // '/usr' + //@ pushd('/etc'); // '/etc /usr' + //@ echo(process.cwd()); // '/etc' + //@ popd(); // '/usr' + //@ echo(process.cwd()); // '/usr' + //@ ``` + //@ + //@ When no arguments are given, `popd` removes the top directory from the stack and performs a `cd` to the new top directory. The elements are numbered from 0, starting at the first directory listed with dirs (i.e., `popd` is equivalent to `popd +0`). Returns an array of paths in the stack. + function _popd(options, index) { + if (_isStackIndex(options)) { + index = options; + options = ''; + } + + options = common.parseOptions(options, { + 'n': 'no-cd', + 'q': 'quiet', + }); + + if (!_dirStack.length) { + return common.error('directory stack empty'); + } + + index = _parseStackIndex(index || '+0'); + + if (options['no-cd'] || index > 0 || _dirStack.length + index === 0) { + index = index > 0 ? index - 1 : index; + _dirStack.splice(index, 1); + } else { + var dir = path.resolve(_dirStack.shift()); + _cd('', dir); + } + + return _dirs(options.quiet ? '-q' : ''); + } + dirs.popd = _popd; + + //@ + //@ + //@ ### dirs([options | '+N' | '-N']) + //@ + //@ Available options: + //@ + //@ + `-c`: Clears the directory stack by deleting all of the elements. + //@ + `-q`: Supresses output to the console. + //@ + //@ Arguments: + //@ + //@ + `+N`: Displays the Nth directory (counting from the left of the list printed by dirs when invoked without options), starting with zero. + //@ + `-N`: Displays the Nth directory (counting from the right of the list printed by dirs when invoked without options), starting with zero. + //@ + //@ Display the list of currently remembered directories. Returns an array of paths in the stack, or a single path if `+N` or `-N` was specified. + //@ + //@ See also: `pushd`, `popd` + function _dirs(options, index) { + if (_isStackIndex(options)) { + index = options; + options = ''; + } + + options = common.parseOptions(options, { + 'c': 'clear', + 'q': 'quiet', + }); + + if (options.clear) { + _dirStack = []; + return _dirStack; + } + + var stack = _actualDirStack(); + + if (index) { + index = _parseStackIndex(index); + + if (index < 0) { + index = stack.length + index; + } + + if (!options.quiet) { + common.log(stack[index]); + } + return stack[index]; + } + + if (!options.quiet) { + common.log(stack.join(' ')); + } + + return stack; + } + dirs.dirs = _dirs; + return dirs; +} + +var echo; +var hasRequiredEcho; + +function requireEcho () { + if (hasRequiredEcho) return echo; + hasRequiredEcho = 1; + var format = require$$4$1.format; + + var common = requireCommon(); + + common.register('echo', _echo, { + allowGlobbing: false, + }); + + //@ + //@ ### echo([options,] string [, string ...]) + //@ + //@ Available options: + //@ + //@ + `-e`: interpret backslash escapes (default) + //@ + `-n`: remove trailing newline from output + //@ + //@ Examples: + //@ + //@ ```javascript + //@ echo('hello world'); + //@ var str = echo('hello world'); + //@ echo('-n', 'no newline at end'); + //@ ``` + //@ + //@ Prints `string` to stdout, and returns string with additional utility methods + //@ like `.to()`. + function _echo(opts) { + // allow strings starting with '-', see issue #20 + var messages = [].slice.call(arguments, opts ? 0 : 1); + var options = {}; + + // If the first argument starts with '-', parse it as options string. + // If parseOptions throws, it wasn't an options string. + try { + options = common.parseOptions(messages[0], { + 'e': 'escapes', + 'n': 'no_newline', + }, { + silent: true, + }); + + // Allow null to be echoed + if (messages[0]) { + messages.shift(); + } + } catch (_) { + // Clear out error if an error occurred + common.state.error = null; + } + + var output = format.apply(null, messages); + + // Add newline if -n is not passed. + if (!options.no_newline) { + output += '\n'; + } + + process.stdout.write(output); + + return output; + } + + echo = _echo; + return echo; +} + +var error_1; +var hasRequiredError; + +function requireError () { + if (hasRequiredError) return error_1; + hasRequiredError = 1; + var common = requireCommon(); + + //@ + //@ ### error() + //@ + //@ Tests if error occurred in the last command. Returns a truthy value if an + //@ error returned, or a falsy value otherwise. + //@ + //@ **Note**: do not rely on the + //@ return value to be an error message. If you need the last error message, use + //@ the `.stderr` attribute from the last command's return value instead. + function error() { + return common.state.error; + } + error_1 = error; + return error_1; +} + +var execChild = {exports: {}}; + +var hasRequiredExecChild; + +function requireExecChild () { + if (hasRequiredExecChild) return execChild.exports; + hasRequiredExecChild = 1; + (function (module) { + if (require.main !== module) { + throw new Error('This file should not be required'); + } + + var childProcess = require$$0$1; + var fs = require$$1; + + var paramFilePath = process.argv[2]; + + var serializedParams = fs.readFileSync(paramFilePath, 'utf8'); + var params = JSON.parse(serializedParams); + + var cmd = params.command; + var execOptions = params.execOptions; + var pipe = params.pipe; + var stdoutFile = params.stdoutFile; + var stderrFile = params.stderrFile; + + var c = childProcess.exec(cmd, execOptions, function (err) { + if (!err) { + process.exitCode = 0; + } else if (err.code === undefined) { + process.exitCode = 1; + } else { + process.exitCode = err.code; + } + }); + + var stdoutStream = fs.createWriteStream(stdoutFile); + var stderrStream = fs.createWriteStream(stderrFile); + + c.stdout.pipe(stdoutStream); + c.stderr.pipe(stderrStream); + c.stdout.pipe(process.stdout); + c.stderr.pipe(process.stderr); + + if (pipe) { + c.stdin.end(pipe); + } +} (execChild)); + return execChild.exports; +} + +var tempdir = {}; + +var hasRequiredTempdir; + +function requireTempdir () { + if (hasRequiredTempdir) return tempdir; + hasRequiredTempdir = 1; + var common = requireCommon(); + var os = require$$0; + var fs = require$$1; + + common.register('tempdir', _tempDir, { + allowGlobbing: false, + wrapOutput: false, + }); + + // Returns false if 'dir' is not a writeable directory, 'dir' otherwise + function writeableDir(dir) { + if (!dir || !fs.existsSync(dir)) return false; + + if (!common.statFollowLinks(dir).isDirectory()) return false; + + var testFile = dir + '/' + common.randomFileName(); + try { + fs.writeFileSync(testFile, ' '); + common.unlinkSync(testFile); + return dir; + } catch (e) { + /* istanbul ignore next */ + return false; + } + } + + // Variable to cache the tempdir value for successive lookups. + var cachedTempDir; + + //@ + //@ ### tempdir() + //@ + //@ Examples: + //@ + //@ ```javascript + //@ var tmp = tempdir(); // "/tmp" for most *nix platforms + //@ ``` + //@ + //@ Searches and returns string containing a writeable, platform-dependent temporary directory. + //@ Follows Python's [tempfile algorithm](http://docs.python.org/library/tempfile.html#tempfile.tempdir). + function _tempDir() { + if (cachedTempDir) return cachedTempDir; + + cachedTempDir = writeableDir(os.tmpdir()) || + writeableDir(process.env.TMPDIR) || + writeableDir(process.env.TEMP) || + writeableDir(process.env.TMP) || + writeableDir(process.env.Wimp$ScrapDir) || // RiscOS + writeableDir('C:\\TEMP') || // Windows + writeableDir('C:\\TMP') || // Windows + writeableDir('\\TEMP') || // Windows + writeableDir('\\TMP') || // Windows + writeableDir('/tmp') || + writeableDir('/var/tmp') || + writeableDir('/usr/tmp') || + writeableDir('.'); // last resort + + return cachedTempDir; + } + + // Indicates if the tempdir value is currently cached. This is exposed for tests + // only. The return value should only be tested for truthiness. + function isCached() { + return cachedTempDir; + } + + // Clears the cached tempDir value, if one is cached. This is exposed for tests + // only. + function clearCache() { + cachedTempDir = undefined; + } + + tempdir.tempDir = _tempDir; + tempdir.isCached = isCached; + tempdir.clearCache = clearCache; + return tempdir; +} + +var pwd; +var hasRequiredPwd; + +function requirePwd () { + if (hasRequiredPwd) return pwd; + hasRequiredPwd = 1; + var path = require$$2; + var common = requireCommon(); + + common.register('pwd', _pwd, { + allowGlobbing: false, + }); + + //@ + //@ ### pwd() + //@ + //@ Returns the current directory. + function _pwd() { + var pwd = path.resolve(process.cwd()); + return pwd; + } + pwd = _pwd; + return pwd; +} + +var exec$1; +var hasRequiredExec; + +function requireExec () { + if (hasRequiredExec) return exec$1; + hasRequiredExec = 1; + var common = requireCommon(); + var _tempDir = requireTempdir().tempDir; + var _pwd = requirePwd(); + var path = require$$2; + var fs = require$$1; + var child = require$$0$1; + + var DEFAULT_MAXBUFFER_SIZE = 20 * 1024 * 1024; + var DEFAULT_ERROR_CODE = 1; + + common.register('exec', _exec, { + unix: false, + canReceivePipe: true, + wrapOutput: false, + }); + + // We use this function to run `exec` synchronously while also providing realtime + // output. + function execSync(cmd, opts, pipe) { + if (!common.config.execPath) { + common.error('Unable to find a path to the node binary. Please manually set config.execPath'); + } + + var tempDir = _tempDir(); + var paramsFile = path.resolve(tempDir + '/' + common.randomFileName()); + var stderrFile = path.resolve(tempDir + '/' + common.randomFileName()); + var stdoutFile = path.resolve(tempDir + '/' + common.randomFileName()); + + opts = common.extend({ + silent: common.config.silent, + cwd: _pwd().toString(), + env: process.env, + maxBuffer: DEFAULT_MAXBUFFER_SIZE, + encoding: 'utf8', + }, opts); + + if (fs.existsSync(paramsFile)) common.unlinkSync(paramsFile); + if (fs.existsSync(stderrFile)) common.unlinkSync(stderrFile); + if (fs.existsSync(stdoutFile)) common.unlinkSync(stdoutFile); + + opts.cwd = path.resolve(opts.cwd); + + var paramsToSerialize = { + command: cmd, + execOptions: opts, + pipe: pipe, + stdoutFile: stdoutFile, + stderrFile: stderrFile, + }; + + // Create the files and ensure these are locked down (for read and write) to + // the current user. The main concerns here are: + // + // * If we execute a command which prints sensitive output, then + // stdoutFile/stderrFile must not be readable by other users. + // * paramsFile must not be readable by other users, or else they can read it + // to figure out the path for stdoutFile/stderrFile and create these first + // (locked down to their own access), which will crash exec() when it tries + // to write to the files. + function writeFileLockedDown(filePath, data) { + fs.writeFileSync(filePath, data, { + encoding: 'utf8', + mode: parseInt('600', 8), + }); + } + writeFileLockedDown(stdoutFile, ''); + writeFileLockedDown(stderrFile, ''); + writeFileLockedDown(paramsFile, JSON.stringify(paramsToSerialize)); + + var execArgs = [ + path.join(__dirname, 'exec-child.js'), + paramsFile, + ]; + + /* istanbul ignore else */ + if (opts.silent) { + opts.stdio = 'ignore'; + } else { + opts.stdio = [0, 1, 2]; + } + + var code = 0; + + // Welcome to the future + try { + // Bad things if we pass in a `shell` option to child_process.execFileSync, + // so we need to explicitly remove it here. + delete opts.shell; + + child.execFileSync(common.config.execPath, execArgs, opts); + } catch (e) { + // Commands with non-zero exit code raise an exception. + code = e.status || DEFAULT_ERROR_CODE; + } + + // fs.readFileSync uses buffer encoding by default, so call + // it without the encoding option if the encoding is 'buffer'. + // Also, if the exec timeout is too short for node to start up, + // the files will not be created, so these calls will throw. + var stdout = ''; + var stderr = ''; + if (opts.encoding === 'buffer') { + stdout = fs.readFileSync(stdoutFile); + stderr = fs.readFileSync(stderrFile); + } else { + stdout = fs.readFileSync(stdoutFile, opts.encoding); + stderr = fs.readFileSync(stderrFile, opts.encoding); + } + + // No biggie if we can't erase the files now -- they're in a temp dir anyway + // and we locked down permissions (see the note above). + try { common.unlinkSync(paramsFile); } catch (e) {} + try { common.unlinkSync(stderrFile); } catch (e) {} + try { common.unlinkSync(stdoutFile); } catch (e) {} + + if (code !== 0) { + // Note: `silent` should be unconditionally true to avoid double-printing + // the command's stderr, and to avoid printing any stderr when the user has + // set `shell.config.silent`. + common.error(stderr, code, { continue: true, silent: true }); + } + var obj = common.ShellString(stdout, stderr, code); + return obj; + } // execSync() + + // Wrapper around exec() to enable echoing output to console in real time + function execAsync(cmd, opts, pipe, callback) { + opts = common.extend({ + silent: common.config.silent, + cwd: _pwd().toString(), + env: process.env, + maxBuffer: DEFAULT_MAXBUFFER_SIZE, + encoding: 'utf8', + }, opts); + + var c = child.exec(cmd, opts, function (err, stdout, stderr) { + if (callback) { + if (!err) { + callback(0, stdout, stderr); + } else if (err.code === undefined) { + // See issue #536 + /* istanbul ignore next */ + callback(1, stdout, stderr); + } else { + callback(err.code, stdout, stderr); + } + } + }); + + if (pipe) c.stdin.end(pipe); + + if (!opts.silent) { + c.stdout.pipe(process.stdout); + c.stderr.pipe(process.stderr); + } + + return c; + } + + //@ + //@ ### exec(command [, options] [, callback]) + //@ + //@ Available options: + //@ + //@ + `async`: Asynchronous execution. If a callback is provided, it will be set to + //@ `true`, regardless of the passed value (default: `false`). + //@ + `silent`: Do not echo program output to console (default: `false`). + //@ + `encoding`: Character encoding to use. Affects the values returned to stdout and stderr, and + //@ what is written to stdout and stderr when not in silent mode (default: `'utf8'`). + //@ + and any option available to Node.js's + //@ [`child_process.exec()`](https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback) + //@ + //@ Examples: + //@ + //@ ```javascript + //@ var version = exec('node --version', {silent:true}).stdout; + //@ + //@ var child = exec('some_long_running_process', {async:true}); + //@ child.stdout.on('data', function(data) { + //@ /* ... do something with data ... */ + //@ }); + //@ + //@ exec('some_long_running_process', function(code, stdout, stderr) { + //@ console.log('Exit code:', code); + //@ console.log('Program output:', stdout); + //@ console.log('Program stderr:', stderr); + //@ }); + //@ ``` + //@ + //@ Executes the given `command` _synchronously_, unless otherwise specified. When in synchronous + //@ mode, this returns a `ShellString` (compatible with ShellJS v0.6.x, which returns an object + //@ of the form `{ code:..., stdout:... , stderr:... }`). Otherwise, this returns the child process + //@ object, and the `callback` receives the arguments `(code, stdout, stderr)`. + //@ + //@ Not seeing the behavior you want? `exec()` runs everything through `sh` + //@ by default (or `cmd.exe` on Windows), which differs from `bash`. If you + //@ need bash-specific behavior, try out the `{shell: 'path/to/bash'}` option. + function _exec(command, options, callback) { + options = options || {}; + if (!command) common.error('must specify command'); + + var pipe = common.readFromPipe(); + + // Callback is defined instead of options. + if (typeof options === 'function') { + callback = options; + options = { async: true }; + } + + // Callback is defined with options. + if (typeof options === 'object' && typeof callback === 'function') { + options.async = true; + } + + options = common.extend({ + silent: common.config.silent, + async: false, + }, options); + + if (options.async) { + return execAsync(command, options, pipe, callback); + } else { + return execSync(command, options, pipe); + } + } + exec$1 = _exec; + return exec$1; +} + +var ls; +var hasRequiredLs; + +function requireLs () { + if (hasRequiredLs) return ls; + hasRequiredLs = 1; + var path = require$$2; + var fs = require$$1; + var common = requireCommon(); + var glob = requireGlob(); + + var globPatternRecursive = path.sep + '**'; + + common.register('ls', _ls, { + cmdOptions: { + 'R': 'recursive', + 'A': 'all', + 'L': 'link', + 'a': 'all_deprecated', + 'd': 'directory', + 'l': 'long', + }, + }); + + //@ + //@ ### ls([options,] [path, ...]) + //@ ### ls([options,] path_array) + //@ + //@ Available options: + //@ + //@ + `-R`: recursive + //@ + `-A`: all files (include files beginning with `.`, except for `.` and `..`) + //@ + `-L`: follow symlinks + //@ + `-d`: list directories themselves, not their contents + //@ + `-l`: list objects representing each file, each with fields containing `ls + //@ -l` output fields. See + //@ [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) + //@ for more info + //@ + //@ Examples: + //@ + //@ ```javascript + //@ ls('projs/*.js'); + //@ ls('-R', '/users/me', '/tmp'); + //@ ls('-R', ['/users/me', '/tmp']); // same as above + //@ ls('-l', 'file.txt'); // { name: 'file.txt', mode: 33188, nlink: 1, ...} + //@ ``` + //@ + //@ Returns array of files in the given `path`, or files in + //@ the current directory if no `path` is provided. + function _ls(options, paths) { + if (options.all_deprecated) { + // We won't support the -a option as it's hard to image why it's useful + // (it includes '.' and '..' in addition to '.*' files) + // For backwards compatibility we'll dump a deprecated message and proceed as before + common.log('ls: Option -a is deprecated. Use -A instead'); + options.all = true; + } + + if (!paths) { + paths = ['.']; + } else { + paths = [].slice.call(arguments, 1); + } + + var list = []; + + function pushFile(abs, relName, stat) { + if (process.platform === 'win32') { + relName = relName.replace(/\\/g, '/'); + } + if (options.long) { + stat = stat || (options.link ? common.statFollowLinks(abs) : common.statNoFollowLinks(abs)); + list.push(addLsAttributes(relName, stat)); + } else { + // list.push(path.relative(rel || '.', file)); + list.push(relName); + } + } + + paths.forEach(function (p) { + var stat; + + try { + stat = options.link ? common.statFollowLinks(p) : common.statNoFollowLinks(p); + // follow links to directories by default + if (stat.isSymbolicLink()) { + /* istanbul ignore next */ + // workaround for https://github.com/shelljs/shelljs/issues/795 + // codecov seems to have a bug that miscalculate this block as uncovered. + // but according to nyc report this block does get covered. + try { + var _stat = common.statFollowLinks(p); + if (_stat.isDirectory()) { + stat = _stat; + } + } catch (_) {} // bad symlink, treat it like a file + } + } catch (e) { + common.error('no such file or directory: ' + p, 2, { continue: true }); + return; + } + + // If the stat succeeded + if (stat.isDirectory() && !options.directory) { + if (options.recursive) { + // use glob, because it's simple + glob.sync(p + globPatternRecursive, { dot: options.all, follow: options.link }) + .forEach(function (item) { + // Glob pattern returns the directory itself and needs to be filtered out. + if (path.relative(p, item)) { + pushFile(item, path.relative(p, item)); + } + }); + } else if (options.all) { + // use fs.readdirSync, because it's fast + fs.readdirSync(p).forEach(function (item) { + pushFile(path.join(p, item), item); + }); + } else { + // use fs.readdirSync and then filter out secret files + fs.readdirSync(p).forEach(function (item) { + if (item[0] !== '.') { + pushFile(path.join(p, item), item); + } + }); + } + } else { + pushFile(p, p, stat); + } + }); + + // Add methods, to make this more compatible with ShellStrings + return list; + } + + function addLsAttributes(pathName, stats) { + // Note: this object will contain more information than .toString() returns + stats.name = pathName; + stats.toString = function () { + // Return a string resembling unix's `ls -l` format + return [this.mode, this.nlink, this.uid, this.gid, this.size, this.mtime, this.name].join(' '); + }; + return stats; + } + + ls = _ls; + return ls; +} + +var find; +var hasRequiredFind; + +function requireFind () { + if (hasRequiredFind) return find; + hasRequiredFind = 1; + var path = require$$2; + var common = requireCommon(); + var _ls = requireLs(); + + common.register('find', _find, {}); + + //@ + //@ ### find(path [, path ...]) + //@ ### find(path_array) + //@ + //@ Examples: + //@ + //@ ```javascript + //@ find('src', 'lib'); + //@ find(['src', 'lib']); // same as above + //@ find('.').filter(function(file) { return file.match(/\.js$/); }); + //@ ``` + //@ + //@ Returns array of all files (however deep) in the given paths. + //@ + //@ The main difference from `ls('-R', path)` is that the resulting file names + //@ include the base directories (e.g., `lib/resources/file1` instead of just `file1`). + function _find(options, paths) { + if (!paths) { + common.error('no path specified'); + } else if (typeof paths === 'string') { + paths = [].slice.call(arguments, 1); + } + + var list = []; + + function pushFile(file) { + if (process.platform === 'win32') { + file = file.replace(/\\/g, '/'); + } + list.push(file); + } + + // why not simply do `ls('-R', paths)`? because the output wouldn't give the base dirs + // to get the base dir in the output, we need instead `ls('-R', 'dir/*')` for every directory + + paths.forEach(function (file) { + var stat; + try { + stat = common.statFollowLinks(file); + } catch (e) { + common.error('no such file or directory: ' + file); + } + + pushFile(file); + + if (stat.isDirectory()) { + _ls({ recursive: true, all: true }, file).forEach(function (subfile) { + pushFile(path.join(file, subfile)); + }); + } + }); + + return list; + } + find = _find; + return find; +} + +var grep; +var hasRequiredGrep; + +function requireGrep () { + if (hasRequiredGrep) return grep; + hasRequiredGrep = 1; + var common = requireCommon(); + var fs = require$$1; + + common.register('grep', _grep, { + globStart: 2, // don't glob-expand the regex + canReceivePipe: true, + cmdOptions: { + 'v': 'inverse', + 'l': 'nameOnly', + 'i': 'ignoreCase', + }, + }); + + //@ + //@ ### grep([options,] regex_filter, file [, file ...]) + //@ ### grep([options,] regex_filter, file_array) + //@ + //@ Available options: + //@ + //@ + `-v`: Invert `regex_filter` (only print non-matching lines). + //@ + `-l`: Print only filenames of matching files. + //@ + `-i`: Ignore case. + //@ + //@ Examples: + //@ + //@ ```javascript + //@ grep('-v', 'GLOBAL_VARIABLE', '*.js'); + //@ grep('GLOBAL_VARIABLE', '*.js'); + //@ ``` + //@ + //@ Reads input string from given files and returns a string containing all lines of the + //@ file that match the given `regex_filter`. + function _grep(options, regex, files) { + // Check if this is coming from a pipe + var pipe = common.readFromPipe(); + + if (!files && !pipe) common.error('no paths given', 2); + + files = [].slice.call(arguments, 2); + + if (pipe) { + files.unshift('-'); + } + + var grep = []; + if (options.ignoreCase) { + regex = new RegExp(regex, 'i'); + } + files.forEach(function (file) { + if (!fs.existsSync(file) && file !== '-') { + common.error('no such file or directory: ' + file, 2, { continue: true }); + return; + } + + var contents = file === '-' ? pipe : fs.readFileSync(file, 'utf8'); + if (options.nameOnly) { + if (contents.match(regex)) { + grep.push(file); + } + } else { + var lines = contents.split('\n'); + lines.forEach(function (line) { + var matched = line.match(regex); + if ((options.inverse && !matched) || (!options.inverse && matched)) { + grep.push(line); + } + }); + } + }); + + return grep.join('\n') + '\n'; + } + grep = _grep; + return grep; +} + +var head; +var hasRequiredHead; + +function requireHead () { + if (hasRequiredHead) return head; + hasRequiredHead = 1; + var common = requireCommon(); + var fs = require$$1; + + common.register('head', _head, { + canReceivePipe: true, + cmdOptions: { + 'n': 'numLines', + }, + }); + + // Reads |numLines| lines or the entire file, whichever is less. + function readSomeLines(file, numLines) { + var buf = common.buffer(); + var bufLength = buf.length; + var bytesRead = bufLength; + var pos = 0; + + var fdr = fs.openSync(file, 'r'); + var numLinesRead = 0; + var ret = ''; + while (bytesRead === bufLength && numLinesRead < numLines) { + bytesRead = fs.readSync(fdr, buf, 0, bufLength, pos); + var bufStr = buf.toString('utf8', 0, bytesRead); + numLinesRead += bufStr.split('\n').length - 1; + ret += bufStr; + pos += bytesRead; + } + + fs.closeSync(fdr); + return ret; + } + + //@ + //@ ### head([{'-n': \},] file [, file ...]) + //@ ### head([{'-n': \},] file_array) + //@ + //@ Available options: + //@ + //@ + `-n `: Show the first `` lines of the files + //@ + //@ Examples: + //@ + //@ ```javascript + //@ var str = head({'-n': 1}, 'file*.txt'); + //@ var str = head('file1', 'file2'); + //@ var str = head(['file1', 'file2']); // same as above + //@ ``` + //@ + //@ Read the start of a file. + function _head(options, files) { + var head = []; + var pipe = common.readFromPipe(); + + if (!files && !pipe) common.error('no paths given'); + + var idx = 1; + if (options.numLines === true) { + idx = 2; + options.numLines = Number(arguments[1]); + } else if (options.numLines === false) { + options.numLines = 10; + } + files = [].slice.call(arguments, idx); + + if (pipe) { + files.unshift('-'); + } + + var shouldAppendNewline = false; + files.forEach(function (file) { + if (file !== '-') { + if (!fs.existsSync(file)) { + common.error('no such file or directory: ' + file, { continue: true }); + return; + } else if (common.statFollowLinks(file).isDirectory()) { + common.error("error reading '" + file + "': Is a directory", { + continue: true, + }); + return; + } + } + + var contents; + if (file === '-') { + contents = pipe; + } else if (options.numLines < 0) { + contents = fs.readFileSync(file, 'utf8'); + } else { + contents = readSomeLines(file, options.numLines); + } + + var lines = contents.split('\n'); + var hasTrailingNewline = (lines[lines.length - 1] === ''); + if (hasTrailingNewline) { + lines.pop(); + } + shouldAppendNewline = (hasTrailingNewline || options.numLines < lines.length); + + head = head.concat(lines.slice(0, options.numLines)); + }); + + if (shouldAppendNewline) { + head.push(''); // to add a trailing newline once we join + } + return head.join('\n'); + } + head = _head; + return head; +} + +var ln; +var hasRequiredLn; + +function requireLn () { + if (hasRequiredLn) return ln; + hasRequiredLn = 1; + var fs = require$$1; + var path = require$$2; + var common = requireCommon(); + + common.register('ln', _ln, { + cmdOptions: { + 's': 'symlink', + 'f': 'force', + }, + }); + + //@ + //@ ### ln([options,] source, dest) + //@ + //@ Available options: + //@ + //@ + `-s`: symlink + //@ + `-f`: force + //@ + //@ Examples: + //@ + //@ ```javascript + //@ ln('file', 'newlink'); + //@ ln('-sf', 'file', 'existing'); + //@ ``` + //@ + //@ Links `source` to `dest`. Use `-f` to force the link, should `dest` already exist. + function _ln(options, source, dest) { + if (!source || !dest) { + common.error('Missing and/or '); + } + + source = String(source); + var sourcePath = path.normalize(source).replace(RegExp(path.sep + '$'), ''); + var isAbsolute = (path.resolve(source) === sourcePath); + dest = path.resolve(process.cwd(), String(dest)); + + if (fs.existsSync(dest)) { + if (!options.force) { + common.error('Destination file exists', { continue: true }); + } + + fs.unlinkSync(dest); + } + + if (options.symlink) { + var isWindows = process.platform === 'win32'; + var linkType = isWindows ? 'file' : null; + var resolvedSourcePath = isAbsolute ? sourcePath : path.resolve(process.cwd(), path.dirname(dest), source); + if (!fs.existsSync(resolvedSourcePath)) { + common.error('Source file does not exist', { continue: true }); + } else if (isWindows && common.statFollowLinks(resolvedSourcePath).isDirectory()) { + linkType = 'junction'; + } + + try { + fs.symlinkSync(linkType === 'junction' ? resolvedSourcePath : source, dest, linkType); + } catch (err) { + common.error(err.message); + } + } else { + if (!fs.existsSync(source)) { + common.error('Source file does not exist', { continue: true }); + } + try { + fs.linkSync(source, dest); + } catch (err) { + common.error(err.message); + } + } + return ''; + } + ln = _ln; + return ln; +} + +var mkdir; +var hasRequiredMkdir; + +function requireMkdir () { + if (hasRequiredMkdir) return mkdir; + hasRequiredMkdir = 1; + var common = requireCommon(); + var fs = require$$1; + var path = require$$2; + + common.register('mkdir', _mkdir, { + cmdOptions: { + 'p': 'fullpath', + }, + }); + + // Recursively creates `dir` + function mkdirSyncRecursive(dir) { + var baseDir = path.dirname(dir); + + // Prevents some potential problems arising from malformed UNCs or + // insufficient permissions. + /* istanbul ignore next */ + if (baseDir === dir) { + common.error('dirname() failed: [' + dir + ']'); + } + + // Base dir exists, no recursion necessary + if (fs.existsSync(baseDir)) { + fs.mkdirSync(dir, parseInt('0777', 8)); + return; + } + + // Base dir does not exist, go recursive + mkdirSyncRecursive(baseDir); + + // Base dir created, can create dir + fs.mkdirSync(dir, parseInt('0777', 8)); + } + + //@ + //@ ### mkdir([options,] dir [, dir ...]) + //@ ### mkdir([options,] dir_array) + //@ + //@ Available options: + //@ + //@ + `-p`: full path (and create intermediate directories, if necessary) + //@ + //@ Examples: + //@ + //@ ```javascript + //@ mkdir('-p', '/tmp/a/b/c/d', '/tmp/e/f/g'); + //@ mkdir('-p', ['/tmp/a/b/c/d', '/tmp/e/f/g']); // same as above + //@ ``` + //@ + //@ Creates directories. + function _mkdir(options, dirs) { + if (!dirs) common.error('no paths given'); + + if (typeof dirs === 'string') { + dirs = [].slice.call(arguments, 1); + } + // if it's array leave it as it is + + dirs.forEach(function (dir) { + try { + var stat = common.statNoFollowLinks(dir); + if (!options.fullpath) { + common.error('path already exists: ' + dir, { continue: true }); + } else if (stat.isFile()) { + common.error('cannot create directory ' + dir + ': File exists', { continue: true }); + } + return; // skip dir + } catch (e) { + // do nothing + } + + // Base dir does not exist, and no -p option given + var baseDir = path.dirname(dir); + if (!fs.existsSync(baseDir) && !options.fullpath) { + common.error('no such file or directory: ' + baseDir, { continue: true }); + return; // skip dir + } + + try { + if (options.fullpath) { + mkdirSyncRecursive(path.resolve(dir)); + } else { + fs.mkdirSync(dir, parseInt('0777', 8)); + } + } catch (e) { + var reason; + if (e.code === 'EACCES') { + reason = 'Permission denied'; + } else if (e.code === 'ENOTDIR' || e.code === 'ENOENT') { + reason = 'Not a directory'; + } else { + /* istanbul ignore next */ + throw e; + } + common.error('cannot create directory ' + dir + ': ' + reason, { continue: true }); + } + }); + return ''; + } // mkdir + mkdir = _mkdir; + return mkdir; +} + +var rm; +var hasRequiredRm; + +function requireRm () { + if (hasRequiredRm) return rm; + hasRequiredRm = 1; + var common = requireCommon(); + var fs = require$$1; + + common.register('rm', _rm, { + cmdOptions: { + 'f': 'force', + 'r': 'recursive', + 'R': 'recursive', + }, + }); + + // Recursively removes 'dir' + // Adapted from https://github.com/ryanmcgrath/wrench-js + // + // Copyright (c) 2010 Ryan McGrath + // Copyright (c) 2012 Artur Adib + // + // Licensed under the MIT License + // http://www.opensource.org/licenses/mit-license.php + function rmdirSyncRecursive(dir, force, fromSymlink) { + var files; + + files = fs.readdirSync(dir); + + // Loop through and delete everything in the sub-tree after checking it + for (var i = 0; i < files.length; i++) { + var file = dir + '/' + files[i]; + var currFile = common.statNoFollowLinks(file); + + if (currFile.isDirectory()) { // Recursive function back to the beginning + rmdirSyncRecursive(file, force); + } else { // Assume it's a file - perhaps a try/catch belongs here? + if (force || isWriteable(file)) { + try { + common.unlinkSync(file); + } catch (e) { + /* istanbul ignore next */ + common.error('could not remove file (code ' + e.code + '): ' + file, { + continue: true, + }); + } + } + } + } + + // if was directory was referenced through a symbolic link, + // the contents should be removed, but not the directory itself + if (fromSymlink) return; + + // Now that we know everything in the sub-tree has been deleted, we can delete the main directory. + // Huzzah for the shopkeep. + + var result; + try { + // Retry on windows, sometimes it takes a little time before all the files in the directory are gone + var start = Date.now(); + + // TODO: replace this with a finite loop + for (;;) { + try { + result = fs.rmdirSync(dir); + if (fs.existsSync(dir)) throw { code: 'EAGAIN' }; + break; + } catch (er) { + /* istanbul ignore next */ + // In addition to error codes, also check if the directory still exists and loop again if true + if (process.platform === 'win32' && (er.code === 'ENOTEMPTY' || er.code === 'EBUSY' || er.code === 'EPERM' || er.code === 'EAGAIN')) { + if (Date.now() - start > 1000) throw er; + } else if (er.code === 'ENOENT') { + // Directory did not exist, deletion was successful + break; + } else { + throw er; + } + } + } + } catch (e) { + common.error('could not remove directory (code ' + e.code + '): ' + dir, { continue: true }); + } + + return result; + } // rmdirSyncRecursive + + // Hack to determine if file has write permissions for current user + // Avoids having to check user, group, etc, but it's probably slow + function isWriteable(file) { + var writePermission = true; + try { + var __fd = fs.openSync(file, 'a'); + fs.closeSync(__fd); + } catch (e) { + writePermission = false; + } + + return writePermission; + } + + function handleFile(file, options) { + if (options.force || isWriteable(file)) { + // -f was passed, or file is writable, so it can be removed + common.unlinkSync(file); + } else { + common.error('permission denied: ' + file, { continue: true }); + } + } + + function handleDirectory(file, options) { + if (options.recursive) { + // -r was passed, so directory can be removed + rmdirSyncRecursive(file, options.force); + } else { + common.error('path is a directory', { continue: true }); + } + } + + function handleSymbolicLink(file, options) { + var stats; + try { + stats = common.statFollowLinks(file); + } catch (e) { + // symlink is broken, so remove the symlink itself + common.unlinkSync(file); + return; + } + + if (stats.isFile()) { + common.unlinkSync(file); + } else if (stats.isDirectory()) { + if (file[file.length - 1] === '/') { + // trailing separator, so remove the contents, not the link + if (options.recursive) { + // -r was passed, so directory can be removed + var fromSymlink = true; + rmdirSyncRecursive(file, options.force, fromSymlink); + } else { + common.error('path is a directory', { continue: true }); + } + } else { + // no trailing separator, so remove the link + common.unlinkSync(file); + } + } + } + + function handleFIFO(file) { + common.unlinkSync(file); + } + + //@ + //@ ### rm([options,] file [, file ...]) + //@ ### rm([options,] file_array) + //@ + //@ Available options: + //@ + //@ + `-f`: force + //@ + `-r, -R`: recursive + //@ + //@ Examples: + //@ + //@ ```javascript + //@ rm('-rf', '/tmp/*'); + //@ rm('some_file.txt', 'another_file.txt'); + //@ rm(['some_file.txt', 'another_file.txt']); // same as above + //@ ``` + //@ + //@ Removes files. + function _rm(options, files) { + if (!files) common.error('no paths given'); + + // Convert to array + files = [].slice.call(arguments, 1); + + files.forEach(function (file) { + var lstats; + try { + var filepath = (file[file.length - 1] === '/') + ? file.slice(0, -1) // remove the '/' so lstatSync can detect symlinks + : file; + lstats = common.statNoFollowLinks(filepath); // test for existence + } catch (e) { + // Path does not exist, no force flag given + if (!options.force) { + common.error('no such file or directory: ' + file, { continue: true }); + } + return; // skip file + } + + // If here, path exists + if (lstats.isFile()) { + handleFile(file, options); + } else if (lstats.isDirectory()) { + handleDirectory(file, options); + } else if (lstats.isSymbolicLink()) { + handleSymbolicLink(file, options); + } else if (lstats.isFIFO()) { + handleFIFO(file); + } + }); // forEach(file) + return ''; + } // rm + rm = _rm; + return rm; +} + +var mv; +var hasRequiredMv; + +function requireMv () { + if (hasRequiredMv) return mv; + hasRequiredMv = 1; + var fs = require$$1; + var path = require$$2; + var common = requireCommon(); + var cp = requireCp(); + var rm = requireRm(); + + common.register('mv', _mv, { + cmdOptions: { + 'f': '!no_force', + 'n': 'no_force', + }, + }); + + // Checks if cureent file was created recently + function checkRecentCreated(sources, index) { + var lookedSource = sources[index]; + return sources.slice(0, index).some(function (src) { + return path.basename(src) === path.basename(lookedSource); + }); + } + + //@ + //@ ### mv([options ,] source [, source ...], dest') + //@ ### mv([options ,] source_array, dest') + //@ + //@ Available options: + //@ + //@ + `-f`: force (default behavior) + //@ + `-n`: no-clobber + //@ + //@ Examples: + //@ + //@ ```javascript + //@ mv('-n', 'file', 'dir/'); + //@ mv('file1', 'file2', 'dir/'); + //@ mv(['file1', 'file2'], 'dir/'); // same as above + //@ ``` + //@ + //@ Moves `source` file(s) to `dest`. + function _mv(options, sources, dest) { + // Get sources, dest + if (arguments.length < 3) { + common.error('missing and/or '); + } else if (arguments.length > 3) { + sources = [].slice.call(arguments, 1, arguments.length - 1); + dest = arguments[arguments.length - 1]; + } else if (typeof sources === 'string') { + sources = [sources]; + } else { + // TODO(nate): figure out if we actually need this line + common.error('invalid arguments'); + } + + var exists = fs.existsSync(dest); + var stats = exists && common.statFollowLinks(dest); + + // Dest is not existing dir, but multiple sources given + if ((!exists || !stats.isDirectory()) && sources.length > 1) { + common.error('dest is not a directory (too many sources)'); + } + + // Dest is an existing file, but no -f given + if (exists && stats.isFile() && options.no_force) { + common.error('dest file already exists: ' + dest); + } + + sources.forEach(function (src, srcIndex) { + if (!fs.existsSync(src)) { + common.error('no such file or directory: ' + src, { continue: true }); + return; // skip file + } + + // If here, src exists + + // When copying to '/path/dir': + // thisDest = '/path/dir/file1' + var thisDest = dest; + if (fs.existsSync(dest) && common.statFollowLinks(dest).isDirectory()) { + thisDest = path.normalize(dest + '/' + path.basename(src)); + } + + var thisDestExists = fs.existsSync(thisDest); + + if (thisDestExists && checkRecentCreated(sources, srcIndex)) { + // cannot overwrite file created recently in current execution, but we want to continue copying other files + if (!options.no_force) { + common.error("will not overwrite just-created '" + thisDest + "' with '" + src + "'", { continue: true }); + } + return; + } + + if (fs.existsSync(thisDest) && options.no_force) { + common.error('dest file already exists: ' + thisDest, { continue: true }); + return; // skip file + } + + if (path.resolve(src) === path.dirname(path.resolve(thisDest))) { + common.error('cannot move to self: ' + src, { continue: true }); + return; // skip file + } + + try { + fs.renameSync(src, thisDest); + } catch (e) { + /* istanbul ignore next */ + if (e.code === 'EXDEV') { + // If we're trying to `mv` to an external partition, we'll actually need + // to perform a copy and then clean up the original file. If either the + // copy or the rm fails with an exception, we should allow this + // exception to pass up to the top level. + cp('-r', src, thisDest); + rm('-rf', src); + } + } + }); // forEach(src) + return ''; + } // mv + mv = _mv; + return mv; +} + +var popd = {}; + +var hasRequiredPopd; + +function requirePopd () { + if (hasRequiredPopd) return popd; + hasRequiredPopd = 1; + // see dirs.js + return popd; +} + +var pushd = {}; + +var hasRequiredPushd; + +function requirePushd () { + if (hasRequiredPushd) return pushd; + hasRequiredPushd = 1; + // see dirs.js + return pushd; +} + +var sed; +var hasRequiredSed; + +function requireSed () { + if (hasRequiredSed) return sed; + hasRequiredSed = 1; + var common = requireCommon(); + var fs = require$$1; + + common.register('sed', _sed, { + globStart: 3, // don't glob-expand regexes + canReceivePipe: true, + cmdOptions: { + 'i': 'inplace', + }, + }); + + //@ + //@ ### sed([options,] search_regex, replacement, file [, file ...]) + //@ ### sed([options,] search_regex, replacement, file_array) + //@ + //@ Available options: + //@ + //@ + `-i`: Replace contents of `file` in-place. _Note that no backups will be created!_ + //@ + //@ Examples: + //@ + //@ ```javascript + //@ sed('-i', 'PROGRAM_VERSION', 'v0.1.3', 'source.js'); + //@ sed(/.*DELETE_THIS_LINE.*\n/, '', 'source.js'); + //@ ``` + //@ + //@ Reads an input string from `file`s, and performs a JavaScript `replace()` on the input + //@ using the given `search_regex` and `replacement` string or function. Returns the new string after replacement. + //@ + //@ Note: + //@ + //@ Like unix `sed`, ShellJS `sed` supports capture groups. Capture groups are specified + //@ using the `$n` syntax: + //@ + //@ ```javascript + //@ sed(/(\w+)\s(\w+)/, '$2, $1', 'file.txt'); + //@ ``` + function _sed(options, regex, replacement, files) { + // Check if this is coming from a pipe + var pipe = common.readFromPipe(); + + if (typeof replacement !== 'string' && typeof replacement !== 'function') { + if (typeof replacement === 'number') { + replacement = replacement.toString(); // fallback + } else { + common.error('invalid replacement string'); + } + } + + // Convert all search strings to RegExp + if (typeof regex === 'string') { + regex = RegExp(regex); + } + + if (!files && !pipe) { + common.error('no files given'); + } + + files = [].slice.call(arguments, 3); + + if (pipe) { + files.unshift('-'); + } + + var sed = []; + files.forEach(function (file) { + if (!fs.existsSync(file) && file !== '-') { + common.error('no such file or directory: ' + file, 2, { continue: true }); + return; + } + + var contents = file === '-' ? pipe : fs.readFileSync(file, 'utf8'); + var lines = contents.split('\n'); + var result = lines.map(function (line) { + return line.replace(regex, replacement); + }).join('\n'); + + sed.push(result); + + if (options.inplace) { + fs.writeFileSync(file, result, 'utf8'); + } + }); + + return sed.join('\n'); + } + sed = _sed; + return sed; +} + +var set; +var hasRequiredSet; + +function requireSet () { + if (hasRequiredSet) return set; + hasRequiredSet = 1; + var common = requireCommon(); + + common.register('set', _set, { + allowGlobbing: false, + wrapOutput: false, + }); + + //@ + //@ ### set(options) + //@ + //@ Available options: + //@ + //@ + `+/-e`: exit upon error (`config.fatal`) + //@ + `+/-v`: verbose: show all commands (`config.verbose`) + //@ + `+/-f`: disable filename expansion (globbing) + //@ + //@ Examples: + //@ + //@ ```javascript + //@ set('-e'); // exit upon first error + //@ set('+e'); // this undoes a "set('-e')" + //@ ``` + //@ + //@ Sets global configuration variables. + function _set(options) { + if (!options) { + var args = [].slice.call(arguments, 0); + if (args.length < 2) common.error('must provide an argument'); + options = args[1]; + } + var negate = (options[0] === '+'); + if (negate) { + options = '-' + options.slice(1); // parseOptions needs a '-' prefix + } + options = common.parseOptions(options, { + 'e': 'fatal', + 'v': 'verbose', + 'f': 'noglob', + }); + + if (negate) { + Object.keys(options).forEach(function (key) { + options[key] = !options[key]; + }); + } + + Object.keys(options).forEach(function (key) { + // Only change the global config if `negate` is false and the option is true + // or if `negate` is true and the option is false (aka negate !== option) + if (negate !== options[key]) { + common.config[key] = options[key]; + } + }); + return; + } + set = _set; + return set; +} + +var sort; +var hasRequiredSort; + +function requireSort () { + if (hasRequiredSort) return sort; + hasRequiredSort = 1; + var common = requireCommon(); + var fs = require$$1; + + common.register('sort', _sort, { + canReceivePipe: true, + cmdOptions: { + 'r': 'reverse', + 'n': 'numerical', + }, + }); + + // parse out the number prefix of a line + function parseNumber(str) { + var match = str.match(/^\s*(\d*)\s*(.*)$/); + return { num: Number(match[1]), value: match[2] }; + } + + // compare two strings case-insensitively, but examine case for strings that are + // case-insensitive equivalent + function unixCmp(a, b) { + var aLower = a.toLowerCase(); + var bLower = b.toLowerCase(); + return (aLower === bLower ? + -1 * a.localeCompare(b) : // unix sort treats case opposite how javascript does + aLower.localeCompare(bLower)); + } + + // compare two strings in the fashion that unix sort's -n option works + function numericalCmp(a, b) { + var objA = parseNumber(a); + var objB = parseNumber(b); + if (objA.hasOwnProperty('num') && objB.hasOwnProperty('num')) { + return ((objA.num !== objB.num) ? + (objA.num - objB.num) : + unixCmp(objA.value, objB.value)); + } else { + return unixCmp(objA.value, objB.value); + } + } + + //@ + //@ ### sort([options,] file [, file ...]) + //@ ### sort([options,] file_array) + //@ + //@ Available options: + //@ + //@ + `-r`: Reverse the results + //@ + `-n`: Compare according to numerical value + //@ + //@ Examples: + //@ + //@ ```javascript + //@ sort('foo.txt', 'bar.txt'); + //@ sort('-r', 'foo.txt'); + //@ ``` + //@ + //@ Return the contents of the `file`s, sorted line-by-line. Sorting multiple + //@ files mixes their content (just as unix `sort` does). + function _sort(options, files) { + // Check if this is coming from a pipe + var pipe = common.readFromPipe(); + + if (!files && !pipe) common.error('no files given'); + + files = [].slice.call(arguments, 1); + + if (pipe) { + files.unshift('-'); + } + + var lines = files.reduce(function (accum, file) { + if (file !== '-') { + if (!fs.existsSync(file)) { + common.error('no such file or directory: ' + file, { continue: true }); + return accum; + } else if (common.statFollowLinks(file).isDirectory()) { + common.error('read failed: ' + file + ': Is a directory', { + continue: true, + }); + return accum; + } + } + + var contents = file === '-' ? pipe : fs.readFileSync(file, 'utf8'); + return accum.concat(contents.trimRight().split('\n')); + }, []); + + var sorted = lines.sort(options.numerical ? numericalCmp : unixCmp); + + if (options.reverse) { + sorted = sorted.reverse(); + } + + return sorted.join('\n') + '\n'; + } + + sort = _sort; + return sort; +} + +var tail; +var hasRequiredTail; + +function requireTail () { + if (hasRequiredTail) return tail; + hasRequiredTail = 1; + var common = requireCommon(); + var fs = require$$1; + + common.register('tail', _tail, { + canReceivePipe: true, + cmdOptions: { + 'n': 'numLines', + }, + }); + + //@ + //@ ### tail([{'-n': \},] file [, file ...]) + //@ ### tail([{'-n': \},] file_array) + //@ + //@ Available options: + //@ + //@ + `-n `: Show the last `` lines of `file`s + //@ + //@ Examples: + //@ + //@ ```javascript + //@ var str = tail({'-n': 1}, 'file*.txt'); + //@ var str = tail('file1', 'file2'); + //@ var str = tail(['file1', 'file2']); // same as above + //@ ``` + //@ + //@ Read the end of a `file`. + function _tail(options, files) { + var tail = []; + var pipe = common.readFromPipe(); + + if (!files && !pipe) common.error('no paths given'); + + var idx = 1; + if (options.numLines === true) { + idx = 2; + options.numLines = Number(arguments[1]); + } else if (options.numLines === false) { + options.numLines = 10; + } + options.numLines = -1 * Math.abs(options.numLines); + files = [].slice.call(arguments, idx); + + if (pipe) { + files.unshift('-'); + } + + var shouldAppendNewline = false; + files.forEach(function (file) { + if (file !== '-') { + if (!fs.existsSync(file)) { + common.error('no such file or directory: ' + file, { continue: true }); + return; + } else if (common.statFollowLinks(file).isDirectory()) { + common.error("error reading '" + file + "': Is a directory", { + continue: true, + }); + return; + } + } + + var contents = file === '-' ? pipe : fs.readFileSync(file, 'utf8'); + + var lines = contents.split('\n'); + if (lines[lines.length - 1] === '') { + lines.pop(); + shouldAppendNewline = true; + } else { + shouldAppendNewline = false; + } + + tail = tail.concat(lines.slice(options.numLines)); + }); + + if (shouldAppendNewline) { + tail.push(''); // to add a trailing newline once we join + } + return tail.join('\n'); + } + tail = _tail; + return tail; +} + +var test; +var hasRequiredTest; + +function requireTest () { + if (hasRequiredTest) return test; + hasRequiredTest = 1; + var common = requireCommon(); + var fs = require$$1; + + common.register('test', _test, { + cmdOptions: { + 'b': 'block', + 'c': 'character', + 'd': 'directory', + 'e': 'exists', + 'f': 'file', + 'L': 'link', + 'p': 'pipe', + 'S': 'socket', + }, + wrapOutput: false, + allowGlobbing: false, + }); + + + //@ + //@ ### test(expression) + //@ + //@ Available expression primaries: + //@ + //@ + `'-b', 'path'`: true if path is a block device + //@ + `'-c', 'path'`: true if path is a character device + //@ + `'-d', 'path'`: true if path is a directory + //@ + `'-e', 'path'`: true if path exists + //@ + `'-f', 'path'`: true if path is a regular file + //@ + `'-L', 'path'`: true if path is a symbolic link + //@ + `'-p', 'path'`: true if path is a pipe (FIFO) + //@ + `'-S', 'path'`: true if path is a socket + //@ + //@ Examples: + //@ + //@ ```javascript + //@ if (test('-d', path)) { /* do something with dir */ }; + //@ if (!test('-f', path)) continue; // skip if it's a regular file + //@ ``` + //@ + //@ Evaluates `expression` using the available primaries and returns corresponding value. + function _test(options, path) { + if (!path) common.error('no path given'); + + var canInterpret = false; + Object.keys(options).forEach(function (key) { + if (options[key] === true) { + canInterpret = true; + } + }); + + if (!canInterpret) common.error('could not interpret expression'); + + if (options.link) { + try { + return common.statNoFollowLinks(path).isSymbolicLink(); + } catch (e) { + return false; + } + } + + if (!fs.existsSync(path)) return false; + + if (options.exists) return true; + + var stats = common.statFollowLinks(path); + + if (options.block) return stats.isBlockDevice(); + + if (options.character) return stats.isCharacterDevice(); + + if (options.directory) return stats.isDirectory(); + + if (options.file) return stats.isFile(); + + /* istanbul ignore next */ + if (options.pipe) return stats.isFIFO(); + + /* istanbul ignore next */ + if (options.socket) return stats.isSocket(); + + /* istanbul ignore next */ + return false; // fallback + } // test + test = _test; + return test; +} + +var to; +var hasRequiredTo; + +function requireTo () { + if (hasRequiredTo) return to; + hasRequiredTo = 1; + var common = requireCommon(); + var fs = require$$1; + var path = require$$2; + + common.register('to', _to, { + pipeOnly: true, + wrapOutput: false, + }); + + //@ + //@ ### ShellString.prototype.to(file) + //@ + //@ Examples: + //@ + //@ ```javascript + //@ cat('input.txt').to('output.txt'); + //@ ``` + //@ + //@ Analogous to the redirection operator `>` in Unix, but works with + //@ `ShellStrings` (such as those returned by `cat`, `grep`, etc.). _Like Unix + //@ redirections, `to()` will overwrite any existing file!_ + function _to(options, file) { + if (!file) common.error('wrong arguments'); + + if (!fs.existsSync(path.dirname(file))) { + common.error('no such file or directory: ' + path.dirname(file)); + } + + try { + fs.writeFileSync(file, this.stdout || this.toString(), 'utf8'); + return this; + } catch (e) { + /* istanbul ignore next */ + common.error('could not write to file (code ' + e.code + '): ' + file, { continue: true }); + } + } + to = _to; + return to; +} + +var toEnd; +var hasRequiredToEnd; + +function requireToEnd () { + if (hasRequiredToEnd) return toEnd; + hasRequiredToEnd = 1; + var common = requireCommon(); + var fs = require$$1; + var path = require$$2; + + common.register('toEnd', _toEnd, { + pipeOnly: true, + wrapOutput: false, + }); + + //@ + //@ ### ShellString.prototype.toEnd(file) + //@ + //@ Examples: + //@ + //@ ```javascript + //@ cat('input.txt').toEnd('output.txt'); + //@ ``` + //@ + //@ Analogous to the redirect-and-append operator `>>` in Unix, but works with + //@ `ShellStrings` (such as those returned by `cat`, `grep`, etc.). + function _toEnd(options, file) { + if (!file) common.error('wrong arguments'); + + if (!fs.existsSync(path.dirname(file))) { + common.error('no such file or directory: ' + path.dirname(file)); + } + + try { + fs.appendFileSync(file, this.stdout || this.toString(), 'utf8'); + return this; + } catch (e) { + /* istanbul ignore next */ + common.error('could not append to file (code ' + e.code + '): ' + file, { continue: true }); + } + } + toEnd = _toEnd; + return toEnd; +} + +var touch; +var hasRequiredTouch; + +function requireTouch () { + if (hasRequiredTouch) return touch; + hasRequiredTouch = 1; + var common = requireCommon(); + var fs = require$$1; + + common.register('touch', _touch, { + cmdOptions: { + 'a': 'atime_only', + 'c': 'no_create', + 'd': 'date', + 'm': 'mtime_only', + 'r': 'reference', + }, + }); + + //@ + //@ ### touch([options,] file [, file ...]) + //@ ### touch([options,] file_array) + //@ + //@ Available options: + //@ + //@ + `-a`: Change only the access time + //@ + `-c`: Do not create any files + //@ + `-m`: Change only the modification time + //@ + `-d DATE`: Parse `DATE` and use it instead of current time + //@ + `-r FILE`: Use `FILE`'s times instead of current time + //@ + //@ Examples: + //@ + //@ ```javascript + //@ touch('source.js'); + //@ touch('-c', '/path/to/some/dir/source.js'); + //@ touch({ '-r': FILE }, '/path/to/some/dir/source.js'); + //@ ``` + //@ + //@ Update the access and modification times of each `FILE` to the current time. + //@ A `FILE` argument that does not exist is created empty, unless `-c` is supplied. + //@ This is a partial implementation of [`touch(1)`](http://linux.die.net/man/1/touch). + function _touch(opts, files) { + if (!files) { + common.error('no files given'); + } else if (typeof files === 'string') { + files = [].slice.call(arguments, 1); + } else { + common.error('file arg should be a string file path or an Array of string file paths'); + } + + files.forEach(function (f) { + touchFile(opts, f); + }); + return ''; + } + + function touchFile(opts, file) { + var stat = tryStatFile(file); + + if (stat && stat.isDirectory()) { + // don't error just exit + return; + } + + // if the file doesn't already exist and the user has specified --no-create then + // this script is finished + if (!stat && opts.no_create) { + return; + } + + // open the file and then close it. this will create it if it doesn't exist but will + // not truncate the file + fs.closeSync(fs.openSync(file, 'a')); + + // + // Set timestamps + // + + // setup some defaults + var now = new Date(); + var mtime = opts.date || now; + var atime = opts.date || now; + + // use reference file + if (opts.reference) { + var refStat = tryStatFile(opts.reference); + if (!refStat) { + common.error('failed to get attributess of ' + opts.reference); + } + mtime = refStat.mtime; + atime = refStat.atime; + } else if (opts.date) { + mtime = opts.date; + atime = opts.date; + } + + if (opts.atime_only && opts.mtime_only) ; else if (opts.atime_only) { + mtime = stat.mtime; + } else if (opts.mtime_only) { + atime = stat.atime; + } + + fs.utimesSync(file, atime, mtime); + } + + touch = _touch; + + function tryStatFile(filePath) { + try { + return common.statFollowLinks(filePath); + } catch (e) { + return null; + } + } + return touch; +} + +var uniq; +var hasRequiredUniq; + +function requireUniq () { + if (hasRequiredUniq) return uniq; + hasRequiredUniq = 1; + var common = requireCommon(); + var fs = require$$1; + + // add c spaces to the left of str + function lpad(c, str) { + var res = '' + str; + if (res.length < c) { + res = Array((c - res.length) + 1).join(' ') + res; + } + return res; + } + + common.register('uniq', _uniq, { + canReceivePipe: true, + cmdOptions: { + 'i': 'ignoreCase', + 'c': 'count', + 'd': 'duplicates', + }, + }); + + //@ + //@ ### uniq([options,] [input, [output]]) + //@ + //@ Available options: + //@ + //@ + `-i`: Ignore case while comparing + //@ + `-c`: Prefix lines by the number of occurrences + //@ + `-d`: Only print duplicate lines, one for each group of identical lines + //@ + //@ Examples: + //@ + //@ ```javascript + //@ uniq('foo.txt'); + //@ uniq('-i', 'foo.txt'); + //@ uniq('-cd', 'foo.txt', 'bar.txt'); + //@ ``` + //@ + //@ Filter adjacent matching lines from `input`. + function _uniq(options, input, output) { + // Check if this is coming from a pipe + var pipe = common.readFromPipe(); + + if (!pipe) { + if (!input) common.error('no input given'); + + if (!fs.existsSync(input)) { + common.error(input + ': No such file or directory'); + } else if (common.statFollowLinks(input).isDirectory()) { + common.error("error reading '" + input + "'"); + } + } + if (output && fs.existsSync(output) && common.statFollowLinks(output).isDirectory()) { + common.error(output + ': Is a directory'); + } + + var lines = (input ? fs.readFileSync(input, 'utf8') : pipe). + trimRight(). + split('\n'); + + var compare = function (a, b) { + return options.ignoreCase ? + a.toLocaleLowerCase().localeCompare(b.toLocaleLowerCase()) : + a.localeCompare(b); + }; + var uniqed = lines.reduceRight(function (res, e) { + // Perform uniq -c on the input + if (res.length === 0) { + return [{ count: 1, ln: e }]; + } else if (compare(res[0].ln, e) === 0) { + return [{ count: res[0].count + 1, ln: e }].concat(res.slice(1)); + } else { + return [{ count: 1, ln: e }].concat(res); + } + }, []).filter(function (obj) { + // Do we want only duplicated objects? + return options.duplicates ? obj.count > 1 : true; + }).map(function (obj) { + // Are we tracking the counts of each line? + return (options.count ? (lpad(7, obj.count) + ' ') : '') + obj.ln; + }).join('\n') + '\n'; + + if (output) { + (new common.ShellString(uniqed)).to(output); + // if uniq writes to output, nothing is passed to the next command in the pipeline (if any) + return ''; + } else { + return uniqed; + } + } + + uniq = _uniq; + return uniq; +} + +var which; +var hasRequiredWhich; + +function requireWhich () { + if (hasRequiredWhich) return which; + hasRequiredWhich = 1; + var common = requireCommon(); + var fs = require$$1; + var path = require$$2; + + common.register('which', _which, { + allowGlobbing: false, + cmdOptions: { + 'a': 'all', + }, + }); + + // XP's system default value for `PATHEXT` system variable, just in case it's not + // set on Windows. + var XP_DEFAULT_PATHEXT = '.com;.exe;.bat;.cmd;.vbs;.vbe;.js;.jse;.wsf;.wsh'; + + // For earlier versions of NodeJS that doesn't have a list of constants (< v6) + var FILE_EXECUTABLE_MODE = 1; + + function isWindowsPlatform() { + return process.platform === 'win32'; + } + + // Cross-platform method for splitting environment `PATH` variables + function splitPath(p) { + return p ? p.split(path.delimiter) : []; + } + + // Tests are running all cases for this func but it stays uncovered by codecov due to unknown reason + /* istanbul ignore next */ + function isExecutable(pathName) { + try { + // TODO(node-support): replace with fs.constants.X_OK once remove support for node < v6 + fs.accessSync(pathName, FILE_EXECUTABLE_MODE); + } catch (err) { + return false; + } + return true; + } + + function checkPath(pathName) { + return fs.existsSync(pathName) && !common.statFollowLinks(pathName).isDirectory() + && (isWindowsPlatform() || isExecutable(pathName)); + } + + //@ + //@ ### which(command) + //@ + //@ Examples: + //@ + //@ ```javascript + //@ var nodeExec = which('node'); + //@ ``` + //@ + //@ Searches for `command` in the system's `PATH`. On Windows, this uses the + //@ `PATHEXT` variable to append the extension if it's not already executable. + //@ Returns string containing the absolute path to `command`. + function _which(options, cmd) { + if (!cmd) common.error('must specify command'); + + var isWindows = isWindowsPlatform(); + var pathArray = splitPath(process.env.PATH); + + var queryMatches = []; + + // No relative/absolute paths provided? + if (cmd.indexOf('/') === -1) { + // Assume that there are no extensions to append to queries (this is the + // case for unix) + var pathExtArray = ['']; + if (isWindows) { + // In case the PATHEXT variable is somehow not set (e.g. + // child_process.spawn with an empty environment), use the XP default. + var pathExtEnv = process.env.PATHEXT || XP_DEFAULT_PATHEXT; + pathExtArray = splitPath(pathExtEnv.toUpperCase()); + } + + // Search for command in PATH + for (var k = 0; k < pathArray.length; k++) { + // already found it + if (queryMatches.length > 0 && !options.all) break; + + var attempt = path.resolve(pathArray[k], cmd); + + if (isWindows) { + attempt = attempt.toUpperCase(); + } + + var match = attempt.match(/\.[^<>:"/\|?*.]+$/); + if (match && pathExtArray.indexOf(match[0]) >= 0) { // this is Windows-only + // The user typed a query with the file extension, like + // `which('node.exe')` + if (checkPath(attempt)) { + queryMatches.push(attempt); + break; + } + } else { // All-platforms + // Cycle through the PATHEXT array, and check each extension + // Note: the array is always [''] on Unix + for (var i = 0; i < pathExtArray.length; i++) { + var ext = pathExtArray[i]; + var newAttempt = attempt + ext; + if (checkPath(newAttempt)) { + queryMatches.push(newAttempt); + break; + } + } + } + } + } else if (checkPath(cmd)) { // a valid absolute or relative path + queryMatches.push(path.resolve(cmd)); + } + + if (queryMatches.length > 0) { + return options.all ? queryMatches : queryMatches[0]; + } + return options.all ? [] : null; + } + which = _which; + return which; +} + +var dynamicModules; + +function getDynamicModules() { + return dynamicModules || (dynamicModules = { + "/node_modules/shelljs/src/cat.js": requireCat, + "/node_modules/shelljs/src/cd.js": requireCd, + "/node_modules/shelljs/src/chmod.js": requireChmod, + "/node_modules/shelljs/src/common.js": requireCommon, + "/node_modules/shelljs/src/cp.js": requireCp, + "/node_modules/shelljs/src/dirs.js": requireDirs, + "/node_modules/shelljs/src/echo.js": requireEcho, + "/node_modules/shelljs/src/error.js": requireError, + "/node_modules/shelljs/src/exec-child.js": requireExecChild, + "/node_modules/shelljs/src/exec.js": requireExec, + "/node_modules/shelljs/src/find.js": requireFind, + "/node_modules/shelljs/src/grep.js": requireGrep, + "/node_modules/shelljs/src/head.js": requireHead, + "/node_modules/shelljs/src/ln.js": requireLn, + "/node_modules/shelljs/src/ls.js": requireLs, + "/node_modules/shelljs/src/mkdir.js": requireMkdir, + "/node_modules/shelljs/src/mv.js": requireMv, + "/node_modules/shelljs/src/popd.js": requirePopd, + "/node_modules/shelljs/src/pushd.js": requirePushd, + "/node_modules/shelljs/src/pwd.js": requirePwd, + "/node_modules/shelljs/src/rm.js": requireRm, + "/node_modules/shelljs/src/sed.js": requireSed, + "/node_modules/shelljs/src/set.js": requireSet, + "/node_modules/shelljs/src/sort.js": requireSort, + "/node_modules/shelljs/src/tail.js": requireTail, + "/node_modules/shelljs/src/tempdir.js": requireTempdir, + "/node_modules/shelljs/src/test.js": requireTest, + "/node_modules/shelljs/src/to.js": requireTo, + "/node_modules/shelljs/src/toEnd.js": requireToEnd, + "/node_modules/shelljs/src/touch.js": requireTouch, + "/node_modules/shelljs/src/uniq.js": requireUniq, + "/node_modules/shelljs/src/which.js": requireWhich + }); +} + +function createCommonjsRequire(originalModuleDir) { + function handleRequire(path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return getDynamicModules()[resolvedPath](); + } + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); + } + handleRequire.resolve = function (path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return resolvedPath; + } + return require.resolve(path); + }; + return handleRequire; +} + +function commonjsResolve (path, originalModuleDir) { + var shouldTryNodeModules = isPossibleNodeModulesPath(path); + path = normalize(path); + var relPath; + if (path[0] === '/') { + originalModuleDir = ''; + } + var modules = getDynamicModules(); + var checkedExtensions = ['', '.js', '.json']; + while (true) { + if (!shouldTryNodeModules) { + relPath = normalize(originalModuleDir + '/' + path); + } else { + relPath = normalize(originalModuleDir + '/node_modules/' + path); + } + + if (relPath.endsWith('/..')) { + break; // Travelled too far up, avoid infinite loop + } + + for (var extensionIndex = 0; extensionIndex < checkedExtensions.length; extensionIndex++) { + var resolvedPath = relPath + checkedExtensions[extensionIndex]; + if (modules[resolvedPath]) { + return resolvedPath; + } + } + if (!shouldTryNodeModules) break; + var nextDir = normalize(originalModuleDir + '/..'); + if (nextDir === originalModuleDir) break; + originalModuleDir = nextDir; + } + return null; +} + +function isPossibleNodeModulesPath (modulePath) { + var c0 = modulePath[0]; + if (c0 === '/' || c0 === '\\') return false; + var c1 = modulePath[1], c2 = modulePath[2]; + if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\')) || + (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\'))) return false; + if (c1 === ':' && (c2 === '/' || c2 === '\\')) return false; + return true; +} + +function normalize (path) { + path = path.replace(/\\/g, '/'); + var parts = path.split('/'); + var slashed = parts[0] === ''; + for (var i = 1; i < parts.length; i++) { + if (parts[i] === '.' || parts[i] === '') { + parts.splice(i--, 1); + } + } + for (var i = 1; i < parts.length; i++) { + if (parts[i] !== '..') continue; + if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') { + parts.splice(--i, 2); + i--; + } + } + path = parts.join('/'); + if (slashed && path[0] !== '/') path = '/' + path; + else if (path.length === 0) path = '.'; + return path; +} + +var shell$2 = {}; + +var commands = [ + 'cat', + 'cd', + 'chmod', + 'cp', + 'dirs', + 'echo', + 'exec', + 'find', + 'grep', + 'head', + 'ln', + 'ls', + 'mkdir', + 'mv', + 'pwd', + 'rm', + 'sed', + 'set', + 'sort', + 'tail', + 'tempdir', + 'test', + 'to', + 'toEnd', + 'touch', + 'uniq', + 'which', +]; + +var hasRequiredShell; + +function requireShell () { + if (hasRequiredShell) return shell$2; + hasRequiredShell = 1; + // + // ShellJS + // Unix shell commands on top of Node's API + // + // Copyright (c) 2012 Artur Adib + // http://github.com/shelljs/shelljs + // + + var common = requireCommon(); + + //@ + //@ All commands run synchronously, unless otherwise stated. + //@ All commands accept standard bash globbing characters (`*`, `?`, etc.), + //@ compatible with the [node `glob` module](https://github.com/isaacs/node-glob). + //@ + //@ For less-commonly used commands and features, please check out our [wiki + //@ page](https://github.com/shelljs/shelljs/wiki). + //@ + + // Include the docs for all the default commands + //@commands + + // Load all default commands + commands.forEach(function (command) { + createCommonjsRequire("/node_modules/shelljs")('./src/' + command); + }); + + //@ + //@ ### exit(code) + //@ + //@ Exits the current process with the given exit `code`. + shell$2.exit = process.exit; + + //@include ./src/error + shell$2.error = requireError(); + + //@include ./src/common + shell$2.ShellString = common.ShellString; + + //@ + //@ ### env['VAR_NAME'] + //@ + //@ Object containing environment variables (both getter and setter). Shortcut + //@ to `process.env`. + shell$2.env = process.env; + + //@ + //@ ### Pipes + //@ + //@ Examples: + //@ + //@ ```javascript + //@ grep('foo', 'file1.txt', 'file2.txt').sed(/o/g, 'a').to('output.txt'); + //@ echo('files with o\'s in the name:\n' + ls().grep('o')); + //@ cat('test.js').exec('node'); // pipe to exec() call + //@ ``` + //@ + //@ Commands can send their output to another command in a pipe-like fashion. + //@ `sed`, `grep`, `cat`, `exec`, `to`, and `toEnd` can appear on the right-hand + //@ side of a pipe. Pipes can be chained. + + //@ + //@ ## Configuration + //@ + + shell$2.config = common.config; + + //@ + //@ ### config.silent + //@ + //@ Example: + //@ + //@ ```javascript + //@ var sh = require('shelljs'); + //@ var silentState = sh.config.silent; // save old silent state + //@ sh.config.silent = true; + //@ /* ... */ + //@ sh.config.silent = silentState; // restore old silent state + //@ ``` + //@ + //@ Suppresses all command output if `true`, except for `echo()` calls. + //@ Default is `false`. + + //@ + //@ ### config.fatal + //@ + //@ Example: + //@ + //@ ```javascript + //@ require('shelljs/global'); + //@ config.fatal = true; // or set('-e'); + //@ cp('this_file_does_not_exist', '/dev/null'); // throws Error here + //@ /* more commands... */ + //@ ``` + //@ + //@ If `true`, the script will throw a Javascript error when any shell.js + //@ command encounters an error. Default is `false`. This is analogous to + //@ Bash's `set -e`. + + //@ + //@ ### config.verbose + //@ + //@ Example: + //@ + //@ ```javascript + //@ config.verbose = true; // or set('-v'); + //@ cd('dir/'); + //@ rm('-rf', 'foo.txt', 'bar.txt'); + //@ exec('echo hello'); + //@ ``` + //@ + //@ Will print each command as follows: + //@ + //@ ``` + //@ cd dir/ + //@ rm -rf foo.txt bar.txt + //@ exec echo hello + //@ ``` + + //@ + //@ ### config.globOptions + //@ + //@ Example: + //@ + //@ ```javascript + //@ config.globOptions = {nodir: true}; + //@ ``` + //@ + //@ Use this value for calls to `glob.sync()` instead of the default options. + + //@ + //@ ### config.reset() + //@ + //@ Example: + //@ + //@ ```javascript + //@ var shell = require('shelljs'); + //@ // Make changes to shell.config, and do stuff... + //@ /* ... */ + //@ shell.config.reset(); // reset to original state + //@ // Do more stuff, but with original settings + //@ /* ... */ + //@ ``` + //@ + //@ Reset `shell.config` to the defaults: + //@ + //@ ```javascript + //@ { + //@ fatal: false, + //@ globOptions: {}, + //@ maxdepth: 255, + //@ noglob: false, + //@ silent: false, + //@ verbose: false, + //@ } + //@ ``` + return shell$2; +} + +/* eslint no-extend-native: 0 */ + +var shell$1 = requireShell(); +var common = requireCommon(); +Object.keys(shell$1).forEach(function (cmd) { + commonjsGlobal[cmd] = shell$1[cmd]; +}); + +var _to = requireTo(); +String.prototype.to = common.wrap('to', _to); + +var _toEnd = requireToEnd(); +String.prototype.toEnd = common.wrap('toEnd', _toEnd); + +commonjsGlobal.config.fatal = true; +commonjsGlobal.target = {}; + +var args = process.argv.slice(2), + targetArgs, + dashesLoc = args.indexOf('--'); + +// split args, everything after -- if only for targets +if (dashesLoc > -1) { + targetArgs = args.slice(dashesLoc + 1, args.length); + args = args.slice(0, dashesLoc); +} + +// This ensures we only execute the script targets after the entire script has +// been evaluated +setTimeout(function() { + var t; + + if (args.length === 1 && args[0] === '--help') { + console.log('Available targets:'); + for (t in commonjsGlobal.target) + console.log(' ' + t); + return; + } + + // Wrap targets to prevent duplicate execution + for (t in commonjsGlobal.target) { + (function(t, oldTarget){ + + // Wrap it + commonjsGlobal.target[t] = function() { + if (!oldTarget.done){ + oldTarget.done = true; + oldTarget.result = oldTarget.apply(oldTarget, arguments); + } + return oldTarget.result; + }; + + })(t, commonjsGlobal.target[t]); + } + + // Execute desired targets + if (args.length > 0) { + args.forEach(function(arg) { + if (arg in commonjsGlobal.target) + commonjsGlobal.target[arg](targetArgs); + else { + console.log('no such target: ' + arg); + } + }); + } else if ('all' in commonjsGlobal.target) { + commonjsGlobal.target.all(targetArgs); + } + +}, 0); /** * @type {import("shelljs")} @@ -31,7 +7523,7 @@ function exec(executable, args, cwd, inheritStdio = true) { try { return execFileSync(executable, args, { stdio: inheritStdio ? "inherit" : undefined, - cwd: cwd && path.resolve(cwd), + cwd: cwd && require$$2.resolve(cwd), env: process.env, }); } catch (error) { diff --git a/Makefile.source.mjs b/Makefile.source.mjs new file mode 100644 index 000000000000..caf62baa702d --- /dev/null +++ b/Makefile.source.mjs @@ -0,0 +1,359 @@ +import "shelljs/make.js"; +import path from "path"; +import { execFileSync } from "child_process"; +import { writeFileSync } from "fs"; + +/** + * @type {import("shelljs")} + */ +const shell = global; +const target = global.target; + +const SOURCES = ["packages", "codemods", "eslint"]; + +const YARN_PATH = shell.which("yarn").stdout; +const NODE_PATH = process.execPath; // `yarn node` is so slow on Windows + +shell.config.verbose = true; + +function print(msg) { + console.log(msg); +} + +function exec(executable, args, cwd, inheritStdio = true) { + print( + `${(executable.replaceAll(YARN_PATH), "yarn").replaceAll( + NODE_PATH, + "node" + )} ${args.join(" ")}` + ); + + try { + return execFileSync(executable, args, { + stdio: inheritStdio ? "inherit" : undefined, + cwd: cwd && path.resolve(cwd), + env: process.env, + }); + } catch (error) { + if (inheritStdio && error.status != 0) { + console.error( + new Error( + `\ncommand: ${executable} ${args.join(" ")}\ncode: ${error.status}` + ) + ); + // eslint-disable-next-line no-process-exit + process.exit(error.status); + } + throw error; + } +} + +function yarn(args, cwd, inheritStdio) { + return exec(YARN_PATH, args, cwd, inheritStdio); +} + +function node(args, cwd, inheritStdio) { + return exec(NODE_PATH, args, cwd, inheritStdio); +} + +function env(fun, env) { + const envBak = process.env; + process.env = { ...envBak, ...env }; + fun(); + process.env = envBak; +} + +/** + * CLEAN + */ + +target["clean-all"] = function () { + ["node_modules", "package-lock.json", ".changelog"].forEach(path => { + shell.rm("-rf", path); + }); + + SOURCES.forEach(source => { + shell.rm("-rf", `${source}/*/test/tmp`); + shell.rm("-rf", `${source}/*/package-lock.json`); + }); + + target["clean"](); + target["clean-lib"](); +}; + +target["clean"] = function () { + target["test-clean"](); + + [ + ".npmrc", + "coverage", + "packages/*/npm-debug*", + "node_modules/.cache", + ].forEach(path => { + shell.rm("-rf", path); + }); +}; + +target["test-clean"] = function () { + SOURCES.forEach(source => { + shell.rm("-rf", `${source}/*/test/tmp`); + shell.rm("-rf", `${source}/*/test-fixtures.json`); + }); +}; + +target["clean-lib"] = function () { + SOURCES.forEach(source => { + shell.rm("-rf", `${source}/*/lib`); + }); +}; + +target["clean-runtime-helpers"] = function () { + [ + "packages/babel-runtime/helpers/**/*.js", + "packages/babel-runtime-corejs2/helpers/**/*.js", + "packages/babel-runtime-corejs3/helpers/**/*.js", + "packages/babel-runtime/helpers/**/*.mjs", + "packages/babel-runtime-corejs2/helpers/**/*.mjs", + "packages/babel-runtime-corejs3/helpers/**/*.mjs", + "packages/babel-runtime-corejs2/core-js", + ].forEach(path => { + shell.rm("-rf", path); + }); +}; + +/** + * BUILD + */ + +target["use-cjs"] = function () { + node(["scripts/set-module-type.js", "script"]); + + target["bootstrap"](); +}; + +target["use-esm"] = function () { + node(["scripts/set-module-type.js", "module"]); + + target["bootstrap"](); +}; + +target["bootstrap-only"] = function () { + target["clean-all"](); + + yarn(["install"]); +}; + +target["bootstrap"] = function () { + target["bootstrap-only"](); + + target["generate-tsconfig"](); + target["build"](); +}; + +target["build"] = function () { + target["build-bundle"](); + + if (process.env.BABEL_COVERAGE != "true") { + target["build-standalone"](); + } +}; + +target["build-standalone"] = function () { + yarn(["gulp", "build-babel-standalone"]); +}; + +target["build-bundle"] = function () { + node(["scripts/set-module-type.js"]); + + target["clean"](); + target["clean-lib"](); + + yarn(["gulp", "build"]); + + target["build-flow-typings"](); + target["build-dist"](); +}; + +target["build-no-bundle"] = function () { + node(["scripts/set-module-type.js"]); + + target["clean"](); + target["clean-lib"](); + + env( + () => { + yarn(["gulp", "build-dev"]); + }, + { BABEL_ENV: "development" } + ); + + target["build-flow-typings"](); + target["build-dist"](); +}; + +target["build-flow-typings"] = function () { + writeFileSync( + "packages/babel-types/lib/index.js.flow", + node(["packages/babel-types/scripts/generators/flow.js"], undefined, false) + ); +}; + +target["build-dist"] = function () { + target["build-plugin-transform-runtime-dist"](); +}; + +target["build-plugin-transform-runtime-dist"] = function () { + node(["scripts/build-dist.js"], "packages/babel-plugin-transform-runtime"); +}; + +target["prepublish-build"] = function () { + target["clean-lib"](); + target["clean-runtime-helpers"](); + + env( + () => { + target["build-bundle"](); + }, + { + NODE_ENV: "production", + BABEL_ENV: "production", + STRIP_BABEL_8_FLAG: "true", + } + ); + + env( + () => { + target["prepublish-build-standalone"](); + target["clone-license"](); + target["prepublish-prepare-dts"](); + }, + { + STRIP_BABEL_8_FLAG: "true", + } + ); +}; + +target["prepublish-build-standalone"] = function () { + env( + () => { + target["build-standalone"](); + }, + { + BABEL_ENV: "production", + IS_PUBLISH: "true", + } + ); +}; + +target["prepublish-prepare-dts"] = function () { + target["tscheck"](); + + yarn(["gulp", "bundle-dts"]); + + target["build-typescript-legacy-typings"](); +}; + +target["tscheck"] = function () { + target["generate-tsconfig"](); + + shell.rm("-rf", "dts"); + yarn(["tsc", "-b", "."]); +}; + +target["generate-tsconfig"] = function () { + node(["scripts/generators/tsconfig.js"]); + node(["scripts/generators/archived-libs-typings.js"]); +}; + +target["clone-license"] = function () { + node(["scripts/clone-license.js"]); +}; + +target["build-typescript-legacy-typings"] = function () { + writeFileSync( + "packages/babel-types/lib/index-legacy.d.ts", + node( + ["packages/babel-types/scripts/generators/typescript-legacy.js"], + undefined, + false + ) + ); +}; + +/** + * DEV + */ + +target["lint"] = function () { + env( + () => { + yarn([ + "eslint", + "scripts", + "benchmark", + ...SOURCES, + "*.{js,cjs,mjs,ts}", + "--format", + "codeframe", + "--ext", + ".js,.cjs,.mjs,.ts", + ]); + }, + { + BABEL_ENV: "test", + } + ); +}; + +target["fix"] = function () { + target["fix-json"](); + target["fix-js"](); +}; + +target["fix-js"] = function () { + yarn([ + "eslint", + "scripts", + "benchmark", + ...SOURCES, + "*.{js,cjs,mjs,ts}", + "--format", + "codeframe", + "--ext", + ".js,.cjs,.mjs,.ts", + "--fix", + ]); +}; + +target["fix-json"] = function () { + yarn([ + "prettier", + `{${SOURCES.join(",")}}/*/test/fixtures/**/options.json`, + "--write", + "--loglevel", + "warn", + ]); +}; + +target["watch"] = function () { + target["build-no-bundle"](); + + env( + () => { + yarn(["gulp", "watch"]); + }, + { + BABEL_ENV: "development", + WATCH_SKIP_BUILD: "true", + } + ); +}; + +target["test"] = function () { + target["lint"](); + target["test-only"](); +}; + +target["test-only"] = function (args = []) { + yarn(["jest", ...args]); +}; diff --git a/scripts/pack-script.js b/scripts/pack-script.js new file mode 100644 index 000000000000..a1b879205c60 --- /dev/null +++ b/scripts/pack-script.js @@ -0,0 +1,36 @@ +import { fileURLToPath } from "url"; +import path from "path"; +import { rollup } from "rollup"; +import { nodeResolve } from "@rollup/plugin-node-resolve"; +import commonjs from "@rollup/plugin-commonjs"; +import { writeFileSync } from "fs"; + +const root = fileURLToPath(path.dirname(import.meta.url)); + +pack("../Makefile.source.mjs", "../Makefile.mjs", [ + "node_modules/shelljs/src/*.js", +]); + +async function pack(inputPath, outputPath, dynamicRequireTargets) { + inputPath = path.join(root, inputPath); + outputPath = path.join(root, outputPath); + + const bundle = await rollup({ + input: inputPath, + + plugins: [ + nodeResolve({ preferBuiltins: true }), + commonjs({ + dynamicRequireTargets: dynamicRequireTargets, + }), + ], + }); + const result = await bundle.generate({ + format: "esm", + }); + + const output = `/* eslint-disable */ + //prettier-ignore + ${result.output[0].code}`; + writeFileSync(outputPath, output); +} From 8827708519d7368ee71ed0298c09e6b34d1eab60 Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Sat, 16 Jul 2022 05:31:51 +0800 Subject: [PATCH 08/12] Update Makefile.mjs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Nicolò Ribaudo --- Makefile.mjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.mjs b/Makefile.mjs index cc2179d1a466..73ddeccb6fd8 100644 --- a/Makefile.mjs +++ b/Makefile.mjs @@ -7514,7 +7514,7 @@ function print(msg) { function exec(executable, args, cwd, inheritStdio = true) { print( - `${(executable.replaceAll(YARN_PATH), "yarn").replaceAll( + `${executable.replaceAll(YARN_PATH, "yarn").replaceAll( NODE_PATH, "node" )} ${args.join(" ")}` From 059b0d5a3101c7ea2a1fd5152be883aeeda398a2 Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Sat, 16 Jul 2022 19:24:39 +0800 Subject: [PATCH 09/12] review --- Makefile | 205 ++++++++++++++++---------------------------- Makefile.source.mjs | 39 +++++++++ 2 files changed, 111 insertions(+), 133 deletions(-) diff --git a/Makefile b/Makefile index 48c235fe0d3a..5d1fba878a15 100644 --- a/Makefile +++ b/Makefile @@ -14,110 +14,127 @@ COMMA_SEPARATED_SOURCES = $(subst $(SPACE),$(COMMA),$(SOURCES)) YARN := yarn NODE := $(YARN) node +MAKEJS := node Makefile.mjs .PHONY: build build-dist watch lint fix clean test-clean test-only test test-ci publish bootstrap use-esm use-cjs -build: build-no-bundle -ifneq ("$(BABEL_COVERAGE)", "true") - $(MAKE) build-standalone -endif +build: + $(MAKEJS) build -build-bundle: clean clean-lib - node ./scripts/set-module-type.js - $(YARN) gulp build - $(MAKE) build-flow-typings - $(MAKE) build-dist +build-bundle: + $(MAKEJS) build-bundle -build-no-bundle-ci: bootstrap-only - $(YARN) gulp build-dev - $(MAKE) build-flow-typings - $(MAKE) build-dist - -build-no-bundle: clean clean-lib - node ./scripts/set-module-type.js - BABEL_ENV=development $(YARN) gulp build-dev - $(MAKE) build-flow-typings - $(MAKE) build-dist +build-no-bundle: + $(MAKEJS) build-no-bundle generate-tsconfig: - $(NODE) scripts/generators/tsconfig.js - $(NODE) scripts/generators/archived-libs-typings.js + $(MAKEJS) generate-tsconfig generate-type-helpers: - $(YARN) gulp generate-type-helpers + $(MAKEJS) generate-type-helpers build-flow-typings: - $(NODE) packages/babel-types/scripts/generators/flow.js > packages/babel-types/lib/index.js.flow + $(MAKEJS) build-flow-typings # For TypeScript older than 3.7 build-typescript-legacy-typings: - $(NODE) packages/babel-types/scripts/generators/typescript-legacy.js > packages/babel-types/lib/index-legacy.d.ts + $(MAKEJS) build-typescript-legacy-typings -build-standalone: build-babel-standalone +build-standalone: + $(MAKEJS) build-standalone build-standalone-ci: build-no-bundle-ci - $(MAKE) build-standalone - -build-babel-standalone: - $(YARN) gulp build-babel-standalone + $(MAKEJS) build-standalone prepublish-build-standalone: - BABEL_ENV=production IS_PUBLISH=true $(YARN) gulp build-babel-standalone + $(MAKEJS) prepublish-build-standalone build-dist: build-plugin-transform-runtime-dist build-plugin-transform-runtime-dist: - cd packages/babel-plugin-transform-runtime; \ - $(NODE) scripts/build-dist.js + $(MAKEJS) build-plugin-transform-runtime-dist -watch: build-no-bundle - BABEL_ENV=development WATCH_SKIP_BUILD=true $(YARN) gulp watch +watch: + $(MAKEJS) watch code-quality: tscheck lint -tscheck: generate-tsconfig - rm -rf dts - $(YARN) tsc -b . +tscheck: + $(MAKEJS) tscheck lint-ci: lint check-compat-data-ci -check-compat-data-ci: - $(MAKE) check-compat-data +check-compat-data-ci: check-compat-data lint: - BABEL_ENV=test $(YARN) eslint scripts benchmark $(SOURCES) '*.{js,cjs,mjs,ts}' --format=codeframe --ext .js,.cjs,.mjs,.ts + $(MAKEJS) lint fix: fix-json fix-js fix-js: - $(YARN) eslint scripts benchmark $(SOURCES) '*.{js,cjs,mjs,ts}' --format=codeframe --ext .js,.cjs,.mjs,.ts --fix + $(MAKEJS) fix-js fix-json: - $(YARN) prettier "{$(COMMA_SEPARATED_SOURCES)}/*/test/fixtures/**/options.json" --write --loglevel warn + $(MAKEJS) fix-json -check-compat-data: - cd packages/babel-compat-data; CHECK_COMPAT_DATA=true $(YARN) run build-data +clean: + $(MAKEJS) clean -build-compat-data: - cd packages/babel-compat-data; $(YARN) run build-data +test: lint test-only + +clone-license: + $(MAKEJS) clone-license + +prepublish-build: + $(MAKEJS) prepublish-build + +prepublish: + $(MAKEJS) prepublish-build -clean: test-clean - rm -f .npmrc - rm -rf coverage - rm -rf packages/*/npm-debug* - rm -rf node_modules/.cache +bootstrap-only: + $(MAKEJS) bootstrap-only -test-clean: - $(foreach source, $(SOURCES), \ - $(call clean-source-test, $(source))) +bootstrap: + $(MAKEJS) bootstrap + +use-cjs: + $(MAKEJS) use-cjs + +use-esm: + $(MAKEJS) use-esm + +clean-lib: + $(MAKEJS) clean-lib + +clean-runtime-helpers: + $(MAKEJS) clean-runtime-helpers + +clean-all: + $(MAKEJS) clean-all + + +build-no-bundle-ci: bootstrap-only + $(YARN) gulp build-dev + $(MAKE) build-flow-typings + $(MAKE) build-dist # Does not work on Windows; use "$(YARN) jest" instead test-only: BABEL_ENV=test ./scripts/test.sh $(MAKE) test-clean -test: lint test-only +check-compat-data: + cd packages/babel-compat-data; CHECK_COMPAT_DATA=true $(YARN) run build-data + +build-compat-data: + cd packages/babel-compat-data; $(YARN) run build-data + +update-env-corejs-fixture: + rm -rf packages/babel-preset-env/node_modules/core-js-compat + $(YARN) + $(MAKE) build-bundle + OVERWRITE=true $(YARN) jest packages/babel-preset-env test-ci: build-standalone-ci BABEL_ENV=test $(YARN) jest --maxWorkers=4 --ci @@ -165,23 +182,6 @@ test-test262: test-test262-update-allowlist: $(NODE) scripts/parser-tests/test262 --update-allowlist -clone-license: - $(NODE) ./scripts/clone-license.js - -prepublish-build: clean-lib clean-runtime-helpers - NODE_ENV=production BABEL_ENV=production STRIP_BABEL_8_FLAG=true $(MAKE) build-bundle - STRIP_BABEL_8_FLAG=true $(MAKE) prepublish-build-standalone clone-license prepublish-prepare-dts - -prepublish-prepare-dts: - $(MAKE) tscheck - $(YARN) gulp bundle-dts - $(MAKE) build-typescript-legacy-typings - -prepublish: - $(MAKE) bootstrap-only - $(MAKE) prepublish-build - IS_PUBLISH=true $(MAKE) test - node ./scripts/set-module-type.js clean new-version-checklist: # @echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" @@ -220,64 +220,3 @@ endif node ./scripts/set-module-type.js clean YARN_NPM_PUBLISH_REGISTRY=http://localhost:4873 $(YARN) release-tool publish --yes --tag-version-prefix="version-e2e-test-" $(MAKE) clean - -bootstrap-only: clean-all - $(YARN) install - -bootstrap: bootstrap-only - $(MAKE) generate-tsconfig build - -use-cjs: - node ./scripts/set-module-type.js script - $(MAKE) bootstrap - -use-esm: - node ./scripts/set-module-type.js module - $(MAKE) bootstrap - -clean-lib: - $(foreach source, $(SOURCES), \ - $(call clean-source-lib, $(source))) - -clean-runtime-helpers: - rm -f packages/babel-runtime/helpers/**/*.js - rm -f packages/babel-runtime-corejs2/helpers/**/*.js - rm -f packages/babel-runtime-corejs3/helpers/**/*.js - rm -f packages/babel-runtime/helpers/**/*.mjs - rm -f packages/babel-runtime-corejs2/helpers/**/*.mjs - rm -f packages/babel-runtime-corejs3/helpers/**/*.mjs - rm -rf packages/babel-runtime-corejs2/core-js - -clean-all: - rm -rf node_modules - rm -rf package-lock.json - rm -rf .changelog - - $(foreach source, $(SOURCES), \ - $(call clean-source-all, $(source))) - - $(MAKE) clean - -update-env-corejs-fixture: - rm -rf packages/babel-preset-env/node_modules/core-js-compat - $(YARN) - $(MAKE) build-bundle - OVERWRITE=true $(YARN) jest packages/babel-preset-env - -define clean-source-lib - rm -rf $(1)/*/lib - -endef - -define clean-source-test - rm -rf $(1)/*/test/tmp - rm -rf $(1)/*/test-fixtures.json - -endef - -define clean-source-all - $(call clean-source-lib, $1) - rm -rf $(1)/*/node_modules - rm -rf $(1)/*/package-lock.json - -endef diff --git a/Makefile.source.mjs b/Makefile.source.mjs index caf62baa702d..3ce1a2cc789d 100644 --- a/Makefile.source.mjs +++ b/Makefile.source.mjs @@ -265,6 +265,10 @@ target["generate-tsconfig"] = function () { node(["scripts/generators/archived-libs-typings.js"]); }; +target["generate-type-helpers"] = function () { + yarn(["gulp", "generate-type-helpers"]); +}; + target["clone-license"] = function () { node(["scripts/clone-license.js"]); }; @@ -357,3 +361,38 @@ target["test"] = function () { target["test-only"] = function (args = []) { yarn(["jest", ...args]); }; + +/** + * PUBLISH + */ + +target["new-version-checklist"] = function () { + if (0) { + throw new Error( + ` +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!!!!! !!!!!! +!!!!!! Write any message that should !!!!!! +!!!!!! block the release here !!!!!! +!!!!!! !!!!!! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + `.trim() + ); + } +}; + +target["new-version"] = function () { + target["new-version-checklist"](); + + exec("git", ["pull", "--rebase"]); + yarn(["release-tool", "version", "-f", "@babel/standalone"]); +}; + +target["new-version"] = function () { + target["new-version-checklist"](); + + exec("git", ["pull", "--rebase"]); + yarn(["release-tool", "version", "-f", "@babel/standalone"]); +}; From a2b8d46386e039c161d85e7d744e6b23594dc552 Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Sat, 16 Jul 2022 20:24:19 +0800 Subject: [PATCH 10/12] fix node6 --- .github/workflows/ci.yml | 3 + Makefile | 2 +- Makefile.js | 9728 ++++++++++++++++++++++++++++++++++++++ Makefile.mjs | 7851 ------------------------------ Makefile.source.mjs | 11 +- make.cmd | 2 +- package.json | 1 + scripts/pack-script.js | 21 +- yarn.lock | 9 +- 9 files changed, 9763 insertions(+), 7865 deletions(-) create mode 100644 Makefile.js delete mode 100644 Makefile.mjs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ce464e14c925..91fd9f174b4f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -114,6 +114,9 @@ jobs: env: BABEL_8_BREAKING: false STRIP_BABEL_8_FLAG: true + - name: Build Makefile.js + run: | + node ./scripts/pack-script.js - name: Ensure cwd does not contain uncommitted changes run: | node ./scripts/assert-dir-git-clean.js diff --git a/Makefile b/Makefile index 5d1fba878a15..38501d428df8 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ COMMA_SEPARATED_SOURCES = $(subst $(SPACE),$(COMMA),$(SOURCES)) YARN := yarn NODE := $(YARN) node -MAKEJS := node Makefile.mjs +MAKEJS := node Makefile.js .PHONY: build build-dist watch lint fix clean test-clean test-only test test-ci publish bootstrap use-esm use-cjs diff --git a/Makefile.js b/Makefile.js new file mode 100644 index 000000000000..232569aaf823 --- /dev/null +++ b/Makefile.js @@ -0,0 +1,9728 @@ +/* eslint-disable */ + //prettier-ignore + 'use strict'; + +var require$$0 = require('os'); +var require$$1 = require('fs'); +var require$$2 = require('path'); +var require$$4 = require('events'); +var require$$6 = require('assert'); +var require$$4$1 = require('util'); +var require$$0$1 = require('child_process'); + +function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + +var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0); +var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1); +var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2); +var require$$4__default = /*#__PURE__*/_interopDefaultLegacy(require$$4); +var require$$6__default = /*#__PURE__*/_interopDefaultLegacy(require$$6); +var require$$4__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$4$1); +var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1); + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +var check = function (it) { + return it && it.Math == Math && it; +}; + +// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 +var global$f = + // eslint-disable-next-line es-x/no-global-this -- safe + check(typeof globalThis == 'object' && globalThis) || + check(typeof window == 'object' && window) || + // eslint-disable-next-line no-restricted-globals -- safe + check(typeof self == 'object' && self) || + check(typeof commonjsGlobal == 'object' && commonjsGlobal) || + // eslint-disable-next-line no-new-func -- fallback + (function () { return this; })() || Function('return this')(); + +var objectGetOwnPropertyDescriptor = {}; + +var fails$p = function (exec) { + try { + return !!exec(); + } catch (error) { + return true; + } +}; + +var fails$o = fails$p; + +// Detect IE8's incomplete defineProperty implementation +var descriptors = !fails$o(function () { + // eslint-disable-next-line es-x/no-object-defineproperty -- required for testing + return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7; +}); + +var fails$n = fails$p; + +var functionBindNative = !fails$n(function () { + // eslint-disable-next-line es-x/no-function-prototype-bind -- safe + var test = (function () { /* empty */ }).bind(); + // eslint-disable-next-line no-prototype-builtins -- safe + return typeof test != 'function' || test.hasOwnProperty('prototype'); +}); + +var NATIVE_BIND$3 = functionBindNative; + +var call$f = Function.prototype.call; + +var functionCall = NATIVE_BIND$3 ? call$f.bind(call$f) : function () { + return call$f.apply(call$f, arguments); +}; + +var objectPropertyIsEnumerable = {}; + +var $propertyIsEnumerable = {}.propertyIsEnumerable; +// eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe +var getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor; + +// Nashorn ~ JDK8 bug +var NASHORN_BUG = getOwnPropertyDescriptor$1 && !$propertyIsEnumerable.call({ 1: 2 }, 1); + +// `Object.prototype.propertyIsEnumerable` method implementation +// https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable +objectPropertyIsEnumerable.f = NASHORN_BUG ? function propertyIsEnumerable(V) { + var descriptor = getOwnPropertyDescriptor$1(this, V); + return !!descriptor && descriptor.enumerable; +} : $propertyIsEnumerable; + +var createPropertyDescriptor$5 = function (bitmap, value) { + return { + enumerable: !(bitmap & 1), + configurable: !(bitmap & 2), + writable: !(bitmap & 4), + value: value + }; +}; + +var NATIVE_BIND$2 = functionBindNative; + +var FunctionPrototype$2 = Function.prototype; +var bind$2 = FunctionPrototype$2.bind; +var call$e = FunctionPrototype$2.call; +var uncurryThis$s = NATIVE_BIND$2 && bind$2.bind(call$e, call$e); + +var functionUncurryThis = NATIVE_BIND$2 ? function (fn) { + return fn && uncurryThis$s(fn); +} : function (fn) { + return fn && function () { + return call$e.apply(fn, arguments); + }; +}; + +var uncurryThis$r = functionUncurryThis; + +var toString$c = uncurryThis$r({}.toString); +var stringSlice$7 = uncurryThis$r(''.slice); + +var classofRaw$1 = function (it) { + return stringSlice$7(toString$c(it), 8, -1); +}; + +var uncurryThis$q = functionUncurryThis; +var fails$m = fails$p; +var classof$7 = classofRaw$1; + +var $Object$4 = Object; +var split = uncurryThis$q(''.split); + +// fallback for non-array-like ES3 and non-enumerable old V8 strings +var indexedObject = fails$m(function () { + // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346 + // eslint-disable-next-line no-prototype-builtins -- safe + return !$Object$4('z').propertyIsEnumerable(0); +}) ? function (it) { + return classof$7(it) == 'String' ? split(it, '') : $Object$4(it); +} : $Object$4; + +var $TypeError$d = TypeError; + +// `RequireObjectCoercible` abstract operation +// https://tc39.es/ecma262/#sec-requireobjectcoercible +var requireObjectCoercible$8 = function (it) { + if (it == undefined) throw $TypeError$d("Can't call method on " + it); + return it; +}; + +// toObject with fallback for non-array-like ES3 strings +var IndexedObject$1 = indexedObject; +var requireObjectCoercible$7 = requireObjectCoercible$8; + +var toIndexedObject$6 = function (it) { + return IndexedObject$1(requireObjectCoercible$7(it)); +}; + +// `IsCallable` abstract operation +// https://tc39.es/ecma262/#sec-iscallable +var isCallable$m = function (argument) { + return typeof argument == 'function'; +}; + +var isCallable$l = isCallable$m; + +var isObject$d = function (it) { + return typeof it == 'object' ? it !== null : isCallable$l(it); +}; + +var global$e = global$f; +var isCallable$k = isCallable$m; + +var aFunction = function (argument) { + return isCallable$k(argument) ? argument : undefined; +}; + +var getBuiltIn$8 = function (namespace, method) { + return arguments.length < 2 ? aFunction(global$e[namespace]) : global$e[namespace] && global$e[namespace][method]; +}; + +var uncurryThis$p = functionUncurryThis; + +var objectIsPrototypeOf = uncurryThis$p({}.isPrototypeOf); + +var getBuiltIn$7 = getBuiltIn$8; + +var engineUserAgent = getBuiltIn$7('navigator', 'userAgent') || ''; + +var global$d = global$f; +var userAgent$2 = engineUserAgent; + +var process$1 = global$d.process; +var Deno = global$d.Deno; +var versions = process$1 && process$1.versions || Deno && Deno.version; +var v8 = versions && versions.v8; +var match, version; + +if (v8) { + match = v8.split('.'); + // in old Chrome, versions of V8 isn't V8 = Chrome / 10 + // but their correct versions are not interesting for us + version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]); +} + +// BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0` +// so check `userAgent` even if `.v8` exists, but 0 +if (!version && userAgent$2) { + match = userAgent$2.match(/Edge\/(\d+)/); + if (!match || match[1] >= 74) { + match = userAgent$2.match(/Chrome\/(\d+)/); + if (match) version = +match[1]; + } +} + +var engineV8Version = version; + +/* eslint-disable es-x/no-symbol -- required for testing */ + +var V8_VERSION$2 = engineV8Version; +var fails$l = fails$p; + +// eslint-disable-next-line es-x/no-object-getownpropertysymbols -- required for testing +var nativeSymbol = !!Object.getOwnPropertySymbols && !fails$l(function () { + var symbol = Symbol(); + // Chrome 38 Symbol has incorrect toString conversion + // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances + return !String(symbol) || !(Object(symbol) instanceof Symbol) || + // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances + !Symbol.sham && V8_VERSION$2 && V8_VERSION$2 < 41; +}); + +/* eslint-disable es-x/no-symbol -- required for testing */ + +var NATIVE_SYMBOL$2 = nativeSymbol; + +var useSymbolAsUid = NATIVE_SYMBOL$2 + && !Symbol.sham + && typeof Symbol.iterator == 'symbol'; + +var getBuiltIn$6 = getBuiltIn$8; +var isCallable$j = isCallable$m; +var isPrototypeOf$3 = objectIsPrototypeOf; +var USE_SYMBOL_AS_UID$1 = useSymbolAsUid; + +var $Object$3 = Object; + +var isSymbol$3 = USE_SYMBOL_AS_UID$1 ? function (it) { + return typeof it == 'symbol'; +} : function (it) { + var $Symbol = getBuiltIn$6('Symbol'); + return isCallable$j($Symbol) && isPrototypeOf$3($Symbol.prototype, $Object$3(it)); +}; + +var $String$3 = String; + +var tryToString$3 = function (argument) { + try { + return $String$3(argument); + } catch (error) { + return 'Object'; + } +}; + +var isCallable$i = isCallable$m; +var tryToString$2 = tryToString$3; + +var $TypeError$c = TypeError; + +// `Assert: IsCallable(argument) is true` +var aCallable$3 = function (argument) { + if (isCallable$i(argument)) return argument; + throw $TypeError$c(tryToString$2(argument) + ' is not a function'); +}; + +var aCallable$2 = aCallable$3; + +// `GetMethod` abstract operation +// https://tc39.es/ecma262/#sec-getmethod +var getMethod$5 = function (V, P) { + var func = V[P]; + return func == null ? undefined : aCallable$2(func); +}; + +var call$d = functionCall; +var isCallable$h = isCallable$m; +var isObject$c = isObject$d; + +var $TypeError$b = TypeError; + +// `OrdinaryToPrimitive` abstract operation +// https://tc39.es/ecma262/#sec-ordinarytoprimitive +var ordinaryToPrimitive$1 = function (input, pref) { + var fn, val; + if (pref === 'string' && isCallable$h(fn = input.toString) && !isObject$c(val = call$d(fn, input))) return val; + if (isCallable$h(fn = input.valueOf) && !isObject$c(val = call$d(fn, input))) return val; + if (pref !== 'string' && isCallable$h(fn = input.toString) && !isObject$c(val = call$d(fn, input))) return val; + throw $TypeError$b("Can't convert object to primitive value"); +}; + +var shared$4 = {exports: {}}; + +var global$c = global$f; + +// eslint-disable-next-line es-x/no-object-defineproperty -- safe +var defineProperty$6 = Object.defineProperty; + +var defineGlobalProperty$3 = function (key, value) { + try { + defineProperty$6(global$c, key, { value: value, configurable: true, writable: true }); + } catch (error) { + global$c[key] = value; + } return value; +}; + +var global$b = global$f; +var defineGlobalProperty$2 = defineGlobalProperty$3; + +var SHARED = '__core-js_shared__'; +var store$3 = global$b[SHARED] || defineGlobalProperty$2(SHARED, {}); + +var sharedStore = store$3; + +var store$2 = sharedStore; + +(shared$4.exports = function (key, value) { + return store$2[key] || (store$2[key] = value !== undefined ? value : {}); +})('versions', []).push({ + version: '3.23.4', + mode: 'global', + copyright: '© 2014-2022 Denis Pushkarev (zloirock.ru)', + license: 'https://github.com/zloirock/core-js/blob/v3.23.4/LICENSE', + source: 'https://github.com/zloirock/core-js' +}); + +var requireObjectCoercible$6 = requireObjectCoercible$8; + +var $Object$2 = Object; + +// `ToObject` abstract operation +// https://tc39.es/ecma262/#sec-toobject +var toObject$7 = function (argument) { + return $Object$2(requireObjectCoercible$6(argument)); +}; + +var uncurryThis$o = functionUncurryThis; +var toObject$6 = toObject$7; + +var hasOwnProperty = uncurryThis$o({}.hasOwnProperty); + +// `HasOwnProperty` abstract operation +// https://tc39.es/ecma262/#sec-hasownproperty +// eslint-disable-next-line es-x/no-object-hasown -- safe +var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) { + return hasOwnProperty(toObject$6(it), key); +}; + +var uncurryThis$n = functionUncurryThis; + +var id = 0; +var postfix = Math.random(); +var toString$b = uncurryThis$n(1.0.toString); + +var uid$2 = function (key) { + return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$b(++id + postfix, 36); +}; + +var global$a = global$f; +var shared$3 = shared$4.exports; +var hasOwn$b = hasOwnProperty_1; +var uid$1 = uid$2; +var NATIVE_SYMBOL$1 = nativeSymbol; +var USE_SYMBOL_AS_UID = useSymbolAsUid; + +var WellKnownSymbolsStore = shared$3('wks'); +var Symbol$1 = global$a.Symbol; +var symbolFor = Symbol$1 && Symbol$1['for']; +var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid$1; + +var wellKnownSymbol$i = function (name) { + if (!hasOwn$b(WellKnownSymbolsStore, name) || !(NATIVE_SYMBOL$1 || typeof WellKnownSymbolsStore[name] == 'string')) { + var description = 'Symbol.' + name; + if (NATIVE_SYMBOL$1 && hasOwn$b(Symbol$1, name)) { + WellKnownSymbolsStore[name] = Symbol$1[name]; + } else if (USE_SYMBOL_AS_UID && symbolFor) { + WellKnownSymbolsStore[name] = symbolFor(description); + } else { + WellKnownSymbolsStore[name] = createWellKnownSymbol(description); + } + } return WellKnownSymbolsStore[name]; +}; + +var call$c = functionCall; +var isObject$b = isObject$d; +var isSymbol$2 = isSymbol$3; +var getMethod$4 = getMethod$5; +var ordinaryToPrimitive = ordinaryToPrimitive$1; +var wellKnownSymbol$h = wellKnownSymbol$i; + +var $TypeError$a = TypeError; +var TO_PRIMITIVE = wellKnownSymbol$h('toPrimitive'); + +// `ToPrimitive` abstract operation +// https://tc39.es/ecma262/#sec-toprimitive +var toPrimitive$1 = function (input, pref) { + if (!isObject$b(input) || isSymbol$2(input)) return input; + var exoticToPrim = getMethod$4(input, TO_PRIMITIVE); + var result; + if (exoticToPrim) { + if (pref === undefined) pref = 'default'; + result = call$c(exoticToPrim, input, pref); + if (!isObject$b(result) || isSymbol$2(result)) return result; + throw $TypeError$a("Can't convert object to primitive value"); + } + if (pref === undefined) pref = 'number'; + return ordinaryToPrimitive(input, pref); +}; + +var toPrimitive = toPrimitive$1; +var isSymbol$1 = isSymbol$3; + +// `ToPropertyKey` abstract operation +// https://tc39.es/ecma262/#sec-topropertykey +var toPropertyKey$3 = function (argument) { + var key = toPrimitive(argument, 'string'); + return isSymbol$1(key) ? key : key + ''; +}; + +var global$9 = global$f; +var isObject$a = isObject$d; + +var document$1 = global$9.document; +// typeof document.createElement is 'object' in old IE +var EXISTS$1 = isObject$a(document$1) && isObject$a(document$1.createElement); + +var documentCreateElement$1 = function (it) { + return EXISTS$1 ? document$1.createElement(it) : {}; +}; + +var DESCRIPTORS$c = descriptors; +var fails$k = fails$p; +var createElement = documentCreateElement$1; + +// Thanks to IE8 for its funny defineProperty +var ie8DomDefine = !DESCRIPTORS$c && !fails$k(function () { + // eslint-disable-next-line es-x/no-object-defineproperty -- required for testing + return Object.defineProperty(createElement('div'), 'a', { + get: function () { return 7; } + }).a != 7; +}); + +var DESCRIPTORS$b = descriptors; +var call$b = functionCall; +var propertyIsEnumerableModule = objectPropertyIsEnumerable; +var createPropertyDescriptor$4 = createPropertyDescriptor$5; +var toIndexedObject$5 = toIndexedObject$6; +var toPropertyKey$2 = toPropertyKey$3; +var hasOwn$a = hasOwnProperty_1; +var IE8_DOM_DEFINE$1 = ie8DomDefine; + +// eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe +var $getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor; + +// `Object.getOwnPropertyDescriptor` method +// https://tc39.es/ecma262/#sec-object.getownpropertydescriptor +objectGetOwnPropertyDescriptor.f = DESCRIPTORS$b ? $getOwnPropertyDescriptor$1 : function getOwnPropertyDescriptor(O, P) { + O = toIndexedObject$5(O); + P = toPropertyKey$2(P); + if (IE8_DOM_DEFINE$1) try { + return $getOwnPropertyDescriptor$1(O, P); + } catch (error) { /* empty */ } + if (hasOwn$a(O, P)) return createPropertyDescriptor$4(!call$b(propertyIsEnumerableModule.f, O, P), O[P]); +}; + +var objectDefineProperty = {}; + +var DESCRIPTORS$a = descriptors; +var fails$j = fails$p; + +// V8 ~ Chrome 36- +// https://bugs.chromium.org/p/v8/issues/detail?id=3334 +var v8PrototypeDefineBug = DESCRIPTORS$a && fails$j(function () { + // eslint-disable-next-line es-x/no-object-defineproperty -- required for testing + return Object.defineProperty(function () { /* empty */ }, 'prototype', { + value: 42, + writable: false + }).prototype != 42; +}); + +var isObject$9 = isObject$d; + +var $String$2 = String; +var $TypeError$9 = TypeError; + +// `Assert: Type(argument) is Object` +var anObject$b = function (argument) { + if (isObject$9(argument)) return argument; + throw $TypeError$9($String$2(argument) + ' is not an object'); +}; + +var DESCRIPTORS$9 = descriptors; +var IE8_DOM_DEFINE = ie8DomDefine; +var V8_PROTOTYPE_DEFINE_BUG$1 = v8PrototypeDefineBug; +var anObject$a = anObject$b; +var toPropertyKey$1 = toPropertyKey$3; + +var $TypeError$8 = TypeError; +// eslint-disable-next-line es-x/no-object-defineproperty -- safe +var $defineProperty = Object.defineProperty; +// eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe +var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; +var ENUMERABLE = 'enumerable'; +var CONFIGURABLE$1 = 'configurable'; +var WRITABLE = 'writable'; + +// `Object.defineProperty` method +// https://tc39.es/ecma262/#sec-object.defineproperty +objectDefineProperty.f = DESCRIPTORS$9 ? V8_PROTOTYPE_DEFINE_BUG$1 ? function defineProperty(O, P, Attributes) { + anObject$a(O); + P = toPropertyKey$1(P); + anObject$a(Attributes); + if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) { + var current = $getOwnPropertyDescriptor(O, P); + if (current && current[WRITABLE]) { + O[P] = Attributes.value; + Attributes = { + configurable: CONFIGURABLE$1 in Attributes ? Attributes[CONFIGURABLE$1] : current[CONFIGURABLE$1], + enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE], + writable: false + }; + } + } return $defineProperty(O, P, Attributes); +} : $defineProperty : function defineProperty(O, P, Attributes) { + anObject$a(O); + P = toPropertyKey$1(P); + anObject$a(Attributes); + if (IE8_DOM_DEFINE) try { + return $defineProperty(O, P, Attributes); + } catch (error) { /* empty */ } + if ('get' in Attributes || 'set' in Attributes) throw $TypeError$8('Accessors not supported'); + if ('value' in Attributes) O[P] = Attributes.value; + return O; +}; + +var DESCRIPTORS$8 = descriptors; +var definePropertyModule$5 = objectDefineProperty; +var createPropertyDescriptor$3 = createPropertyDescriptor$5; + +var createNonEnumerableProperty$7 = DESCRIPTORS$8 ? function (object, key, value) { + return definePropertyModule$5.f(object, key, createPropertyDescriptor$3(1, value)); +} : function (object, key, value) { + object[key] = value; + return object; +}; + +var makeBuiltIn$3 = {exports: {}}; + +var DESCRIPTORS$7 = descriptors; +var hasOwn$9 = hasOwnProperty_1; + +var FunctionPrototype$1 = Function.prototype; +// eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe +var getDescriptor = DESCRIPTORS$7 && Object.getOwnPropertyDescriptor; + +var EXISTS = hasOwn$9(FunctionPrototype$1, 'name'); +// additional protection from minified / mangled / dropped function names +var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something'; +var CONFIGURABLE = EXISTS && (!DESCRIPTORS$7 || (DESCRIPTORS$7 && getDescriptor(FunctionPrototype$1, 'name').configurable)); + +var functionName = { + EXISTS: EXISTS, + PROPER: PROPER, + CONFIGURABLE: CONFIGURABLE +}; + +var uncurryThis$m = functionUncurryThis; +var isCallable$g = isCallable$m; +var store$1 = sharedStore; + +var functionToString = uncurryThis$m(Function.toString); + +// this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper +if (!isCallable$g(store$1.inspectSource)) { + store$1.inspectSource = function (it) { + return functionToString(it); + }; +} + +var inspectSource$3 = store$1.inspectSource; + +var global$8 = global$f; +var isCallable$f = isCallable$m; +var inspectSource$2 = inspectSource$3; + +var WeakMap$1 = global$8.WeakMap; + +var nativeWeakMap = isCallable$f(WeakMap$1) && /native code/.test(inspectSource$2(WeakMap$1)); + +var shared$2 = shared$4.exports; +var uid = uid$2; + +var keys$1 = shared$2('keys'); + +var sharedKey$3 = function (key) { + return keys$1[key] || (keys$1[key] = uid(key)); +}; + +var hiddenKeys$4 = {}; + +var NATIVE_WEAK_MAP = nativeWeakMap; +var global$7 = global$f; +var uncurryThis$l = functionUncurryThis; +var isObject$8 = isObject$d; +var createNonEnumerableProperty$6 = createNonEnumerableProperty$7; +var hasOwn$8 = hasOwnProperty_1; +var shared$1 = sharedStore; +var sharedKey$2 = sharedKey$3; +var hiddenKeys$3 = hiddenKeys$4; + +var OBJECT_ALREADY_INITIALIZED = 'Object already initialized'; +var TypeError$1 = global$7.TypeError; +var WeakMap = global$7.WeakMap; +var set$1, get, has; + +var enforce = function (it) { + return has(it) ? get(it) : set$1(it, {}); +}; + +var getterFor = function (TYPE) { + return function (it) { + var state; + if (!isObject$8(it) || (state = get(it)).type !== TYPE) { + throw TypeError$1('Incompatible receiver, ' + TYPE + ' required'); + } return state; + }; +}; + +if (NATIVE_WEAK_MAP || shared$1.state) { + var store = shared$1.state || (shared$1.state = new WeakMap()); + var wmget = uncurryThis$l(store.get); + var wmhas = uncurryThis$l(store.has); + var wmset = uncurryThis$l(store.set); + set$1 = function (it, metadata) { + if (wmhas(store, it)) throw new TypeError$1(OBJECT_ALREADY_INITIALIZED); + metadata.facade = it; + wmset(store, it, metadata); + return metadata; + }; + get = function (it) { + return wmget(store, it) || {}; + }; + has = function (it) { + return wmhas(store, it); + }; +} else { + var STATE = sharedKey$2('state'); + hiddenKeys$3[STATE] = true; + set$1 = function (it, metadata) { + if (hasOwn$8(it, STATE)) throw new TypeError$1(OBJECT_ALREADY_INITIALIZED); + metadata.facade = it; + createNonEnumerableProperty$6(it, STATE, metadata); + return metadata; + }; + get = function (it) { + return hasOwn$8(it, STATE) ? it[STATE] : {}; + }; + has = function (it) { + return hasOwn$8(it, STATE); + }; +} + +var internalState = { + set: set$1, + get: get, + has: has, + enforce: enforce, + getterFor: getterFor +}; + +var fails$i = fails$p; +var isCallable$e = isCallable$m; +var hasOwn$7 = hasOwnProperty_1; +var DESCRIPTORS$6 = descriptors; +var CONFIGURABLE_FUNCTION_NAME$1 = functionName.CONFIGURABLE; +var inspectSource$1 = inspectSource$3; +var InternalStateModule$1 = internalState; + +var enforceInternalState$1 = InternalStateModule$1.enforce; +var getInternalState$3 = InternalStateModule$1.get; +// eslint-disable-next-line es-x/no-object-defineproperty -- safe +var defineProperty$5 = Object.defineProperty; + +var CONFIGURABLE_LENGTH = DESCRIPTORS$6 && !fails$i(function () { + return defineProperty$5(function () { /* empty */ }, 'length', { value: 8 }).length !== 8; +}); + +var TEMPLATE = String(String).split('String'); + +var makeBuiltIn$2 = makeBuiltIn$3.exports = function (value, name, options) { + if (String(name).slice(0, 7) === 'Symbol(') { + name = '[' + String(name).replace(/^Symbol\(([^)]*)\)/, '$1') + ']'; + } + if (options && options.getter) name = 'get ' + name; + if (options && options.setter) name = 'set ' + name; + if (!hasOwn$7(value, 'name') || (CONFIGURABLE_FUNCTION_NAME$1 && value.name !== name)) { + if (DESCRIPTORS$6) defineProperty$5(value, 'name', { value: name, configurable: true }); + else value.name = name; + } + if (CONFIGURABLE_LENGTH && options && hasOwn$7(options, 'arity') && value.length !== options.arity) { + defineProperty$5(value, 'length', { value: options.arity }); + } + try { + if (options && hasOwn$7(options, 'constructor') && options.constructor) { + if (DESCRIPTORS$6) defineProperty$5(value, 'prototype', { writable: false }); + // in V8 ~ Chrome 53, prototypes of some methods, like `Array.prototype.values`, are non-writable + } else if (value.prototype) value.prototype = undefined; + } catch (error) { /* empty */ } + var state = enforceInternalState$1(value); + if (!hasOwn$7(state, 'source')) { + state.source = TEMPLATE.join(typeof name == 'string' ? name : ''); + } return value; +}; + +// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative +// eslint-disable-next-line no-extend-native -- required +Function.prototype.toString = makeBuiltIn$2(function toString() { + return isCallable$e(this) && getInternalState$3(this).source || inspectSource$1(this); +}, 'toString'); + +var isCallable$d = isCallable$m; +var definePropertyModule$4 = objectDefineProperty; +var makeBuiltIn$1 = makeBuiltIn$3.exports; +var defineGlobalProperty$1 = defineGlobalProperty$3; + +var defineBuiltIn$5 = function (O, key, value, options) { + if (!options) options = {}; + var simple = options.enumerable; + var name = options.name !== undefined ? options.name : key; + if (isCallable$d(value)) makeBuiltIn$1(value, name, options); + if (options.global) { + if (simple) O[key] = value; + else defineGlobalProperty$1(key, value); + } else { + try { + if (!options.unsafe) delete O[key]; + else if (O[key]) simple = true; + } catch (error) { /* empty */ } + if (simple) O[key] = value; + else definePropertyModule$4.f(O, key, { + value: value, + enumerable: false, + configurable: !options.nonConfigurable, + writable: !options.nonWritable + }); + } return O; +}; + +var objectGetOwnPropertyNames = {}; + +var ceil = Math.ceil; +var floor$2 = Math.floor; + +// `Math.trunc` method +// https://tc39.es/ecma262/#sec-math.trunc +// eslint-disable-next-line es-x/no-math-trunc -- safe +var mathTrunc = Math.trunc || function trunc(x) { + var n = +x; + return (n > 0 ? floor$2 : ceil)(n); +}; + +var trunc = mathTrunc; + +// `ToIntegerOrInfinity` abstract operation +// https://tc39.es/ecma262/#sec-tointegerorinfinity +var toIntegerOrInfinity$5 = function (argument) { + var number = +argument; + // eslint-disable-next-line no-self-compare -- NaN check + return number !== number || number === 0 ? 0 : trunc(number); +}; + +var toIntegerOrInfinity$4 = toIntegerOrInfinity$5; + +var max$5 = Math.max; +var min$4 = Math.min; + +// Helper for a popular repeating case of the spec: +// Let integer be ? ToInteger(index). +// If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length). +var toAbsoluteIndex$4 = function (index, length) { + var integer = toIntegerOrInfinity$4(index); + return integer < 0 ? max$5(integer + length, 0) : min$4(integer, length); +}; + +var toIntegerOrInfinity$3 = toIntegerOrInfinity$5; + +var min$3 = Math.min; + +// `ToLength` abstract operation +// https://tc39.es/ecma262/#sec-tolength +var toLength$4 = function (argument) { + return argument > 0 ? min$3(toIntegerOrInfinity$3(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991 +}; + +var toLength$3 = toLength$4; + +// `LengthOfArrayLike` abstract operation +// https://tc39.es/ecma262/#sec-lengthofarraylike +var lengthOfArrayLike$7 = function (obj) { + return toLength$3(obj.length); +}; + +var toIndexedObject$4 = toIndexedObject$6; +var toAbsoluteIndex$3 = toAbsoluteIndex$4; +var lengthOfArrayLike$6 = lengthOfArrayLike$7; + +// `Array.prototype.{ indexOf, includes }` methods implementation +var createMethod$3 = function (IS_INCLUDES) { + return function ($this, el, fromIndex) { + var O = toIndexedObject$4($this); + var length = lengthOfArrayLike$6(O); + var index = toAbsoluteIndex$3(fromIndex, length); + var value; + // Array#includes uses SameValueZero equality algorithm + // eslint-disable-next-line no-self-compare -- NaN check + if (IS_INCLUDES && el != el) while (length > index) { + value = O[index++]; + // eslint-disable-next-line no-self-compare -- NaN check + if (value != value) return true; + // Array#indexOf ignores holes, Array#includes - not + } else for (;length > index; index++) { + if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0; + } return !IS_INCLUDES && -1; + }; +}; + +var arrayIncludes = { + // `Array.prototype.includes` method + // https://tc39.es/ecma262/#sec-array.prototype.includes + includes: createMethod$3(true), + // `Array.prototype.indexOf` method + // https://tc39.es/ecma262/#sec-array.prototype.indexof + indexOf: createMethod$3(false) +}; + +var uncurryThis$k = functionUncurryThis; +var hasOwn$6 = hasOwnProperty_1; +var toIndexedObject$3 = toIndexedObject$6; +var indexOf$2 = arrayIncludes.indexOf; +var hiddenKeys$2 = hiddenKeys$4; + +var push$4 = uncurryThis$k([].push); + +var objectKeysInternal = function (object, names) { + var O = toIndexedObject$3(object); + var i = 0; + var result = []; + var key; + for (key in O) !hasOwn$6(hiddenKeys$2, key) && hasOwn$6(O, key) && push$4(result, key); + // Don't enum bug & hidden keys + while (names.length > i) if (hasOwn$6(O, key = names[i++])) { + ~indexOf$2(result, key) || push$4(result, key); + } + return result; +}; + +// IE8- don't enum bug keys +var enumBugKeys$3 = [ + 'constructor', + 'hasOwnProperty', + 'isPrototypeOf', + 'propertyIsEnumerable', + 'toLocaleString', + 'toString', + 'valueOf' +]; + +var internalObjectKeys$1 = objectKeysInternal; +var enumBugKeys$2 = enumBugKeys$3; + +var hiddenKeys$1 = enumBugKeys$2.concat('length', 'prototype'); + +// `Object.getOwnPropertyNames` method +// https://tc39.es/ecma262/#sec-object.getownpropertynames +// eslint-disable-next-line es-x/no-object-getownpropertynames -- safe +objectGetOwnPropertyNames.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { + return internalObjectKeys$1(O, hiddenKeys$1); +}; + +var objectGetOwnPropertySymbols = {}; + +// eslint-disable-next-line es-x/no-object-getownpropertysymbols -- safe +objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols; + +var getBuiltIn$5 = getBuiltIn$8; +var uncurryThis$j = functionUncurryThis; +var getOwnPropertyNamesModule = objectGetOwnPropertyNames; +var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols; +var anObject$9 = anObject$b; + +var concat$1 = uncurryThis$j([].concat); + +// all object keys, includes non-enumerable and symbols +var ownKeys$1 = getBuiltIn$5('Reflect', 'ownKeys') || function ownKeys(it) { + var keys = getOwnPropertyNamesModule.f(anObject$9(it)); + var getOwnPropertySymbols = getOwnPropertySymbolsModule.f; + return getOwnPropertySymbols ? concat$1(keys, getOwnPropertySymbols(it)) : keys; +}; + +var hasOwn$5 = hasOwnProperty_1; +var ownKeys = ownKeys$1; +var getOwnPropertyDescriptorModule = objectGetOwnPropertyDescriptor; +var definePropertyModule$3 = objectDefineProperty; + +var copyConstructorProperties$2 = function (target, source, exceptions) { + var keys = ownKeys(source); + var defineProperty = definePropertyModule$3.f; + var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f; + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + if (!hasOwn$5(target, key) && !(exceptions && hasOwn$5(exceptions, key))) { + defineProperty(target, key, getOwnPropertyDescriptor(source, key)); + } + } +}; + +var fails$h = fails$p; +var isCallable$c = isCallable$m; + +var replacement = /#|\.prototype\./; + +var isForced$2 = function (feature, detection) { + var value = data[normalize$1(feature)]; + return value == POLYFILL ? true + : value == NATIVE ? false + : isCallable$c(detection) ? fails$h(detection) + : !!detection; +}; + +var normalize$1 = isForced$2.normalize = function (string) { + return String(string).replace(replacement, '.').toLowerCase(); +}; + +var data = isForced$2.data = {}; +var NATIVE = isForced$2.NATIVE = 'N'; +var POLYFILL = isForced$2.POLYFILL = 'P'; + +var isForced_1 = isForced$2; + +var global$6 = global$f; +var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f; +var createNonEnumerableProperty$5 = createNonEnumerableProperty$7; +var defineBuiltIn$4 = defineBuiltIn$5; +var defineGlobalProperty = defineGlobalProperty$3; +var copyConstructorProperties$1 = copyConstructorProperties$2; +var isForced$1 = isForced_1; + +/* + options.target - name of the target object + options.global - target is the global object + options.stat - export as static methods of target + options.proto - export as prototype methods of target + options.real - real prototype method for the `pure` version + options.forced - export even if the native feature is available + options.bind - bind methods to the target, required for the `pure` version + options.wrap - wrap constructors to preventing global pollution, required for the `pure` version + options.unsafe - use the simple assignment of property instead of delete + defineProperty + options.sham - add a flag to not completely full polyfills + options.enumerable - export as enumerable property + options.dontCallGetSet - prevent calling a getter on target + options.name - the .name of the function if it does not match the key +*/ +var _export = function (options, source) { + var TARGET = options.target; + var GLOBAL = options.global; + var STATIC = options.stat; + var FORCED, target, key, targetProperty, sourceProperty, descriptor; + if (GLOBAL) { + target = global$6; + } else if (STATIC) { + target = global$6[TARGET] || defineGlobalProperty(TARGET, {}); + } else { + target = (global$6[TARGET] || {}).prototype; + } + if (target) for (key in source) { + sourceProperty = source[key]; + if (options.dontCallGetSet) { + descriptor = getOwnPropertyDescriptor(target, key); + targetProperty = descriptor && descriptor.value; + } else targetProperty = target[key]; + FORCED = isForced$1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced); + // contained in target + if (!FORCED && targetProperty !== undefined) { + if (typeof sourceProperty == typeof targetProperty) continue; + copyConstructorProperties$1(sourceProperty, targetProperty); + } + // add a flag to not completely full polyfills + if (options.sham || (targetProperty && targetProperty.sham)) { + createNonEnumerableProperty$5(sourceProperty, 'sham', true); + } + defineBuiltIn$4(target, key, sourceProperty, options); + } +}; + +var wellKnownSymbol$g = wellKnownSymbol$i; + +var TO_STRING_TAG$2 = wellKnownSymbol$g('toStringTag'); +var test$2 = {}; + +test$2[TO_STRING_TAG$2] = 'z'; + +var toStringTagSupport = String(test$2) === '[object z]'; + +var TO_STRING_TAG_SUPPORT = toStringTagSupport; +var isCallable$b = isCallable$m; +var classofRaw = classofRaw$1; +var wellKnownSymbol$f = wellKnownSymbol$i; + +var TO_STRING_TAG$1 = wellKnownSymbol$f('toStringTag'); +var $Object$1 = Object; + +// ES3 wrong here +var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments'; + +// fallback for IE11 Script Access Denied error +var tryGet = function (it, key) { + try { + return it[key]; + } catch (error) { /* empty */ } +}; + +// getting tag from ES6+ `Object.prototype.toString` +var classof$6 = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) { + var O, tag, result; + return it === undefined ? 'Undefined' : it === null ? 'Null' + // @@toStringTag case + : typeof (tag = tryGet(O = $Object$1(it), TO_STRING_TAG$1)) == 'string' ? tag + // builtinTag case + : CORRECT_ARGUMENTS ? classofRaw(O) + // ES3 arguments fallback + : (result = classofRaw(O)) == 'Object' && isCallable$b(O.callee) ? 'Arguments' : result; +}; + +var classof$5 = classof$6; + +var $String$1 = String; + +var toString$a = function (argument) { + if (classof$5(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string'); + return $String$1(argument); +}; + +var anObject$8 = anObject$b; + +// `RegExp.prototype.flags` getter implementation +// https://tc39.es/ecma262/#sec-get-regexp.prototype.flags +var regexpFlags$1 = function () { + var that = anObject$8(this); + var result = ''; + if (that.hasIndices) result += 'd'; + if (that.global) result += 'g'; + if (that.ignoreCase) result += 'i'; + if (that.multiline) result += 'm'; + if (that.dotAll) result += 's'; + if (that.unicode) result += 'u'; + if (that.unicodeSets) result += 'v'; + if (that.sticky) result += 'y'; + return result; +}; + +var fails$g = fails$p; +var global$5 = global$f; + +// babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError +var $RegExp$2 = global$5.RegExp; + +var UNSUPPORTED_Y$3 = fails$g(function () { + var re = $RegExp$2('a', 'y'); + re.lastIndex = 2; + return re.exec('abcd') != null; +}); + +// UC Browser bug +// https://github.com/zloirock/core-js/issues/1008 +var MISSED_STICKY$1 = UNSUPPORTED_Y$3 || fails$g(function () { + return !$RegExp$2('a', 'y').sticky; +}); + +var BROKEN_CARET = UNSUPPORTED_Y$3 || fails$g(function () { + // https://bugzilla.mozilla.org/show_bug.cgi?id=773687 + var re = $RegExp$2('^r', 'gy'); + re.lastIndex = 2; + return re.exec('str') != null; +}); + +var regexpStickyHelpers = { + BROKEN_CARET: BROKEN_CARET, + MISSED_STICKY: MISSED_STICKY$1, + UNSUPPORTED_Y: UNSUPPORTED_Y$3 +}; + +var objectDefineProperties = {}; + +var internalObjectKeys = objectKeysInternal; +var enumBugKeys$1 = enumBugKeys$3; + +// `Object.keys` method +// https://tc39.es/ecma262/#sec-object.keys +// eslint-disable-next-line es-x/no-object-keys -- safe +var objectKeys$1 = Object.keys || function keys(O) { + return internalObjectKeys(O, enumBugKeys$1); +}; + +var DESCRIPTORS$5 = descriptors; +var V8_PROTOTYPE_DEFINE_BUG = v8PrototypeDefineBug; +var definePropertyModule$2 = objectDefineProperty; +var anObject$7 = anObject$b; +var toIndexedObject$2 = toIndexedObject$6; +var objectKeys = objectKeys$1; + +// `Object.defineProperties` method +// https://tc39.es/ecma262/#sec-object.defineproperties +// eslint-disable-next-line es-x/no-object-defineproperties -- safe +objectDefineProperties.f = DESCRIPTORS$5 && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) { + anObject$7(O); + var props = toIndexedObject$2(Properties); + var keys = objectKeys(Properties); + var length = keys.length; + var index = 0; + var key; + while (length > index) definePropertyModule$2.f(O, key = keys[index++], props[key]); + return O; +}; + +var getBuiltIn$4 = getBuiltIn$8; + +var html$1 = getBuiltIn$4('document', 'documentElement'); + +/* global ActiveXObject -- old IE, WSH */ + +var anObject$6 = anObject$b; +var definePropertiesModule = objectDefineProperties; +var enumBugKeys = enumBugKeys$3; +var hiddenKeys = hiddenKeys$4; +var html = html$1; +var documentCreateElement = documentCreateElement$1; +var sharedKey$1 = sharedKey$3; + +var GT = '>'; +var LT = '<'; +var PROTOTYPE = 'prototype'; +var SCRIPT = 'script'; +var IE_PROTO$1 = sharedKey$1('IE_PROTO'); + +var EmptyConstructor = function () { /* empty */ }; + +var scriptTag = function (content) { + return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT; +}; + +// Create object with fake `null` prototype: use ActiveX Object with cleared prototype +var NullProtoObjectViaActiveX = function (activeXDocument) { + activeXDocument.write(scriptTag('')); + activeXDocument.close(); + var temp = activeXDocument.parentWindow.Object; + activeXDocument = null; // avoid memory leak + return temp; +}; + +// Create object with fake `null` prototype: use iframe Object with cleared prototype +var NullProtoObjectViaIFrame = function () { + // Thrash, waste and sodomy: IE GC bug + var iframe = documentCreateElement('iframe'); + var JS = 'java' + SCRIPT + ':'; + var iframeDocument; + iframe.style.display = 'none'; + html.appendChild(iframe); + // https://github.com/zloirock/core-js/issues/475 + iframe.src = String(JS); + iframeDocument = iframe.contentWindow.document; + iframeDocument.open(); + iframeDocument.write(scriptTag('document.F=Object')); + iframeDocument.close(); + return iframeDocument.F; +}; + +// Check for document.domain and active x support +// No need to use active x approach when document.domain is not set +// see https://github.com/es-shims/es5-shim/issues/150 +// variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346 +// avoid IE GC bug +var activeXDocument; +var NullProtoObject = function () { + try { + activeXDocument = new ActiveXObject('htmlfile'); + } catch (error) { /* ignore */ } + NullProtoObject = typeof document != 'undefined' + ? document.domain && activeXDocument + ? NullProtoObjectViaActiveX(activeXDocument) // old IE + : NullProtoObjectViaIFrame() + : NullProtoObjectViaActiveX(activeXDocument); // WSH + var length = enumBugKeys.length; + while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]]; + return NullProtoObject(); +}; + +hiddenKeys[IE_PROTO$1] = true; + +// `Object.create` method +// https://tc39.es/ecma262/#sec-object.create +// eslint-disable-next-line es-x/no-object-create -- safe +var objectCreate = Object.create || function create(O, Properties) { + var result; + if (O !== null) { + EmptyConstructor[PROTOTYPE] = anObject$6(O); + result = new EmptyConstructor(); + EmptyConstructor[PROTOTYPE] = null; + // add "__proto__" for Object.getPrototypeOf polyfill + result[IE_PROTO$1] = O; + } else result = NullProtoObject(); + return Properties === undefined ? result : definePropertiesModule.f(result, Properties); +}; + +var fails$f = fails$p; +var global$4 = global$f; + +// babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError +var $RegExp$1 = global$4.RegExp; + +var regexpUnsupportedDotAll = fails$f(function () { + var re = $RegExp$1('.', 's'); + return !(re.dotAll && re.exec('\n') && re.flags === 's'); +}); + +var fails$e = fails$p; +var global$3 = global$f; + +// babel-minify and Closure Compiler transpiles RegExp('(?b)', 'g') -> /(?b)/g and it causes SyntaxError +var $RegExp = global$3.RegExp; + +var regexpUnsupportedNcg = fails$e(function () { + var re = $RegExp('(?b)', 'g'); + return re.exec('b').groups.a !== 'b' || + 'b'.replace(re, '$c') !== 'bc'; +}); + +/* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */ +/* eslint-disable regexp/no-useless-quantifier -- testing */ +var call$a = functionCall; +var uncurryThis$i = functionUncurryThis; +var toString$9 = toString$a; +var regexpFlags = regexpFlags$1; +var stickyHelpers$2 = regexpStickyHelpers; +var shared = shared$4.exports; +var create$2 = objectCreate; +var getInternalState$2 = internalState.get; +var UNSUPPORTED_DOT_ALL$2 = regexpUnsupportedDotAll; +var UNSUPPORTED_NCG$1 = regexpUnsupportedNcg; + +var nativeReplace = shared('native-string-replace', String.prototype.replace); +var nativeExec = RegExp.prototype.exec; +var patchedExec = nativeExec; +var charAt$5 = uncurryThis$i(''.charAt); +var indexOf$1 = uncurryThis$i(''.indexOf); +var replace$5 = uncurryThis$i(''.replace); +var stringSlice$6 = uncurryThis$i(''.slice); + +var UPDATES_LAST_INDEX_WRONG = (function () { + var re1 = /a/; + var re2 = /b*/g; + call$a(nativeExec, re1, 'a'); + call$a(nativeExec, re2, 'a'); + return re1.lastIndex !== 0 || re2.lastIndex !== 0; +})(); + +var UNSUPPORTED_Y$2 = stickyHelpers$2.BROKEN_CARET; + +// nonparticipating capturing group, copied from es5-shim's String#split patch. +var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined; + +var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y$2 || UNSUPPORTED_DOT_ALL$2 || UNSUPPORTED_NCG$1; + +if (PATCH) { + patchedExec = function exec(string) { + var re = this; + var state = getInternalState$2(re); + var str = toString$9(string); + var raw = state.raw; + var result, reCopy, lastIndex, match, i, object, group; + + if (raw) { + raw.lastIndex = re.lastIndex; + result = call$a(patchedExec, raw, str); + re.lastIndex = raw.lastIndex; + return result; + } + + var groups = state.groups; + var sticky = UNSUPPORTED_Y$2 && re.sticky; + var flags = call$a(regexpFlags, re); + var source = re.source; + var charsAdded = 0; + var strCopy = str; + + if (sticky) { + flags = replace$5(flags, 'y', ''); + if (indexOf$1(flags, 'g') === -1) { + flags += 'g'; + } + + strCopy = stringSlice$6(str, re.lastIndex); + // Support anchored sticky behavior. + if (re.lastIndex > 0 && (!re.multiline || re.multiline && charAt$5(str, re.lastIndex - 1) !== '\n')) { + source = '(?: ' + source + ')'; + strCopy = ' ' + strCopy; + charsAdded++; + } + // ^(? + rx + ) is needed, in combination with some str slicing, to + // simulate the 'y' flag. + reCopy = new RegExp('^(?:' + source + ')', flags); + } + + if (NPCG_INCLUDED) { + reCopy = new RegExp('^' + source + '$(?!\\s)', flags); + } + if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex; + + match = call$a(nativeExec, sticky ? reCopy : re, strCopy); + + if (sticky) { + if (match) { + match.input = stringSlice$6(match.input, charsAdded); + match[0] = stringSlice$6(match[0], charsAdded); + match.index = re.lastIndex; + re.lastIndex += match[0].length; + } else re.lastIndex = 0; + } else if (UPDATES_LAST_INDEX_WRONG && match) { + re.lastIndex = re.global ? match.index + match[0].length : lastIndex; + } + if (NPCG_INCLUDED && match && match.length > 1) { + // Fix browsers whose `exec` methods don't consistently return `undefined` + // for NPCG, like IE8. NOTE: This doesn't work for /(.?)?/ + call$a(nativeReplace, match[0], reCopy, function () { + for (i = 1; i < arguments.length - 2; i++) { + if (arguments[i] === undefined) match[i] = undefined; + } + }); + } + + if (match && groups) { + match.groups = object = create$2(null); + for (i = 0; i < groups.length; i++) { + group = groups[i]; + object[group[0]] = match[group[1]]; + } + } + + return match; + }; +} + +var regexpExec$3 = patchedExec; + +var $$f = _export; +var exec$6 = regexpExec$3; + +// `RegExp.prototype.exec` method +// https://tc39.es/ecma262/#sec-regexp.prototype.exec +$$f({ target: 'RegExp', proto: true, forced: /./.exec !== exec$6 }, { + exec: exec$6 +}); + +var NATIVE_BIND$1 = functionBindNative; + +var FunctionPrototype = Function.prototype; +var apply$4 = FunctionPrototype.apply; +var call$9 = FunctionPrototype.call; + +// eslint-disable-next-line es-x/no-reflect -- safe +var functionApply = typeof Reflect == 'object' && Reflect.apply || (NATIVE_BIND$1 ? call$9.bind(apply$4) : function () { + return call$9.apply(apply$4, arguments); +}); + +// TODO: Remove from `core-js@4` since it's moved to entry points + +var uncurryThis$h = functionUncurryThis; +var defineBuiltIn$3 = defineBuiltIn$5; +var regexpExec$2 = regexpExec$3; +var fails$d = fails$p; +var wellKnownSymbol$e = wellKnownSymbol$i; +var createNonEnumerableProperty$4 = createNonEnumerableProperty$7; + +var SPECIES$5 = wellKnownSymbol$e('species'); +var RegExpPrototype$3 = RegExp.prototype; + +var fixRegexpWellKnownSymbolLogic = function (KEY, exec, FORCED, SHAM) { + var SYMBOL = wellKnownSymbol$e(KEY); + + var DELEGATES_TO_SYMBOL = !fails$d(function () { + // String methods call symbol-named RegEp methods + var O = {}; + O[SYMBOL] = function () { return 7; }; + return ''[KEY](O) != 7; + }); + + var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails$d(function () { + // Symbol-named RegExp methods call .exec + var execCalled = false; + var re = /a/; + + if (KEY === 'split') { + // We can't use real regex here since it causes deoptimization + // and serious performance degradation in V8 + // https://github.com/zloirock/core-js/issues/306 + re = {}; + // RegExp[@@split] doesn't call the regex's exec method, but first creates + // a new one. We need to return the patched regex when creating the new one. + re.constructor = {}; + re.constructor[SPECIES$5] = function () { return re; }; + re.flags = ''; + re[SYMBOL] = /./[SYMBOL]; + } + + re.exec = function () { execCalled = true; return null; }; + + re[SYMBOL](''); + return !execCalled; + }); + + if ( + !DELEGATES_TO_SYMBOL || + !DELEGATES_TO_EXEC || + FORCED + ) { + var uncurriedNativeRegExpMethod = uncurryThis$h(/./[SYMBOL]); + var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) { + var uncurriedNativeMethod = uncurryThis$h(nativeMethod); + var $exec = regexp.exec; + if ($exec === regexpExec$2 || $exec === RegExpPrototype$3.exec) { + if (DELEGATES_TO_SYMBOL && !forceStringMethod) { + // The native String method already delegates to @@method (this + // polyfilled function), leasing to infinite recursion. + // We avoid it by directly calling the native @@method method. + return { done: true, value: uncurriedNativeRegExpMethod(regexp, str, arg2) }; + } + return { done: true, value: uncurriedNativeMethod(str, regexp, arg2) }; + } + return { done: false }; + }); + + defineBuiltIn$3(String.prototype, KEY, methods[0]); + defineBuiltIn$3(RegExpPrototype$3, SYMBOL, methods[1]); + } + + if (SHAM) createNonEnumerableProperty$4(RegExpPrototype$3[SYMBOL], 'sham', true); +}; + +var uncurryThis$g = functionUncurryThis; +var toIntegerOrInfinity$2 = toIntegerOrInfinity$5; +var toString$8 = toString$a; +var requireObjectCoercible$5 = requireObjectCoercible$8; + +var charAt$4 = uncurryThis$g(''.charAt); +var charCodeAt$1 = uncurryThis$g(''.charCodeAt); +var stringSlice$5 = uncurryThis$g(''.slice); + +var createMethod$2 = function (CONVERT_TO_STRING) { + return function ($this, pos) { + var S = toString$8(requireObjectCoercible$5($this)); + var position = toIntegerOrInfinity$2(pos); + var size = S.length; + var first, second; + if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined; + first = charCodeAt$1(S, position); + return first < 0xD800 || first > 0xDBFF || position + 1 === size + || (second = charCodeAt$1(S, position + 1)) < 0xDC00 || second > 0xDFFF + ? CONVERT_TO_STRING + ? charAt$4(S, position) + : first + : CONVERT_TO_STRING + ? stringSlice$5(S, position, position + 2) + : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000; + }; +}; + +var stringMultibyte = { + // `String.prototype.codePointAt` method + // https://tc39.es/ecma262/#sec-string.prototype.codepointat + codeAt: createMethod$2(false), + // `String.prototype.at` method + // https://github.com/mathiasbynens/String.prototype.at + charAt: createMethod$2(true) +}; + +var charAt$3 = stringMultibyte.charAt; + +// `AdvanceStringIndex` abstract operation +// https://tc39.es/ecma262/#sec-advancestringindex +var advanceStringIndex$3 = function (S, index, unicode) { + return index + (unicode ? charAt$3(S, index).length : 1); +}; + +var uncurryThis$f = functionUncurryThis; +var toObject$5 = toObject$7; + +var floor$1 = Math.floor; +var charAt$2 = uncurryThis$f(''.charAt); +var replace$4 = uncurryThis$f(''.replace); +var stringSlice$4 = uncurryThis$f(''.slice); +var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d{1,2}|<[^>]*>)/g; +var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d{1,2})/g; + +// `GetSubstitution` abstract operation +// https://tc39.es/ecma262/#sec-getsubstitution +var getSubstitution$2 = function (matched, str, position, captures, namedCaptures, replacement) { + var tailPos = position + matched.length; + var m = captures.length; + var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED; + if (namedCaptures !== undefined) { + namedCaptures = toObject$5(namedCaptures); + symbols = SUBSTITUTION_SYMBOLS; + } + return replace$4(replacement, symbols, function (match, ch) { + var capture; + switch (charAt$2(ch, 0)) { + case '$': return '$'; + case '&': return matched; + case '`': return stringSlice$4(str, 0, position); + case "'": return stringSlice$4(str, tailPos); + case '<': + capture = namedCaptures[stringSlice$4(ch, 1, -1)]; + break; + default: // \d\d? + var n = +ch; + if (n === 0) return match; + if (n > m) { + var f = floor$1(n / 10); + if (f === 0) return match; + if (f <= m) return captures[f - 1] === undefined ? charAt$2(ch, 1) : captures[f - 1] + charAt$2(ch, 1); + return match; + } + capture = captures[n - 1]; + } + return capture === undefined ? '' : capture; + }); +}; + +var call$8 = functionCall; +var anObject$5 = anObject$b; +var isCallable$a = isCallable$m; +var classof$4 = classofRaw$1; +var regexpExec$1 = regexpExec$3; + +var $TypeError$7 = TypeError; + +// `RegExpExec` abstract operation +// https://tc39.es/ecma262/#sec-regexpexec +var regexpExecAbstract = function (R, S) { + var exec = R.exec; + if (isCallable$a(exec)) { + var result = call$8(exec, R, S); + if (result !== null) anObject$5(result); + return result; + } + if (classof$4(R) === 'RegExp') return call$8(regexpExec$1, R, S); + throw $TypeError$7('RegExp#exec called on incompatible receiver'); +}; + +var apply$3 = functionApply; +var call$7 = functionCall; +var uncurryThis$e = functionUncurryThis; +var fixRegExpWellKnownSymbolLogic$2 = fixRegexpWellKnownSymbolLogic; +var fails$c = fails$p; +var anObject$4 = anObject$b; +var isCallable$9 = isCallable$m; +var toIntegerOrInfinity$1 = toIntegerOrInfinity$5; +var toLength$2 = toLength$4; +var toString$7 = toString$a; +var requireObjectCoercible$4 = requireObjectCoercible$8; +var advanceStringIndex$2 = advanceStringIndex$3; +var getMethod$3 = getMethod$5; +var getSubstitution$1 = getSubstitution$2; +var regExpExec$1 = regexpExecAbstract; +var wellKnownSymbol$d = wellKnownSymbol$i; + +var REPLACE$1 = wellKnownSymbol$d('replace'); +var max$4 = Math.max; +var min$2 = Math.min; +var concat = uncurryThis$e([].concat); +var push$3 = uncurryThis$e([].push); +var stringIndexOf$2 = uncurryThis$e(''.indexOf); +var stringSlice$3 = uncurryThis$e(''.slice); + +var maybeToString = function (it) { + return it === undefined ? it : String(it); +}; + +// IE <= 11 replaces $0 with the whole match, as if it was $& +// https://stackoverflow.com/questions/6024666/getting-ie-to-replace-a-regex-with-the-literal-string-0 +var REPLACE_KEEPS_$0 = (function () { + // eslint-disable-next-line regexp/prefer-escape-replacement-dollar-char -- required for testing + return 'a'.replace(/./, '$0') === '$0'; +})(); + +// Safari <= 13.0.3(?) substitutes nth capture where n>m with an empty string +var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = (function () { + if (/./[REPLACE$1]) { + return /./[REPLACE$1]('a', '$0') === ''; + } + return false; +})(); + +var REPLACE_SUPPORTS_NAMED_GROUPS = !fails$c(function () { + var re = /./; + re.exec = function () { + var result = []; + result.groups = { a: '7' }; + return result; + }; + // eslint-disable-next-line regexp/no-useless-dollar-replacements -- false positive + return ''.replace(re, '$') !== '7'; +}); + +// @@replace logic +fixRegExpWellKnownSymbolLogic$2('replace', function (_, nativeReplace, maybeCallNative) { + var UNSAFE_SUBSTITUTE = REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE ? '$' : '$0'; + + return [ + // `String.prototype.replace` method + // https://tc39.es/ecma262/#sec-string.prototype.replace + function replace(searchValue, replaceValue) { + var O = requireObjectCoercible$4(this); + var replacer = searchValue == undefined ? undefined : getMethod$3(searchValue, REPLACE$1); + return replacer + ? call$7(replacer, searchValue, O, replaceValue) + : call$7(nativeReplace, toString$7(O), searchValue, replaceValue); + }, + // `RegExp.prototype[@@replace]` method + // https://tc39.es/ecma262/#sec-regexp.prototype-@@replace + function (string, replaceValue) { + var rx = anObject$4(this); + var S = toString$7(string); + + if ( + typeof replaceValue == 'string' && + stringIndexOf$2(replaceValue, UNSAFE_SUBSTITUTE) === -1 && + stringIndexOf$2(replaceValue, '$<') === -1 + ) { + var res = maybeCallNative(nativeReplace, rx, S, replaceValue); + if (res.done) return res.value; + } + + var functionalReplace = isCallable$9(replaceValue); + if (!functionalReplace) replaceValue = toString$7(replaceValue); + + var global = rx.global; + if (global) { + var fullUnicode = rx.unicode; + rx.lastIndex = 0; + } + var results = []; + while (true) { + var result = regExpExec$1(rx, S); + if (result === null) break; + + push$3(results, result); + if (!global) break; + + var matchStr = toString$7(result[0]); + if (matchStr === '') rx.lastIndex = advanceStringIndex$2(S, toLength$2(rx.lastIndex), fullUnicode); + } + + var accumulatedResult = ''; + var nextSourcePosition = 0; + for (var i = 0; i < results.length; i++) { + result = results[i]; + + var matched = toString$7(result[0]); + var position = max$4(min$2(toIntegerOrInfinity$1(result.index), S.length), 0); + var captures = []; + // NOTE: This is equivalent to + // captures = result.slice(1).map(maybeToString) + // but for some reason `nativeSlice.call(result, 1, result.length)` (called in + // the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and + // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it. + for (var j = 1; j < result.length; j++) push$3(captures, maybeToString(result[j])); + var namedCaptures = result.groups; + if (functionalReplace) { + var replacerArgs = concat([matched], captures, position, S); + if (namedCaptures !== undefined) push$3(replacerArgs, namedCaptures); + var replacement = toString$7(apply$3(replaceValue, undefined, replacerArgs)); + } else { + replacement = getSubstitution$1(matched, S, position, captures, namedCaptures, replaceValue); + } + if (position >= nextSourcePosition) { + accumulatedResult += stringSlice$3(S, nextSourcePosition, position) + replacement; + nextSourcePosition = position + matched.length; + } + } + return accumulatedResult + stringSlice$3(S, nextSourcePosition); + } + ]; +}, !REPLACE_SUPPORTS_NAMED_GROUPS || !REPLACE_KEEPS_$0 || REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE); + +var isObject$7 = isObject$d; +var classof$3 = classofRaw$1; +var wellKnownSymbol$c = wellKnownSymbol$i; + +var MATCH$1 = wellKnownSymbol$c('match'); + +// `IsRegExp` abstract operation +// https://tc39.es/ecma262/#sec-isregexp +var isRegexp = function (it) { + var isRegExp; + return isObject$7(it) && ((isRegExp = it[MATCH$1]) !== undefined ? !!isRegExp : classof$3(it) == 'RegExp'); +}; + +var call$6 = functionCall; +var hasOwn$4 = hasOwnProperty_1; +var isPrototypeOf$2 = objectIsPrototypeOf; +var regExpFlags = regexpFlags$1; + +var RegExpPrototype$2 = RegExp.prototype; + +var regexpGetFlags = function (R) { + var flags = R.flags; + return flags === undefined && !('flags' in RegExpPrototype$2) && !hasOwn$4(R, 'flags') && isPrototypeOf$2(RegExpPrototype$2, R) + ? call$6(regExpFlags, R) : flags; +}; + +var $$e = _export; +var call$5 = functionCall; +var uncurryThis$d = functionUncurryThis; +var requireObjectCoercible$3 = requireObjectCoercible$8; +var isCallable$8 = isCallable$m; +var isRegExp$2 = isRegexp; +var toString$6 = toString$a; +var getMethod$2 = getMethod$5; +var getRegExpFlags$1 = regexpGetFlags; +var getSubstitution = getSubstitution$2; +var wellKnownSymbol$b = wellKnownSymbol$i; + +var REPLACE = wellKnownSymbol$b('replace'); +var $TypeError$6 = TypeError; +var indexOf = uncurryThis$d(''.indexOf); +uncurryThis$d(''.replace); +var stringSlice$2 = uncurryThis$d(''.slice); +var max$3 = Math.max; + +var stringIndexOf$1 = function (string, searchValue, fromIndex) { + if (fromIndex > string.length) return -1; + if (searchValue === '') return fromIndex; + return indexOf(string, searchValue, fromIndex); +}; + +// `String.prototype.replaceAll` method +// https://tc39.es/ecma262/#sec-string.prototype.replaceall +$$e({ target: 'String', proto: true }, { + replaceAll: function replaceAll(searchValue, replaceValue) { + var O = requireObjectCoercible$3(this); + var IS_REG_EXP, flags, replacer, string, searchString, functionalReplace, searchLength, advanceBy, replacement; + var position = 0; + var endOfLastMatch = 0; + var result = ''; + if (searchValue != null) { + IS_REG_EXP = isRegExp$2(searchValue); + if (IS_REG_EXP) { + flags = toString$6(requireObjectCoercible$3(getRegExpFlags$1(searchValue))); + if (!~indexOf(flags, 'g')) throw $TypeError$6('`.replaceAll` does not allow non-global regexes'); + } + replacer = getMethod$2(searchValue, REPLACE); + if (replacer) { + return call$5(replacer, searchValue, O, replaceValue); + } + } + string = toString$6(O); + searchString = toString$6(searchValue); + functionalReplace = isCallable$8(replaceValue); + if (!functionalReplace) replaceValue = toString$6(replaceValue); + searchLength = searchString.length; + advanceBy = max$3(1, searchLength); + position = stringIndexOf$1(string, searchString, 0); + while (position !== -1) { + replacement = functionalReplace + ? toString$6(replaceValue(searchString, position, string)) + : getSubstitution(searchString, string, position, [], undefined, replaceValue); + result += stringSlice$2(string, endOfLastMatch, position) + replacement; + endOfLastMatch = position + searchLength; + position = stringIndexOf$1(string, searchString, position + advanceBy); + } + if (endOfLastMatch < string.length) { + result += stringSlice$2(string, endOfLastMatch); + } + return result; + } +}); + +var isCallable$7 = isCallable$m; + +var $String = String; +var $TypeError$5 = TypeError; + +var aPossiblePrototype$1 = function (argument) { + if (typeof argument == 'object' || isCallable$7(argument)) return argument; + throw $TypeError$5("Can't set " + $String(argument) + ' as a prototype'); +}; + +/* eslint-disable no-proto -- safe */ + +var uncurryThis$c = functionUncurryThis; +var anObject$3 = anObject$b; +var aPossiblePrototype = aPossiblePrototype$1; + +// `Object.setPrototypeOf` method +// https://tc39.es/ecma262/#sec-object.setprototypeof +// Works with __proto__ only. Old v8 can't work with null proto objects. +// eslint-disable-next-line es-x/no-object-setprototypeof -- safe +var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () { + var CORRECT_SETTER = false; + var test = {}; + var setter; + try { + // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe + setter = uncurryThis$c(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set); + setter(test, []); + CORRECT_SETTER = test instanceof Array; + } catch (error) { /* empty */ } + return function setPrototypeOf(O, proto) { + anObject$3(O); + aPossiblePrototype(proto); + if (CORRECT_SETTER) setter(O, proto); + else O.__proto__ = proto; + return O; + }; +}() : undefined); + +var defineProperty$4 = objectDefineProperty.f; + +var proxyAccessor$2 = function (Target, Source, key) { + key in Target || defineProperty$4(Target, key, { + configurable: true, + get: function () { return Source[key]; }, + set: function (it) { Source[key] = it; } + }); +}; + +var isCallable$6 = isCallable$m; +var isObject$6 = isObject$d; +var setPrototypeOf$2 = objectSetPrototypeOf; + +// makes subclassing work correct for wrapped built-ins +var inheritIfRequired$2 = function ($this, dummy, Wrapper) { + var NewTarget, NewTargetPrototype; + if ( + // it can work only with native `setPrototypeOf` + setPrototypeOf$2 && + // we haven't completely correct pre-ES6 way for getting `new.target`, so use this + isCallable$6(NewTarget = dummy.constructor) && + NewTarget !== Wrapper && + isObject$6(NewTargetPrototype = NewTarget.prototype) && + NewTargetPrototype !== Wrapper.prototype + ) setPrototypeOf$2($this, NewTargetPrototype); + return $this; +}; + +var toString$5 = toString$a; + +var normalizeStringArgument$1 = function (argument, $default) { + return argument === undefined ? arguments.length < 2 ? '' : $default : toString$5(argument); +}; + +var isObject$5 = isObject$d; +var createNonEnumerableProperty$3 = createNonEnumerableProperty$7; + +// `InstallErrorCause` abstract operation +// https://tc39.es/proposal-error-cause/#sec-errorobjects-install-error-cause +var installErrorCause$1 = function (O, options) { + if (isObject$5(options) && 'cause' in options) { + createNonEnumerableProperty$3(O, 'cause', options.cause); + } +}; + +var uncurryThis$b = functionUncurryThis; + +var $Error = Error; +var replace$3 = uncurryThis$b(''.replace); + +var TEST = (function (arg) { return String($Error(arg).stack); })('zxcasd'); +var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/; +var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST); + +var clearErrorStack$1 = function (stack, dropEntries) { + if (IS_V8_OR_CHAKRA_STACK && typeof stack == 'string' && !$Error.prepareStackTrace) { + while (dropEntries--) stack = replace$3(stack, V8_OR_CHAKRA_STACK_ENTRY, ''); + } return stack; +}; + +var fails$b = fails$p; +var createPropertyDescriptor$2 = createPropertyDescriptor$5; + +var errorStackInstallable = !fails$b(function () { + var error = Error('a'); + if (!('stack' in error)) return true; + // eslint-disable-next-line es-x/no-object-defineproperty -- safe + Object.defineProperty(error, 'stack', createPropertyDescriptor$2(1, 7)); + return error.stack !== 7; +}); + +var getBuiltIn$3 = getBuiltIn$8; +var hasOwn$3 = hasOwnProperty_1; +var createNonEnumerableProperty$2 = createNonEnumerableProperty$7; +var isPrototypeOf$1 = objectIsPrototypeOf; +var setPrototypeOf$1 = objectSetPrototypeOf; +var copyConstructorProperties = copyConstructorProperties$2; +var proxyAccessor$1 = proxyAccessor$2; +var inheritIfRequired$1 = inheritIfRequired$2; +var normalizeStringArgument = normalizeStringArgument$1; +var installErrorCause = installErrorCause$1; +var clearErrorStack = clearErrorStack$1; +var ERROR_STACK_INSTALLABLE = errorStackInstallable; +var DESCRIPTORS$4 = descriptors; + +var wrapErrorConstructorWithCause$1 = function (FULL_NAME, wrapper, FORCED, IS_AGGREGATE_ERROR) { + var STACK_TRACE_LIMIT = 'stackTraceLimit'; + var OPTIONS_POSITION = IS_AGGREGATE_ERROR ? 2 : 1; + var path = FULL_NAME.split('.'); + var ERROR_NAME = path[path.length - 1]; + var OriginalError = getBuiltIn$3.apply(null, path); + + if (!OriginalError) return; + + var OriginalErrorPrototype = OriginalError.prototype; + + // V8 9.3- bug https://bugs.chromium.org/p/v8/issues/detail?id=12006 + if (hasOwn$3(OriginalErrorPrototype, 'cause')) delete OriginalErrorPrototype.cause; + + if (!FORCED) return OriginalError; + + var BaseError = getBuiltIn$3('Error'); + + var WrappedError = wrapper(function (a, b) { + var message = normalizeStringArgument(IS_AGGREGATE_ERROR ? b : a, undefined); + var result = IS_AGGREGATE_ERROR ? new OriginalError(a) : new OriginalError(); + if (message !== undefined) createNonEnumerableProperty$2(result, 'message', message); + if (ERROR_STACK_INSTALLABLE) createNonEnumerableProperty$2(result, 'stack', clearErrorStack(result.stack, 2)); + if (this && isPrototypeOf$1(OriginalErrorPrototype, this)) inheritIfRequired$1(result, this, WrappedError); + if (arguments.length > OPTIONS_POSITION) installErrorCause(result, arguments[OPTIONS_POSITION]); + return result; + }); + + WrappedError.prototype = OriginalErrorPrototype; + + if (ERROR_NAME !== 'Error') { + if (setPrototypeOf$1) setPrototypeOf$1(WrappedError, BaseError); + else copyConstructorProperties(WrappedError, BaseError, { name: true }); + } else if (DESCRIPTORS$4 && STACK_TRACE_LIMIT in OriginalError) { + proxyAccessor$1(WrappedError, OriginalError, STACK_TRACE_LIMIT); + proxyAccessor$1(WrappedError, OriginalError, 'prepareStackTrace'); + } + + copyConstructorProperties(WrappedError, OriginalError); + + try { + // Safari 13- bug: WebAssembly errors does not have a proper `.name` + if (OriginalErrorPrototype.name !== ERROR_NAME) { + createNonEnumerableProperty$2(OriginalErrorPrototype, 'name', ERROR_NAME); + } + OriginalErrorPrototype.constructor = WrappedError; + } catch (error) { /* empty */ } + + return WrappedError; +}; + +/* eslint-disable no-unused-vars -- required for functions `.length` */ + +var $$d = _export; +var global$2 = global$f; +var apply$2 = functionApply; +var wrapErrorConstructorWithCause = wrapErrorConstructorWithCause$1; + +var WEB_ASSEMBLY = 'WebAssembly'; +var WebAssembly = global$2[WEB_ASSEMBLY]; + +var FORCED$2 = Error('e', { cause: 7 }).cause !== 7; + +var exportGlobalErrorCauseWrapper = function (ERROR_NAME, wrapper) { + var O = {}; + O[ERROR_NAME] = wrapErrorConstructorWithCause(ERROR_NAME, wrapper, FORCED$2); + $$d({ global: true, constructor: true, arity: 1, forced: FORCED$2 }, O); +}; + +var exportWebAssemblyErrorCauseWrapper = function (ERROR_NAME, wrapper) { + if (WebAssembly && WebAssembly[ERROR_NAME]) { + var O = {}; + O[ERROR_NAME] = wrapErrorConstructorWithCause(WEB_ASSEMBLY + '.' + ERROR_NAME, wrapper, FORCED$2); + $$d({ target: WEB_ASSEMBLY, stat: true, constructor: true, arity: 1, forced: FORCED$2 }, O); + } +}; + +// https://github.com/tc39/proposal-error-cause +exportGlobalErrorCauseWrapper('Error', function (init) { + return function Error(message) { return apply$2(init, this, arguments); }; +}); +exportGlobalErrorCauseWrapper('EvalError', function (init) { + return function EvalError(message) { return apply$2(init, this, arguments); }; +}); +exportGlobalErrorCauseWrapper('RangeError', function (init) { + return function RangeError(message) { return apply$2(init, this, arguments); }; +}); +exportGlobalErrorCauseWrapper('ReferenceError', function (init) { + return function ReferenceError(message) { return apply$2(init, this, arguments); }; +}); +exportGlobalErrorCauseWrapper('SyntaxError', function (init) { + return function SyntaxError(message) { return apply$2(init, this, arguments); }; +}); +exportGlobalErrorCauseWrapper('TypeError', function (init) { + return function TypeError(message) { return apply$2(init, this, arguments); }; +}); +exportGlobalErrorCauseWrapper('URIError', function (init) { + return function URIError(message) { return apply$2(init, this, arguments); }; +}); +exportWebAssemblyErrorCauseWrapper('CompileError', function (init) { + return function CompileError(message) { return apply$2(init, this, arguments); }; +}); +exportWebAssemblyErrorCauseWrapper('LinkError', function (init) { + return function LinkError(message) { return apply$2(init, this, arguments); }; +}); +exportWebAssemblyErrorCauseWrapper('RuntimeError', function (init) { + return function RuntimeError(message) { return apply$2(init, this, arguments); }; +}); + +var wellKnownSymbol$a = wellKnownSymbol$i; +var create$1 = objectCreate; +var defineProperty$3 = objectDefineProperty.f; + +var UNSCOPABLES = wellKnownSymbol$a('unscopables'); +var ArrayPrototype = Array.prototype; + +// Array.prototype[@@unscopables] +// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables +if (ArrayPrototype[UNSCOPABLES] == undefined) { + defineProperty$3(ArrayPrototype, UNSCOPABLES, { + configurable: true, + value: create$1(null) + }); +} + +// add a key to Array.prototype[@@unscopables] +var addToUnscopables$1 = function (key) { + ArrayPrototype[UNSCOPABLES][key] = true; +}; + +var iterators = {}; + +var fails$a = fails$p; + +var correctPrototypeGetter = !fails$a(function () { + function F() { /* empty */ } + F.prototype.constructor = null; + // eslint-disable-next-line es-x/no-object-getprototypeof -- required for testing + return Object.getPrototypeOf(new F()) !== F.prototype; +}); + +var hasOwn$2 = hasOwnProperty_1; +var isCallable$5 = isCallable$m; +var toObject$4 = toObject$7; +var sharedKey = sharedKey$3; +var CORRECT_PROTOTYPE_GETTER = correctPrototypeGetter; + +var IE_PROTO = sharedKey('IE_PROTO'); +var $Object = Object; +var ObjectPrototype = $Object.prototype; + +// `Object.getPrototypeOf` method +// https://tc39.es/ecma262/#sec-object.getprototypeof +// eslint-disable-next-line es-x/no-object-getprototypeof -- safe +var objectGetPrototypeOf = CORRECT_PROTOTYPE_GETTER ? $Object.getPrototypeOf : function (O) { + var object = toObject$4(O); + if (hasOwn$2(object, IE_PROTO)) return object[IE_PROTO]; + var constructor = object.constructor; + if (isCallable$5(constructor) && object instanceof constructor) { + return constructor.prototype; + } return object instanceof $Object ? ObjectPrototype : null; +}; + +var fails$9 = fails$p; +var isCallable$4 = isCallable$m; +var getPrototypeOf$1 = objectGetPrototypeOf; +var defineBuiltIn$2 = defineBuiltIn$5; +var wellKnownSymbol$9 = wellKnownSymbol$i; + +var ITERATOR$1 = wellKnownSymbol$9('iterator'); +var BUGGY_SAFARI_ITERATORS$1 = false; + +// `%IteratorPrototype%` object +// https://tc39.es/ecma262/#sec-%iteratorprototype%-object +var IteratorPrototype$2, PrototypeOfArrayIteratorPrototype, arrayIterator; + +/* eslint-disable es-x/no-array-prototype-keys -- safe */ +if ([].keys) { + arrayIterator = [].keys(); + // Safari 8 has buggy iterators w/o `next` + if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS$1 = true; + else { + PrototypeOfArrayIteratorPrototype = getPrototypeOf$1(getPrototypeOf$1(arrayIterator)); + if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype$2 = PrototypeOfArrayIteratorPrototype; + } +} + +var NEW_ITERATOR_PROTOTYPE = IteratorPrototype$2 == undefined || fails$9(function () { + var test = {}; + // FF44- legacy iterators case + return IteratorPrototype$2[ITERATOR$1].call(test) !== test; +}); + +if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype$2 = {}; + +// `%IteratorPrototype%[@@iterator]()` method +// https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator +if (!isCallable$4(IteratorPrototype$2[ITERATOR$1])) { + defineBuiltIn$2(IteratorPrototype$2, ITERATOR$1, function () { + return this; + }); +} + +var iteratorsCore = { + IteratorPrototype: IteratorPrototype$2, + BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS$1 +}; + +var defineProperty$2 = objectDefineProperty.f; +var hasOwn$1 = hasOwnProperty_1; +var wellKnownSymbol$8 = wellKnownSymbol$i; + +var TO_STRING_TAG = wellKnownSymbol$8('toStringTag'); + +var setToStringTag$2 = function (target, TAG, STATIC) { + if (target && !STATIC) target = target.prototype; + if (target && !hasOwn$1(target, TO_STRING_TAG)) { + defineProperty$2(target, TO_STRING_TAG, { configurable: true, value: TAG }); + } +}; + +var IteratorPrototype$1 = iteratorsCore.IteratorPrototype; +var create = objectCreate; +var createPropertyDescriptor$1 = createPropertyDescriptor$5; +var setToStringTag$1 = setToStringTag$2; +var Iterators$2 = iterators; + +var returnThis$1 = function () { return this; }; + +var createIteratorConstructor$1 = function (IteratorConstructor, NAME, next, ENUMERABLE_NEXT) { + var TO_STRING_TAG = NAME + ' Iterator'; + IteratorConstructor.prototype = create(IteratorPrototype$1, { next: createPropertyDescriptor$1(+!ENUMERABLE_NEXT, next) }); + setToStringTag$1(IteratorConstructor, TO_STRING_TAG, false); + Iterators$2[TO_STRING_TAG] = returnThis$1; + return IteratorConstructor; +}; + +var $$c = _export; +var call$4 = functionCall; +var FunctionName = functionName; +var isCallable$3 = isCallable$m; +var createIteratorConstructor = createIteratorConstructor$1; +var getPrototypeOf = objectGetPrototypeOf; +var setPrototypeOf = objectSetPrototypeOf; +var setToStringTag = setToStringTag$2; +var createNonEnumerableProperty$1 = createNonEnumerableProperty$7; +var defineBuiltIn$1 = defineBuiltIn$5; +var wellKnownSymbol$7 = wellKnownSymbol$i; +var Iterators$1 = iterators; +var IteratorsCore = iteratorsCore; + +var PROPER_FUNCTION_NAME$1 = FunctionName.PROPER; +var CONFIGURABLE_FUNCTION_NAME = FunctionName.CONFIGURABLE; +var IteratorPrototype = IteratorsCore.IteratorPrototype; +var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS; +var ITERATOR = wellKnownSymbol$7('iterator'); +var KEYS = 'keys'; +var VALUES = 'values'; +var ENTRIES = 'entries'; + +var returnThis = function () { return this; }; + +var defineIterator$1 = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) { + createIteratorConstructor(IteratorConstructor, NAME, next); + + var getIterationMethod = function (KIND) { + if (KIND === DEFAULT && defaultIterator) return defaultIterator; + if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype) return IterablePrototype[KIND]; + switch (KIND) { + case KEYS: return function keys() { return new IteratorConstructor(this, KIND); }; + case VALUES: return function values() { return new IteratorConstructor(this, KIND); }; + case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); }; + } return function () { return new IteratorConstructor(this); }; + }; + + var TO_STRING_TAG = NAME + ' Iterator'; + var INCORRECT_VALUES_NAME = false; + var IterablePrototype = Iterable.prototype; + var nativeIterator = IterablePrototype[ITERATOR] + || IterablePrototype['@@iterator'] + || DEFAULT && IterablePrototype[DEFAULT]; + var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT); + var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator; + var CurrentIteratorPrototype, methods, KEY; + + // fix native + if (anyNativeIterator) { + CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable())); + if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) { + if (getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) { + if (setPrototypeOf) { + setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype); + } else if (!isCallable$3(CurrentIteratorPrototype[ITERATOR])) { + defineBuiltIn$1(CurrentIteratorPrototype, ITERATOR, returnThis); + } + } + // Set @@toStringTag to native iterators + setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true); + } + } + + // fix Array.prototype.{ values, @@iterator }.name in V8 / FF + if (PROPER_FUNCTION_NAME$1 && DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) { + if (CONFIGURABLE_FUNCTION_NAME) { + createNonEnumerableProperty$1(IterablePrototype, 'name', VALUES); + } else { + INCORRECT_VALUES_NAME = true; + defaultIterator = function values() { return call$4(nativeIterator, this); }; + } + } + + // export additional methods + if (DEFAULT) { + methods = { + values: getIterationMethod(VALUES), + keys: IS_SET ? defaultIterator : getIterationMethod(KEYS), + entries: getIterationMethod(ENTRIES) + }; + if (FORCED) for (KEY in methods) { + if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) { + defineBuiltIn$1(IterablePrototype, KEY, methods[KEY]); + } + } else $$c({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods); + } + + // define iterator + if (IterablePrototype[ITERATOR] !== defaultIterator) { + defineBuiltIn$1(IterablePrototype, ITERATOR, defaultIterator, { name: DEFAULT }); + } + Iterators$1[NAME] = defaultIterator; + + return methods; +}; + +var toIndexedObject$1 = toIndexedObject$6; +var addToUnscopables = addToUnscopables$1; +var Iterators = iterators; +var InternalStateModule = internalState; +var defineProperty$1 = objectDefineProperty.f; +var defineIterator = defineIterator$1; +var DESCRIPTORS$3 = descriptors; + +var ARRAY_ITERATOR = 'Array Iterator'; +var setInternalState = InternalStateModule.set; +var getInternalState$1 = InternalStateModule.getterFor(ARRAY_ITERATOR); + +// `Array.prototype.entries` method +// https://tc39.es/ecma262/#sec-array.prototype.entries +// `Array.prototype.keys` method +// https://tc39.es/ecma262/#sec-array.prototype.keys +// `Array.prototype.values` method +// https://tc39.es/ecma262/#sec-array.prototype.values +// `Array.prototype[@@iterator]` method +// https://tc39.es/ecma262/#sec-array.prototype-@@iterator +// `CreateArrayIterator` internal method +// https://tc39.es/ecma262/#sec-createarrayiterator +defineIterator(Array, 'Array', function (iterated, kind) { + setInternalState(this, { + type: ARRAY_ITERATOR, + target: toIndexedObject$1(iterated), // target + index: 0, // next index + kind: kind // kind + }); +// `%ArrayIteratorPrototype%.next` method +// https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next +}, function () { + var state = getInternalState$1(this); + var target = state.target; + var kind = state.kind; + var index = state.index++; + if (!target || index >= target.length) { + state.target = undefined; + return { value: undefined, done: true }; + } + if (kind == 'keys') return { value: index, done: false }; + if (kind == 'values') return { value: target[index], done: false }; + return { value: [index, target[index]], done: false }; +}, 'values'); + +// argumentsList[@@iterator] is %ArrayProto_values% +// https://tc39.es/ecma262/#sec-createunmappedargumentsobject +// https://tc39.es/ecma262/#sec-createmappedargumentsobject +var values = Iterators.Arguments = Iterators.Array; + +// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables +addToUnscopables('keys'); +addToUnscopables('values'); +addToUnscopables('entries'); + +// V8 ~ Chrome 45- bug +if (DESCRIPTORS$3 && values.name !== 'values') try { + defineProperty$1(values, 'name', { value: 'values' }); +} catch (error) { /* empty */ } + +// TODO: Remove from `core-js@4` since it's moved to entry points + +var $$b = _export; +var call$3 = functionCall; +var uncurryThis$a = functionUncurryThis; +var isCallable$2 = isCallable$m; +var isObject$4 = isObject$d; + +var DELEGATES_TO_EXEC = function () { + var execCalled = false; + var re = /[ac]/; + re.exec = function () { + execCalled = true; + return /./.exec.apply(this, arguments); + }; + return re.test('abc') === true && execCalled; +}(); + +var $TypeError$4 = TypeError; +var un$Test = uncurryThis$a(/./.test); + +// `RegExp.prototype.test` method +// https://tc39.es/ecma262/#sec-regexp.prototype.test +$$b({ target: 'RegExp', proto: true, forced: !DELEGATES_TO_EXEC }, { + test: function (str) { + var exec = this.exec; + if (!isCallable$2(exec)) return un$Test(this, str); + var result = call$3(exec, this, str); + if (result !== null && !isObject$4(result)) { + throw new $TypeError$4('RegExp exec method returned something other than an Object or null'); + } + return !!result; + } +}); + +// a string of all valid unicode whitespaces +var whitespaces$2 = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' + + '\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'; + +var uncurryThis$9 = functionUncurryThis; +var requireObjectCoercible$2 = requireObjectCoercible$8; +var toString$4 = toString$a; +var whitespaces$1 = whitespaces$2; + +var replace$2 = uncurryThis$9(''.replace); +var whitespace = '[' + whitespaces$1 + ']'; +var ltrim = RegExp('^' + whitespace + whitespace + '*'); +var rtrim = RegExp(whitespace + whitespace + '*$'); + +// `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation +var createMethod$1 = function (TYPE) { + return function ($this) { + var string = toString$4(requireObjectCoercible$2($this)); + if (TYPE & 1) string = replace$2(string, ltrim, ''); + if (TYPE & 2) string = replace$2(string, rtrim, ''); + return string; + }; +}; + +var stringTrim = { + // `String.prototype.{ trimLeft, trimStart }` methods + // https://tc39.es/ecma262/#sec-string.prototype.trimstart + start: createMethod$1(1), + // `String.prototype.{ trimRight, trimEnd }` methods + // https://tc39.es/ecma262/#sec-string.prototype.trimend + end: createMethod$1(2), + // `String.prototype.trim` method + // https://tc39.es/ecma262/#sec-string.prototype.trim + trim: createMethod$1(3) +}; + +var PROPER_FUNCTION_NAME = functionName.PROPER; +var fails$8 = fails$p; +var whitespaces = whitespaces$2; + +var non = '\u200B\u0085\u180E'; + +// check that a method works with the correct list +// of whitespaces and has a correct name +var stringTrimForced = function (METHOD_NAME) { + return fails$8(function () { + return !!whitespaces[METHOD_NAME]() + || non[METHOD_NAME]() !== non + || (PROPER_FUNCTION_NAME && whitespaces[METHOD_NAME].name !== METHOD_NAME); + }); +}; + +var $$a = _export; +var $trim = stringTrim.trim; +var forcedStringTrimMethod$1 = stringTrimForced; + +// `String.prototype.trim` method +// https://tc39.es/ecma262/#sec-string.prototype.trim +$$a({ target: 'String', proto: true, forced: forcedStringTrimMethod$1('trim') }, { + trim: function trim() { + return $trim(this); + } +}); + +var classof$2 = classofRaw$1; + +// `IsArray` abstract operation +// https://tc39.es/ecma262/#sec-isarray +// eslint-disable-next-line es-x/no-array-isarray -- safe +var isArray$4 = Array.isArray || function isArray(argument) { + return classof$2(argument) == 'Array'; +}; + +var uncurryThis$8 = functionUncurryThis; +var fails$7 = fails$p; +var isCallable$1 = isCallable$m; +var classof$1 = classof$6; +var getBuiltIn$2 = getBuiltIn$8; +var inspectSource = inspectSource$3; + +var noop = function () { /* empty */ }; +var empty = []; +var construct = getBuiltIn$2('Reflect', 'construct'); +var constructorRegExp = /^\s*(?:class|function)\b/; +var exec$5 = uncurryThis$8(constructorRegExp.exec); +var INCORRECT_TO_STRING = !constructorRegExp.exec(noop); + +var isConstructorModern = function isConstructor(argument) { + if (!isCallable$1(argument)) return false; + try { + construct(noop, empty, argument); + return true; + } catch (error) { + return false; + } +}; + +var isConstructorLegacy = function isConstructor(argument) { + if (!isCallable$1(argument)) return false; + switch (classof$1(argument)) { + case 'AsyncFunction': + case 'GeneratorFunction': + case 'AsyncGeneratorFunction': return false; + } + try { + // we can't check .prototype since constructors produced by .bind haven't it + // `Function#toString` throws on some built-it function in some legacy engines + // (for example, `DOMQuad` and similar in FF41-) + return INCORRECT_TO_STRING || !!exec$5(constructorRegExp, inspectSource(argument)); + } catch (error) { + return true; + } +}; + +isConstructorLegacy.sham = true; + +// `IsConstructor` abstract operation +// https://tc39.es/ecma262/#sec-isconstructor +var isConstructor$3 = !construct || fails$7(function () { + var called; + return isConstructorModern(isConstructorModern.call) + || !isConstructorModern(Object) + || !isConstructorModern(function () { called = true; }) + || called; +}) ? isConstructorLegacy : isConstructorModern; + +var toPropertyKey = toPropertyKey$3; +var definePropertyModule$1 = objectDefineProperty; +var createPropertyDescriptor = createPropertyDescriptor$5; + +var createProperty$4 = function (object, key, value) { + var propertyKey = toPropertyKey(key); + if (propertyKey in object) definePropertyModule$1.f(object, propertyKey, createPropertyDescriptor(0, value)); + else object[propertyKey] = value; +}; + +var fails$6 = fails$p; +var wellKnownSymbol$6 = wellKnownSymbol$i; +var V8_VERSION$1 = engineV8Version; + +var SPECIES$4 = wellKnownSymbol$6('species'); + +var arrayMethodHasSpeciesSupport$5 = function (METHOD_NAME) { + // We can't use this feature detection in V8 since it causes + // deoptimization and serious performance degradation + // https://github.com/zloirock/core-js/issues/677 + return V8_VERSION$1 >= 51 || !fails$6(function () { + var array = []; + var constructor = array.constructor = {}; + constructor[SPECIES$4] = function () { + return { foo: 1 }; + }; + return array[METHOD_NAME](Boolean).foo !== 1; + }); +}; + +var uncurryThis$7 = functionUncurryThis; + +var arraySlice$3 = uncurryThis$7([].slice); + +var $$9 = _export; +var isArray$3 = isArray$4; +var isConstructor$2 = isConstructor$3; +var isObject$3 = isObject$d; +var toAbsoluteIndex$2 = toAbsoluteIndex$4; +var lengthOfArrayLike$5 = lengthOfArrayLike$7; +var toIndexedObject = toIndexedObject$6; +var createProperty$3 = createProperty$4; +var wellKnownSymbol$5 = wellKnownSymbol$i; +var arrayMethodHasSpeciesSupport$4 = arrayMethodHasSpeciesSupport$5; +var un$Slice = arraySlice$3; + +var HAS_SPECIES_SUPPORT$3 = arrayMethodHasSpeciesSupport$4('slice'); + +var SPECIES$3 = wellKnownSymbol$5('species'); +var $Array$2 = Array; +var max$2 = Math.max; + +// `Array.prototype.slice` method +// https://tc39.es/ecma262/#sec-array.prototype.slice +// fallback for not array-like ES3 strings and DOM objects +$$9({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$3 }, { + slice: function slice(start, end) { + var O = toIndexedObject(this); + var length = lengthOfArrayLike$5(O); + var k = toAbsoluteIndex$2(start, length); + var fin = toAbsoluteIndex$2(end === undefined ? length : end, length); + // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible + var Constructor, result, n; + if (isArray$3(O)) { + Constructor = O.constructor; + // cross-realm fallback + if (isConstructor$2(Constructor) && (Constructor === $Array$2 || isArray$3(Constructor.prototype))) { + Constructor = undefined; + } else if (isObject$3(Constructor)) { + Constructor = Constructor[SPECIES$3]; + if (Constructor === null) Constructor = undefined; + } + if (Constructor === $Array$2 || Constructor === undefined) { + return un$Slice(O, k, fin); + } + } + result = new (Constructor === undefined ? $Array$2 : Constructor)(max$2(fin - k, 0)); + for (n = 0; k < fin; k++, n++) if (k in O) createProperty$3(result, n, O[k]); + result.length = n; + return result; + } +}); + +var fails$5 = fails$p; + +var arrayMethodIsStrict$2 = function (METHOD_NAME, argument) { + var method = [][METHOD_NAME]; + return !!method && fails$5(function () { + // eslint-disable-next-line no-useless-call -- required for testing + method.call(null, argument || function () { return 1; }, 1); + }); +}; + +/* eslint-disable es-x/no-array-prototype-indexof -- required for testing */ +var $$8 = _export; +var uncurryThis$6 = functionUncurryThis; +var $IndexOf = arrayIncludes.indexOf; +var arrayMethodIsStrict$1 = arrayMethodIsStrict$2; + +var un$IndexOf = uncurryThis$6([].indexOf); + +var NEGATIVE_ZERO = !!un$IndexOf && 1 / un$IndexOf([1], 1, -0) < 0; +var STRICT_METHOD$1 = arrayMethodIsStrict$1('indexOf'); + +// `Array.prototype.indexOf` method +// https://tc39.es/ecma262/#sec-array.prototype.indexof +$$8({ target: 'Array', proto: true, forced: NEGATIVE_ZERO || !STRICT_METHOD$1 }, { + indexOf: function indexOf(searchElement /* , fromIndex = 0 */) { + var fromIndex = arguments.length > 1 ? arguments[1] : undefined; + return NEGATIVE_ZERO + // convert -0 to +0 + ? un$IndexOf(this, searchElement, fromIndex) || 0 + : $IndexOf(this, searchElement, fromIndex); + } +}); + +var isConstructor$1 = isConstructor$3; +var tryToString$1 = tryToString$3; + +var $TypeError$3 = TypeError; + +// `Assert: IsConstructor(argument) is true` +var aConstructor$1 = function (argument) { + if (isConstructor$1(argument)) return argument; + throw $TypeError$3(tryToString$1(argument) + ' is not a constructor'); +}; + +var anObject$2 = anObject$b; +var aConstructor = aConstructor$1; +var wellKnownSymbol$4 = wellKnownSymbol$i; + +var SPECIES$2 = wellKnownSymbol$4('species'); + +// `SpeciesConstructor` abstract operation +// https://tc39.es/ecma262/#sec-speciesconstructor +var speciesConstructor$1 = function (O, defaultConstructor) { + var C = anObject$2(O).constructor; + var S; + return C === undefined || (S = anObject$2(C)[SPECIES$2]) == undefined ? defaultConstructor : aConstructor(S); +}; + +var toAbsoluteIndex$1 = toAbsoluteIndex$4; +var lengthOfArrayLike$4 = lengthOfArrayLike$7; +var createProperty$2 = createProperty$4; + +var $Array$1 = Array; +var max$1 = Math.max; + +var arraySliceSimple = function (O, start, end) { + var length = lengthOfArrayLike$4(O); + var k = toAbsoluteIndex$1(start, length); + var fin = toAbsoluteIndex$1(end === undefined ? length : end, length); + var result = $Array$1(max$1(fin - k, 0)); + for (var n = 0; k < fin; k++, n++) createProperty$2(result, n, O[k]); + result.length = n; + return result; +}; + +var apply$1 = functionApply; +var call$2 = functionCall; +var uncurryThis$5 = functionUncurryThis; +var fixRegExpWellKnownSymbolLogic$1 = fixRegexpWellKnownSymbolLogic; +var isRegExp$1 = isRegexp; +var anObject$1 = anObject$b; +var requireObjectCoercible$1 = requireObjectCoercible$8; +var speciesConstructor = speciesConstructor$1; +var advanceStringIndex$1 = advanceStringIndex$3; +var toLength$1 = toLength$4; +var toString$3 = toString$a; +var getMethod$1 = getMethod$5; +var arraySlice$2 = arraySliceSimple; +var callRegExpExec = regexpExecAbstract; +var regexpExec = regexpExec$3; +var stickyHelpers$1 = regexpStickyHelpers; +var fails$4 = fails$p; + +var UNSUPPORTED_Y$1 = stickyHelpers$1.UNSUPPORTED_Y; +var MAX_UINT32 = 0xFFFFFFFF; +var min$1 = Math.min; +var $push = [].push; +var exec$4 = uncurryThis$5(/./.exec); +var push$2 = uncurryThis$5($push); +var stringSlice$1 = uncurryThis$5(''.slice); + +// Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec +// Weex JS has frozen built-in prototypes, so use try / catch wrapper +var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails$4(function () { + // eslint-disable-next-line regexp/no-empty-group -- required for testing + var re = /(?:)/; + var originalExec = re.exec; + re.exec = function () { return originalExec.apply(this, arguments); }; + var result = 'ab'.split(re); + return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b'; +}); + +// @@split logic +fixRegExpWellKnownSymbolLogic$1('split', function (SPLIT, nativeSplit, maybeCallNative) { + var internalSplit; + if ( + 'abbc'.split(/(b)*/)[1] == 'c' || + // eslint-disable-next-line regexp/no-empty-group -- required for testing + 'test'.split(/(?:)/, -1).length != 4 || + 'ab'.split(/(?:ab)*/).length != 2 || + '.'.split(/(.?)(.?)/).length != 4 || + // eslint-disable-next-line regexp/no-empty-capturing-group, regexp/no-empty-group -- required for testing + '.'.split(/()()/).length > 1 || + ''.split(/.?/).length + ) { + // based on es5-shim implementation, need to rework it + internalSplit = function (separator, limit) { + var string = toString$3(requireObjectCoercible$1(this)); + var lim = limit === undefined ? MAX_UINT32 : limit >>> 0; + if (lim === 0) return []; + if (separator === undefined) return [string]; + // If `separator` is not a regex, use native split + if (!isRegExp$1(separator)) { + return call$2(nativeSplit, string, separator, lim); + } + var output = []; + var flags = (separator.ignoreCase ? 'i' : '') + + (separator.multiline ? 'm' : '') + + (separator.unicode ? 'u' : '') + + (separator.sticky ? 'y' : ''); + var lastLastIndex = 0; + // Make `global` and avoid `lastIndex` issues by working with a copy + var separatorCopy = new RegExp(separator.source, flags + 'g'); + var match, lastIndex, lastLength; + while (match = call$2(regexpExec, separatorCopy, string)) { + lastIndex = separatorCopy.lastIndex; + if (lastIndex > lastLastIndex) { + push$2(output, stringSlice$1(string, lastLastIndex, match.index)); + if (match.length > 1 && match.index < string.length) apply$1($push, output, arraySlice$2(match, 1)); + lastLength = match[0].length; + lastLastIndex = lastIndex; + if (output.length >= lim) break; + } + if (separatorCopy.lastIndex === match.index) separatorCopy.lastIndex++; // Avoid an infinite loop + } + if (lastLastIndex === string.length) { + if (lastLength || !exec$4(separatorCopy, '')) push$2(output, ''); + } else push$2(output, stringSlice$1(string, lastLastIndex)); + return output.length > lim ? arraySlice$2(output, 0, lim) : output; + }; + // Chakra, V8 + } else if ('0'.split(undefined, 0).length) { + internalSplit = function (separator, limit) { + return separator === undefined && limit === 0 ? [] : call$2(nativeSplit, this, separator, limit); + }; + } else internalSplit = nativeSplit; + + return [ + // `String.prototype.split` method + // https://tc39.es/ecma262/#sec-string.prototype.split + function split(separator, limit) { + var O = requireObjectCoercible$1(this); + var splitter = separator == undefined ? undefined : getMethod$1(separator, SPLIT); + return splitter + ? call$2(splitter, separator, O, limit) + : call$2(internalSplit, toString$3(O), separator, limit); + }, + // `RegExp.prototype[@@split]` method + // https://tc39.es/ecma262/#sec-regexp.prototype-@@split + // + // NOTE: This cannot be properly polyfilled in engines that don't support + // the 'y' flag. + function (string, limit) { + var rx = anObject$1(this); + var S = toString$3(string); + var res = maybeCallNative(internalSplit, rx, S, limit, internalSplit !== nativeSplit); + + if (res.done) return res.value; + + var C = speciesConstructor(rx, RegExp); + + var unicodeMatching = rx.unicode; + var flags = (rx.ignoreCase ? 'i' : '') + + (rx.multiline ? 'm' : '') + + (rx.unicode ? 'u' : '') + + (UNSUPPORTED_Y$1 ? 'g' : 'y'); + + // ^(? + rx + ) is needed, in combination with some S slicing, to + // simulate the 'y' flag. + var splitter = new C(UNSUPPORTED_Y$1 ? '^(?:' + rx.source + ')' : rx, flags); + var lim = limit === undefined ? MAX_UINT32 : limit >>> 0; + if (lim === 0) return []; + if (S.length === 0) return callRegExpExec(splitter, S) === null ? [S] : []; + var p = 0; + var q = 0; + var A = []; + while (q < S.length) { + splitter.lastIndex = UNSUPPORTED_Y$1 ? 0 : q; + var z = callRegExpExec(splitter, UNSUPPORTED_Y$1 ? stringSlice$1(S, q) : S); + var e; + if ( + z === null || + (e = min$1(toLength$1(splitter.lastIndex + (UNSUPPORTED_Y$1 ? q : 0)), S.length)) === p + ) { + q = advanceStringIndex$1(S, q, unicodeMatching); + } else { + push$2(A, stringSlice$1(S, p, q)); + if (A.length === lim) return A; + for (var i = 1; i <= z.length - 1; i++) { + push$2(A, z[i]); + if (A.length === lim) return A; + } + q = p = e; + } + } + push$2(A, stringSlice$1(S, p)); + return A; + } + ]; +}, !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC, UNSUPPORTED_Y$1); + +var uncurryThis$4 = functionUncurryThis; +var aCallable$1 = aCallable$3; +var NATIVE_BIND = functionBindNative; + +var bind$1 = uncurryThis$4(uncurryThis$4.bind); + +// optional / simple context binding +var functionBindContext = function (fn, that) { + aCallable$1(fn); + return that === undefined ? fn : NATIVE_BIND ? bind$1(fn, that) : function (/* ...args */) { + return fn.apply(that, arguments); + }; +}; + +var isArray$2 = isArray$4; +var isConstructor = isConstructor$3; +var isObject$2 = isObject$d; +var wellKnownSymbol$3 = wellKnownSymbol$i; + +var SPECIES$1 = wellKnownSymbol$3('species'); +var $Array = Array; + +// a part of `ArraySpeciesCreate` abstract operation +// https://tc39.es/ecma262/#sec-arrayspeciescreate +var arraySpeciesConstructor$1 = function (originalArray) { + var C; + if (isArray$2(originalArray)) { + C = originalArray.constructor; + // cross-realm fallback + if (isConstructor(C) && (C === $Array || isArray$2(C.prototype))) C = undefined; + else if (isObject$2(C)) { + C = C[SPECIES$1]; + if (C === null) C = undefined; + } + } return C === undefined ? $Array : C; +}; + +var arraySpeciesConstructor = arraySpeciesConstructor$1; + +// `ArraySpeciesCreate` abstract operation +// https://tc39.es/ecma262/#sec-arrayspeciescreate +var arraySpeciesCreate$3 = function (originalArray, length) { + return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length); +}; + +var bind = functionBindContext; +var uncurryThis$3 = functionUncurryThis; +var IndexedObject = indexedObject; +var toObject$3 = toObject$7; +var lengthOfArrayLike$3 = lengthOfArrayLike$7; +var arraySpeciesCreate$2 = arraySpeciesCreate$3; + +var push$1 = uncurryThis$3([].push); + +// `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterReject }` methods implementation +var createMethod = function (TYPE) { + var IS_MAP = TYPE == 1; + var IS_FILTER = TYPE == 2; + var IS_SOME = TYPE == 3; + var IS_EVERY = TYPE == 4; + var IS_FIND_INDEX = TYPE == 6; + var IS_FILTER_REJECT = TYPE == 7; + var NO_HOLES = TYPE == 5 || IS_FIND_INDEX; + return function ($this, callbackfn, that, specificCreate) { + var O = toObject$3($this); + var self = IndexedObject(O); + var boundFunction = bind(callbackfn, that); + var length = lengthOfArrayLike$3(self); + var index = 0; + var create = specificCreate || arraySpeciesCreate$2; + var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_REJECT ? create($this, 0) : undefined; + var value, result; + for (;length > index; index++) if (NO_HOLES || index in self) { + value = self[index]; + result = boundFunction(value, index, O); + if (TYPE) { + if (IS_MAP) target[index] = result; // map + else if (result) switch (TYPE) { + case 3: return true; // some + case 5: return value; // find + case 6: return index; // findIndex + case 2: push$1(target, value); // filter + } else switch (TYPE) { + case 4: return false; // every + case 7: push$1(target, value); // filterReject + } + } + } + return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target; + }; +}; + +var arrayIteration = { + // `Array.prototype.forEach` method + // https://tc39.es/ecma262/#sec-array.prototype.foreach + forEach: createMethod(0), + // `Array.prototype.map` method + // https://tc39.es/ecma262/#sec-array.prototype.map + map: createMethod(1), + // `Array.prototype.filter` method + // https://tc39.es/ecma262/#sec-array.prototype.filter + filter: createMethod(2), + // `Array.prototype.some` method + // https://tc39.es/ecma262/#sec-array.prototype.some + some: createMethod(3), + // `Array.prototype.every` method + // https://tc39.es/ecma262/#sec-array.prototype.every + every: createMethod(4), + // `Array.prototype.find` method + // https://tc39.es/ecma262/#sec-array.prototype.find + find: createMethod(5), + // `Array.prototype.findIndex` method + // https://tc39.es/ecma262/#sec-array.prototype.findIndex + findIndex: createMethod(6), + // `Array.prototype.filterReject` method + // https://github.com/tc39/proposal-array-filtering + filterReject: createMethod(7) +}; + +var $$7 = _export; +var $map = arrayIteration.map; +var arrayMethodHasSpeciesSupport$3 = arrayMethodHasSpeciesSupport$5; + +var HAS_SPECIES_SUPPORT$2 = arrayMethodHasSpeciesSupport$3('map'); + +// `Array.prototype.map` method +// https://tc39.es/ecma262/#sec-array.prototype.map +// with adding support of @@species +$$7({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$2 }, { + map: function map(callbackfn /* , thisArg */) { + return $map(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); + } +}); + +var $TypeError$2 = TypeError; +var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF; // 2 ** 53 - 1 == 9007199254740991 + +var doesNotExceedSafeInteger$2 = function (it) { + if (it > MAX_SAFE_INTEGER) throw $TypeError$2('Maximum allowed index exceeded'); + return it; +}; + +var $$6 = _export; +var fails$3 = fails$p; +var isArray$1 = isArray$4; +var isObject$1 = isObject$d; +var toObject$2 = toObject$7; +var lengthOfArrayLike$2 = lengthOfArrayLike$7; +var doesNotExceedSafeInteger$1 = doesNotExceedSafeInteger$2; +var createProperty$1 = createProperty$4; +var arraySpeciesCreate$1 = arraySpeciesCreate$3; +var arrayMethodHasSpeciesSupport$2 = arrayMethodHasSpeciesSupport$5; +var wellKnownSymbol$2 = wellKnownSymbol$i; +var V8_VERSION = engineV8Version; + +var IS_CONCAT_SPREADABLE = wellKnownSymbol$2('isConcatSpreadable'); + +// We can't use this feature detection in V8 since it causes +// deoptimization and serious performance degradation +// https://github.com/zloirock/core-js/issues/679 +var IS_CONCAT_SPREADABLE_SUPPORT = V8_VERSION >= 51 || !fails$3(function () { + var array = []; + array[IS_CONCAT_SPREADABLE] = false; + return array.concat()[0] !== array; +}); + +var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport$2('concat'); + +var isConcatSpreadable = function (O) { + if (!isObject$1(O)) return false; + var spreadable = O[IS_CONCAT_SPREADABLE]; + return spreadable !== undefined ? !!spreadable : isArray$1(O); +}; + +var FORCED$1 = !IS_CONCAT_SPREADABLE_SUPPORT || !SPECIES_SUPPORT; + +// `Array.prototype.concat` method +// https://tc39.es/ecma262/#sec-array.prototype.concat +// with adding support of @@isConcatSpreadable and @@species +$$6({ target: 'Array', proto: true, arity: 1, forced: FORCED$1 }, { + // eslint-disable-next-line no-unused-vars -- required for `.length` + concat: function concat(arg) { + var O = toObject$2(this); + var A = arraySpeciesCreate$1(O, 0); + var n = 0; + var i, k, length, len, E; + for (i = -1, length = arguments.length; i < length; i++) { + E = i === -1 ? O : arguments[i]; + if (isConcatSpreadable(E)) { + len = lengthOfArrayLike$2(E); + doesNotExceedSafeInteger$1(n + len); + for (k = 0; k < len; k++, n++) if (k in E) createProperty$1(A, n, E[k]); + } else { + doesNotExceedSafeInteger$1(n + 1); + createProperty$1(A, n++, E); + } + } + A.length = n; + return A; + } +}); + +var common$2 = {}; + +var call$1 = functionCall; +var fixRegExpWellKnownSymbolLogic = fixRegexpWellKnownSymbolLogic; +var anObject = anObject$b; +var toLength = toLength$4; +var toString$2 = toString$a; +var requireObjectCoercible = requireObjectCoercible$8; +var getMethod = getMethod$5; +var advanceStringIndex = advanceStringIndex$3; +var regExpExec = regexpExecAbstract; + +// @@match logic +fixRegExpWellKnownSymbolLogic('match', function (MATCH, nativeMatch, maybeCallNative) { + return [ + // `String.prototype.match` method + // https://tc39.es/ecma262/#sec-string.prototype.match + function match(regexp) { + var O = requireObjectCoercible(this); + var matcher = regexp == undefined ? undefined : getMethod(regexp, MATCH); + return matcher ? call$1(matcher, regexp, O) : new RegExp(regexp)[MATCH](toString$2(O)); + }, + // `RegExp.prototype[@@match]` method + // https://tc39.es/ecma262/#sec-regexp.prototype-@@match + function (string) { + var rx = anObject(this); + var S = toString$2(string); + var res = maybeCallNative(nativeMatch, rx, S); + + if (res.done) return res.value; + + if (!rx.global) return regExpExec(rx, S); + + var fullUnicode = rx.unicode; + rx.lastIndex = 0; + var A = []; + var n = 0; + var result; + while ((result = regExpExec(rx, S)) !== null) { + var matchStr = toString$2(result[0]); + A[n] = matchStr; + if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode); + n++; + } + return n === 0 ? null : A; + } + ]; +}); + +var old = {}; + +var hasRequiredOld; + +function requireOld() { + if (hasRequiredOld) return old; + hasRequiredOld = 1; + var pathModule = require$$2__default["default"]; + var isWindows = process.platform === 'win32'; + var fs = require$$1__default["default"]; + var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG); + + function rethrow() { + var callback; + + if (DEBUG) { + var backtrace = new Error(); + callback = debugCallback; + } else callback = missingCallback; + + return callback; + + function debugCallback(err) { + if (err) { + backtrace.message = err.message; + err = backtrace; + missingCallback(err); + } + } + + function missingCallback(err) { + if (err) { + if (process.throwDeprecation) throw err;else if (!process.noDeprecation) { + var msg = 'fs: missing callback ' + (err.stack || err.message); + if (process.traceDeprecation) console.trace(msg);else console.error(msg); + } + } + } + } + + function maybeCallback(cb) { + return typeof cb === 'function' ? cb : rethrow(); + } + + pathModule.normalize; + + if (isWindows) { + var nextPartRe = /(.*?)(?:[\/\\]+|$)/g; + } else { + var nextPartRe = /(.*?)(?:[\/]+|$)/g; + } + + if (isWindows) { + var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/; + } else { + var splitRootRe = /^[\/]*/; + } + + old.realpathSync = function realpathSync(p, cache) { + p = pathModule.resolve(p); + + if (cache && Object.prototype.hasOwnProperty.call(cache, p)) { + return cache[p]; + } + + var original = p, + seenLinks = {}, + knownHard = {}; + var pos; + var current; + var base; + var previous; + start(); + + function start() { + var m = splitRootRe.exec(p); + pos = m[0].length; + current = m[0]; + base = m[0]; + previous = ''; + + if (isWindows && !knownHard[base]) { + fs.lstatSync(base); + knownHard[base] = true; + } + } + + while (pos < p.length) { + nextPartRe.lastIndex = pos; + var result = nextPartRe.exec(p); + previous = current; + current += result[0]; + base = previous + result[1]; + pos = nextPartRe.lastIndex; + + if (knownHard[base] || cache && cache[base] === base) { + continue; + } + + var resolvedLink; + + if (cache && Object.prototype.hasOwnProperty.call(cache, base)) { + resolvedLink = cache[base]; + } else { + var stat = fs.lstatSync(base); + + if (!stat.isSymbolicLink()) { + knownHard[base] = true; + if (cache) cache[base] = base; + continue; + } + + var linkTarget = null; + + if (!isWindows) { + var id = stat.dev.toString(32) + ':' + stat.ino.toString(32); + + if (seenLinks.hasOwnProperty(id)) { + linkTarget = seenLinks[id]; + } + } + + if (linkTarget === null) { + fs.statSync(base); + linkTarget = fs.readlinkSync(base); + } + + resolvedLink = pathModule.resolve(previous, linkTarget); + if (cache) cache[base] = resolvedLink; + if (!isWindows) seenLinks[id] = linkTarget; + } + + p = pathModule.resolve(resolvedLink, p.slice(pos)); + start(); + } + + if (cache) cache[original] = p; + return p; + }; + + old.realpath = function realpath(p, cache, cb) { + if (typeof cb !== 'function') { + cb = maybeCallback(cache); + cache = null; + } + + p = pathModule.resolve(p); + + if (cache && Object.prototype.hasOwnProperty.call(cache, p)) { + return process.nextTick(cb.bind(null, null, cache[p])); + } + + var original = p, + seenLinks = {}, + knownHard = {}; + var pos; + var current; + var base; + var previous; + start(); + + function start() { + var m = splitRootRe.exec(p); + pos = m[0].length; + current = m[0]; + base = m[0]; + previous = ''; + + if (isWindows && !knownHard[base]) { + fs.lstat(base, function (err) { + if (err) return cb(err); + knownHard[base] = true; + LOOP(); + }); + } else { + process.nextTick(LOOP); + } + } + + function LOOP() { + if (pos >= p.length) { + if (cache) cache[original] = p; + return cb(null, p); + } + + nextPartRe.lastIndex = pos; + var result = nextPartRe.exec(p); + previous = current; + current += result[0]; + base = previous + result[1]; + pos = nextPartRe.lastIndex; + + if (knownHard[base] || cache && cache[base] === base) { + return process.nextTick(LOOP); + } + + if (cache && Object.prototype.hasOwnProperty.call(cache, base)) { + return gotResolvedLink(cache[base]); + } + + return fs.lstat(base, gotStat); + } + + function gotStat(err, stat) { + if (err) return cb(err); + + if (!stat.isSymbolicLink()) { + knownHard[base] = true; + if (cache) cache[base] = base; + return process.nextTick(LOOP); + } + + if (!isWindows) { + var id = stat.dev.toString(32) + ':' + stat.ino.toString(32); + + if (seenLinks.hasOwnProperty(id)) { + return gotTarget(null, seenLinks[id], base); + } + } + + fs.stat(base, function (err) { + if (err) return cb(err); + fs.readlink(base, function (err, target) { + if (!isWindows) seenLinks[id] = target; + gotTarget(err, target); + }); + }); + } + + function gotTarget(err, target, base) { + if (err) return cb(err); + var resolvedLink = pathModule.resolve(previous, target); + if (cache) cache[base] = resolvedLink; + gotResolvedLink(resolvedLink); + } + + function gotResolvedLink(resolvedLink) { + p = pathModule.resolve(resolvedLink, p.slice(pos)); + start(); + } + }; + + return old; +} + +var fs_realpath; +var hasRequiredFs_realpath; + +function requireFs_realpath() { + if (hasRequiredFs_realpath) return fs_realpath; + hasRequiredFs_realpath = 1; + fs_realpath = realpath; + realpath.realpath = realpath; + realpath.sync = realpathSync; + realpath.realpathSync = realpathSync; + realpath.monkeypatch = monkeypatch; + realpath.unmonkeypatch = unmonkeypatch; + var fs = require$$1__default["default"]; + var origRealpath = fs.realpath; + var origRealpathSync = fs.realpathSync; + var version = process.version; + var ok = /^v[0-5]\./.test(version); + var old = requireOld(); + + function newError(er) { + return er && er.syscall === 'realpath' && (er.code === 'ELOOP' || er.code === 'ENOMEM' || er.code === 'ENAMETOOLONG'); + } + + function realpath(p, cache, cb) { + if (ok) { + return origRealpath(p, cache, cb); + } + + if (typeof cache === 'function') { + cb = cache; + cache = null; + } + + origRealpath(p, cache, function (er, result) { + if (newError(er)) { + old.realpath(p, cache, cb); + } else { + cb(er, result); + } + }); + } + + function realpathSync(p, cache) { + if (ok) { + return origRealpathSync(p, cache); + } + + try { + return origRealpathSync(p, cache); + } catch (er) { + if (newError(er)) { + return old.realpathSync(p, cache); + } else { + throw er; + } + } + } + + function monkeypatch() { + fs.realpath = realpath; + fs.realpathSync = realpathSync; + } + + function unmonkeypatch() { + fs.realpath = origRealpath; + fs.realpathSync = origRealpathSync; + } + + return fs_realpath; +} + +var $$5 = _export; +var $filter = arrayIteration.filter; +var arrayMethodHasSpeciesSupport$1 = arrayMethodHasSpeciesSupport$5; + +var HAS_SPECIES_SUPPORT$1 = arrayMethodHasSpeciesSupport$1('filter'); + +// `Array.prototype.filter` method +// https://tc39.es/ecma262/#sec-array.prototype.filter +// with adding support of @@species +$$5({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$1 }, { + filter: function filter(callbackfn /* , thisArg */) { + return $filter(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); + } +}); + +var getBuiltIn$1 = getBuiltIn$8; +var definePropertyModule = objectDefineProperty; +var wellKnownSymbol$1 = wellKnownSymbol$i; +var DESCRIPTORS$2 = descriptors; + +var SPECIES = wellKnownSymbol$1('species'); + +var setSpecies$1 = function (CONSTRUCTOR_NAME) { + var Constructor = getBuiltIn$1(CONSTRUCTOR_NAME); + var defineProperty = definePropertyModule.f; + + if (DESCRIPTORS$2 && Constructor && !Constructor[SPECIES]) { + defineProperty(Constructor, SPECIES, { + configurable: true, + get: function () { return this; } + }); + } +}; + +var DESCRIPTORS$1 = descriptors; +var global$1 = global$f; +var uncurryThis$2 = functionUncurryThis; +var isForced = isForced_1; +var inheritIfRequired = inheritIfRequired$2; +var createNonEnumerableProperty = createNonEnumerableProperty$7; +var getOwnPropertyNames = objectGetOwnPropertyNames.f; +var isPrototypeOf = objectIsPrototypeOf; +var isRegExp = isRegexp; +var toString$1 = toString$a; +var getRegExpFlags = regexpGetFlags; +var stickyHelpers = regexpStickyHelpers; +var proxyAccessor = proxyAccessor$2; +var defineBuiltIn = defineBuiltIn$5; +var fails$2 = fails$p; +var hasOwn = hasOwnProperty_1; +var enforceInternalState = internalState.enforce; +var setSpecies = setSpecies$1; +var wellKnownSymbol = wellKnownSymbol$i; +var UNSUPPORTED_DOT_ALL$1 = regexpUnsupportedDotAll; +var UNSUPPORTED_NCG = regexpUnsupportedNcg; + +var MATCH = wellKnownSymbol('match'); +var NativeRegExp = global$1.RegExp; +var RegExpPrototype$1 = NativeRegExp.prototype; +var SyntaxError = global$1.SyntaxError; +var exec$3 = uncurryThis$2(RegExpPrototype$1.exec); +var charAt$1 = uncurryThis$2(''.charAt); +var replace$1 = uncurryThis$2(''.replace); +var stringIndexOf = uncurryThis$2(''.indexOf); +var stringSlice = uncurryThis$2(''.slice); +// TODO: Use only proper RegExpIdentifierName +var IS_NCG = /^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/; +var re1 = /a/g; +var re2 = /a/g; + +// "new" should create a new object, old webkit bug +var CORRECT_NEW = new NativeRegExp(re1) !== re1; + +var MISSED_STICKY = stickyHelpers.MISSED_STICKY; +var UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y; + +var BASE_FORCED = DESCRIPTORS$1 && + (!CORRECT_NEW || MISSED_STICKY || UNSUPPORTED_DOT_ALL$1 || UNSUPPORTED_NCG || fails$2(function () { + re2[MATCH] = false; + // RegExp constructor can alter flags and IsRegExp works correct with @@match + return NativeRegExp(re1) != re1 || NativeRegExp(re2) == re2 || NativeRegExp(re1, 'i') != '/a/i'; + })); + +var handleDotAll = function (string) { + var length = string.length; + var index = 0; + var result = ''; + var brackets = false; + var chr; + for (; index <= length; index++) { + chr = charAt$1(string, index); + if (chr === '\\') { + result += chr + charAt$1(string, ++index); + continue; + } + if (!brackets && chr === '.') { + result += '[\\s\\S]'; + } else { + if (chr === '[') { + brackets = true; + } else if (chr === ']') { + brackets = false; + } result += chr; + } + } return result; +}; + +var handleNCG = function (string) { + var length = string.length; + var index = 0; + var result = ''; + var named = []; + var names = {}; + var brackets = false; + var ncg = false; + var groupid = 0; + var groupname = ''; + var chr; + for (; index <= length; index++) { + chr = charAt$1(string, index); + if (chr === '\\') { + chr = chr + charAt$1(string, ++index); + } else if (chr === ']') { + brackets = false; + } else if (!brackets) switch (true) { + case chr === '[': + brackets = true; + break; + case chr === '(': + if (exec$3(IS_NCG, stringSlice(string, index + 1))) { + index += 2; + ncg = true; + } + result += chr; + groupid++; + continue; + case chr === '>' && ncg: + if (groupname === '' || hasOwn(names, groupname)) { + throw new SyntaxError('Invalid capture group name'); + } + names[groupname] = true; + named[named.length] = [groupname, groupid]; + ncg = false; + groupname = ''; + continue; + } + if (ncg) groupname += chr; + else result += chr; + } return [result, named]; +}; + +// `RegExp` constructor +// https://tc39.es/ecma262/#sec-regexp-constructor +if (isForced('RegExp', BASE_FORCED)) { + var RegExpWrapper = function RegExp(pattern, flags) { + var thisIsRegExp = isPrototypeOf(RegExpPrototype$1, this); + var patternIsRegExp = isRegExp(pattern); + var flagsAreUndefined = flags === undefined; + var groups = []; + var rawPattern = pattern; + var rawFlags, dotAll, sticky, handled, result, state; + + if (!thisIsRegExp && patternIsRegExp && flagsAreUndefined && pattern.constructor === RegExpWrapper) { + return pattern; + } + + if (patternIsRegExp || isPrototypeOf(RegExpPrototype$1, pattern)) { + pattern = pattern.source; + if (flagsAreUndefined) flags = getRegExpFlags(rawPattern); + } + + pattern = pattern === undefined ? '' : toString$1(pattern); + flags = flags === undefined ? '' : toString$1(flags); + rawPattern = pattern; + + if (UNSUPPORTED_DOT_ALL$1 && 'dotAll' in re1) { + dotAll = !!flags && stringIndexOf(flags, 's') > -1; + if (dotAll) flags = replace$1(flags, /s/g, ''); + } + + rawFlags = flags; + + if (MISSED_STICKY && 'sticky' in re1) { + sticky = !!flags && stringIndexOf(flags, 'y') > -1; + if (sticky && UNSUPPORTED_Y) flags = replace$1(flags, /y/g, ''); + } + + if (UNSUPPORTED_NCG) { + handled = handleNCG(pattern); + pattern = handled[0]; + groups = handled[1]; + } + + result = inheritIfRequired(NativeRegExp(pattern, flags), thisIsRegExp ? this : RegExpPrototype$1, RegExpWrapper); + + if (dotAll || sticky || groups.length) { + state = enforceInternalState(result); + if (dotAll) { + state.dotAll = true; + state.raw = RegExpWrapper(handleDotAll(pattern), rawFlags); + } + if (sticky) state.sticky = true; + if (groups.length) state.groups = groups; + } + + if (pattern !== rawPattern) try { + // fails in old engines, but we have no alternatives for unsupported regex syntax + createNonEnumerableProperty(result, 'source', rawPattern === '' ? '(?:)' : rawPattern); + } catch (error) { /* empty */ } + + return result; + }; + + for (var keys = getOwnPropertyNames(NativeRegExp), index = 0; keys.length > index;) { + proxyAccessor(RegExpWrapper, NativeRegExp, keys[index++]); + } + + RegExpPrototype$1.constructor = RegExpWrapper; + RegExpWrapper.prototype = RegExpPrototype$1; + defineBuiltIn(global$1, 'RegExp', RegExpWrapper, { constructor: true }); +} + +// https://tc39.es/ecma262/#sec-get-regexp-@@species +setSpecies('RegExp'); + +var makeBuiltIn = makeBuiltIn$3.exports; +var defineProperty = objectDefineProperty; + +var defineBuiltInAccessor$1 = function (target, name, descriptor) { + if (descriptor.get) makeBuiltIn(descriptor.get, name, { getter: true }); + if (descriptor.set) makeBuiltIn(descriptor.set, name, { setter: true }); + return defineProperty.f(target, name, descriptor); +}; + +var DESCRIPTORS = descriptors; +var UNSUPPORTED_DOT_ALL = regexpUnsupportedDotAll; +var classof = classofRaw$1; +var defineBuiltInAccessor = defineBuiltInAccessor$1; +var getInternalState = internalState.get; + +var RegExpPrototype = RegExp.prototype; +var $TypeError$1 = TypeError; + +// `RegExp.prototype.dotAll` getter +// https://tc39.es/ecma262/#sec-get-regexp.prototype.dotall +if (DESCRIPTORS && UNSUPPORTED_DOT_ALL) { + defineBuiltInAccessor(RegExpPrototype, 'dotAll', { + configurable: true, + get: function dotAll() { + if (this === RegExpPrototype) return undefined; + // We can't use InternalStateModule.getterFor because + // we don't add metadata for regexps created by a literal. + if (classof(this) === 'RegExp') { + return !!getInternalState(this).dotAll; + } + throw $TypeError$1('Incompatible receiver, RegExp required'); + } + }); +} + +var concatMap; +var hasRequiredConcatMap; + +function requireConcatMap() { + if (hasRequiredConcatMap) return concatMap; + hasRequiredConcatMap = 1; + + concatMap = function concatMap(xs, fn) { + var res = []; + + for (var i = 0; i < xs.length; i++) { + var x = fn(xs[i], i); + if (isArray(x)) res.push.apply(res, x);else res.push(x); + } + + return res; + }; + + var isArray = Array.isArray || function (xs) { + return Object.prototype.toString.call(xs) === '[object Array]'; + }; + + return concatMap; +} + +var balancedMatch; +var hasRequiredBalancedMatch; + +function requireBalancedMatch() { + if (hasRequiredBalancedMatch) return balancedMatch; + hasRequiredBalancedMatch = 1; + + balancedMatch = balanced; + + function balanced(a, b, str) { + if (a instanceof RegExp) a = maybeMatch(a, str); + if (b instanceof RegExp) b = maybeMatch(b, str); + var r = range(a, b, str); + return r && { + start: r[0], + end: r[1], + pre: str.slice(0, r[0]), + body: str.slice(r[0] + a.length, r[1]), + post: str.slice(r[1] + b.length) + }; + } + + function maybeMatch(reg, str) { + var m = str.match(reg); + return m ? m[0] : null; + } + + balanced.range = range; + + function range(a, b, str) { + var begs, beg, left, right, result; + var ai = str.indexOf(a); + var bi = str.indexOf(b, ai + 1); + var i = ai; + + if (ai >= 0 && bi > 0) { + begs = []; + left = str.length; + + while (i >= 0 && !result) { + if (i == ai) { + begs.push(i); + ai = str.indexOf(a, i + 1); + } else if (begs.length == 1) { + result = [begs.pop(), bi]; + } else { + beg = begs.pop(); + + if (beg < left) { + left = beg; + right = bi; + } + + bi = str.indexOf(b, i + 1); + } + + i = ai < bi && ai >= 0 ? ai : bi; + } + + if (begs.length) { + result = [left, right]; + } + } + + return result; + } + + return balancedMatch; +} + +var braceExpansion; +var hasRequiredBraceExpansion; + +function requireBraceExpansion() { + if (hasRequiredBraceExpansion) return braceExpansion; + hasRequiredBraceExpansion = 1; + var concatMap = requireConcatMap(); + var balanced = requireBalancedMatch(); + braceExpansion = expandTop; + var escSlash = '\0SLASH' + Math.random() + '\0'; + var escOpen = '\0OPEN' + Math.random() + '\0'; + var escClose = '\0CLOSE' + Math.random() + '\0'; + var escComma = '\0COMMA' + Math.random() + '\0'; + var escPeriod = '\0PERIOD' + Math.random() + '\0'; + + function numeric(str) { + return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0); + } + + function escapeBraces(str) { + return str.split('\\\\').join(escSlash).split('\\{').join(escOpen).split('\\}').join(escClose).split('\\,').join(escComma).split('\\.').join(escPeriod); + } + + function unescapeBraces(str) { + return str.split(escSlash).join('\\').split(escOpen).join('{').split(escClose).join('}').split(escComma).join(',').split(escPeriod).join('.'); + } + + function parseCommaParts(str) { + if (!str) return ['']; + var parts = []; + var m = balanced('{', '}', str); + if (!m) return str.split(','); + var pre = m.pre; + var body = m.body; + var post = m.post; + var p = pre.split(','); + p[p.length - 1] += '{' + body + '}'; + var postParts = parseCommaParts(post); + + if (post.length) { + p[p.length - 1] += postParts.shift(); + p.push.apply(p, postParts); + } + + parts.push.apply(parts, p); + return parts; + } + + function expandTop(str) { + if (!str) return []; + + if (str.substr(0, 2) === '{}') { + str = '\\{\\}' + str.substr(2); + } + + return expand(escapeBraces(str), true).map(unescapeBraces); + } + + function embrace(str) { + return '{' + str + '}'; + } + + function isPadded(el) { + return /^-?0\d/.test(el); + } + + function lte(i, y) { + return i <= y; + } + + function gte(i, y) { + return i >= y; + } + + function expand(str, isTop) { + var expansions = []; + var m = balanced('{', '}', str); + if (!m || /\$$/.test(m.pre)) return [str]; + var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body); + var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body); + var isSequence = isNumericSequence || isAlphaSequence; + var isOptions = m.body.indexOf(',') >= 0; + + if (!isSequence && !isOptions) { + if (m.post.match(/,.*\}/)) { + str = m.pre + '{' + m.body + escClose + m.post; + return expand(str); + } + + return [str]; + } + + var n; + + if (isSequence) { + n = m.body.split(/\.\./); + } else { + n = parseCommaParts(m.body); + + if (n.length === 1) { + n = expand(n[0], false).map(embrace); + + if (n.length === 1) { + var post = m.post.length ? expand(m.post, false) : ['']; + return post.map(function (p) { + return m.pre + n[0] + p; + }); + } + } + } + + var pre = m.pre; + var post = m.post.length ? expand(m.post, false) : ['']; + var N; + + if (isSequence) { + var x = numeric(n[0]); + var y = numeric(n[1]); + var width = Math.max(n[0].length, n[1].length); + var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1; + var test = lte; + var reverse = y < x; + + if (reverse) { + incr *= -1; + test = gte; + } + + var pad = n.some(isPadded); + N = []; + + for (var i = x; test(i, y); i += incr) { + var c; + + if (isAlphaSequence) { + c = String.fromCharCode(i); + if (c === '\\') c = ''; + } else { + c = String(i); + + if (pad) { + var need = width - c.length; + + if (need > 0) { + var z = new Array(need + 1).join('0'); + if (i < 0) c = '-' + z + c.slice(1);else c = z + c; + } + } + } + + N.push(c); + } + } else { + N = concatMap(n, function (el) { + return expand(el, false); + }); + } + + for (var j = 0; j < N.length; j++) { + for (var k = 0; k < post.length; k++) { + var expansion = pre + N[j] + post[k]; + if (!isTop || isSequence || expansion) expansions.push(expansion); + } + } + + return expansions; + } + + return braceExpansion; +} + +var minimatch_1; +var hasRequiredMinimatch; + +function requireMinimatch() { + if (hasRequiredMinimatch) return minimatch_1; + hasRequiredMinimatch = 1; + minimatch_1 = minimatch; + minimatch.Minimatch = Minimatch; + var path = { + sep: '/' + }; + + try { + path = require('path'); + } catch (er) {} + + var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}; + var expand = requireBraceExpansion(); + var plTypes = { + '!': { + open: '(?:(?!(?:', + close: '))[^/]*?)' + }, + '?': { + open: '(?:', + close: ')?' + }, + '+': { + open: '(?:', + close: ')+' + }, + '*': { + open: '(?:', + close: ')*' + }, + '@': { + open: '(?:', + close: ')' + } + }; + var qmark = '[^/]'; + var star = qmark + '*?'; + var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?'; + var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?'; + var reSpecials = charSet('().*{}+?[]^$\\!'); + + function charSet(s) { + return s.split('').reduce(function (set, c) { + set[c] = true; + return set; + }, {}); + } + + var slashSplit = /\/+/; + minimatch.filter = filter; + + function filter(pattern, options) { + options = options || {}; + return function (p, i, list) { + return minimatch(p, pattern, options); + }; + } + + function ext(a, b) { + a = a || {}; + b = b || {}; + var t = {}; + Object.keys(b).forEach(function (k) { + t[k] = b[k]; + }); + Object.keys(a).forEach(function (k) { + t[k] = a[k]; + }); + return t; + } + + minimatch.defaults = function (def) { + if (!def || !Object.keys(def).length) return minimatch; + var orig = minimatch; + + var m = function minimatch(p, pattern, options) { + return orig.minimatch(p, pattern, ext(def, options)); + }; + + m.Minimatch = function Minimatch(pattern, options) { + return new orig.Minimatch(pattern, ext(def, options)); + }; + + return m; + }; + + Minimatch.defaults = function (def) { + if (!def || !Object.keys(def).length) return Minimatch; + return minimatch.defaults(def).Minimatch; + }; + + function minimatch(p, pattern, options) { + if (typeof pattern !== 'string') { + throw new TypeError('glob pattern string required'); + } + + if (!options) options = {}; + + if (!options.nocomment && pattern.charAt(0) === '#') { + return false; + } + + if (pattern.trim() === '') return p === ''; + return new Minimatch(pattern, options).match(p); + } + + function Minimatch(pattern, options) { + if (!(this instanceof Minimatch)) { + return new Minimatch(pattern, options); + } + + if (typeof pattern !== 'string') { + throw new TypeError('glob pattern string required'); + } + + if (!options) options = {}; + pattern = pattern.trim(); + + if (path.sep !== '/') { + pattern = pattern.split(path.sep).join('/'); + } + + this.options = options; + this.set = []; + this.pattern = pattern; + this.regexp = null; + this.negate = false; + this.comment = false; + this.empty = false; + this.make(); + } + + Minimatch.prototype.debug = function () {}; + + Minimatch.prototype.make = make; + + function make() { + if (this._made) return; + var pattern = this.pattern; + var options = this.options; + + if (!options.nocomment && pattern.charAt(0) === '#') { + this.comment = true; + return; + } + + if (!pattern) { + this.empty = true; + return; + } + + this.parseNegate(); + var set = this.globSet = this.braceExpand(); + if (options.debug) this.debug = console.error; + this.debug(this.pattern, set); + set = this.globParts = set.map(function (s) { + return s.split(slashSplit); + }); + this.debug(this.pattern, set); + set = set.map(function (s, si, set) { + return s.map(this.parse, this); + }, this); + this.debug(this.pattern, set); + set = set.filter(function (s) { + return s.indexOf(false) === -1; + }); + this.debug(this.pattern, set); + this.set = set; + } + + Minimatch.prototype.parseNegate = parseNegate; + + function parseNegate() { + var pattern = this.pattern; + var negate = false; + var options = this.options; + var negateOffset = 0; + if (options.nonegate) return; + + for (var i = 0, l = pattern.length; i < l && pattern.charAt(i) === '!'; i++) { + negate = !negate; + negateOffset++; + } + + if (negateOffset) this.pattern = pattern.substr(negateOffset); + this.negate = negate; + } + + minimatch.braceExpand = function (pattern, options) { + return braceExpand(pattern, options); + }; + + Minimatch.prototype.braceExpand = braceExpand; + + function braceExpand(pattern, options) { + if (!options) { + if (this instanceof Minimatch) { + options = this.options; + } else { + options = {}; + } + } + + pattern = typeof pattern === 'undefined' ? this.pattern : pattern; + + if (typeof pattern === 'undefined') { + throw new TypeError('undefined pattern'); + } + + if (options.nobrace || !pattern.match(/\{.*\}/)) { + return [pattern]; + } + + return expand(pattern); + } + + Minimatch.prototype.parse = parse; + var SUBPARSE = {}; + + function parse(pattern, isSub) { + if (pattern.length > 1024 * 64) { + throw new TypeError('pattern is too long'); + } + + var options = this.options; + if (!options.noglobstar && pattern === '**') return GLOBSTAR; + if (pattern === '') return ''; + var re = ''; + var hasMagic = !!options.nocase; + var escaping = false; + var patternListStack = []; + var negativeLists = []; + var stateChar; + var inClass = false; + var reClassStart = -1; + var classStart = -1; + var patternStart = pattern.charAt(0) === '.' ? '' : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' : '(?!\\.)'; + var self = this; + + function clearStateChar() { + if (stateChar) { + switch (stateChar) { + case '*': + re += star; + hasMagic = true; + break; + + case '?': + re += qmark; + hasMagic = true; + break; + + default: + re += '\\' + stateChar; + break; + } + + self.debug('clearStateChar %j %j', stateChar, re); + stateChar = false; + } + } + + for (var i = 0, len = pattern.length, c; i < len && (c = pattern.charAt(i)); i++) { + this.debug('%s\t%s %s %j', pattern, i, re, c); + + if (escaping && reSpecials[c]) { + re += '\\' + c; + escaping = false; + continue; + } + + switch (c) { + case '/': + return false; + + case '\\': + clearStateChar(); + escaping = true; + continue; + + case '?': + case '*': + case '+': + case '@': + case '!': + this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c); + + if (inClass) { + this.debug(' in class'); + if (c === '!' && i === classStart + 1) c = '^'; + re += c; + continue; + } + + self.debug('call clearStateChar %j', stateChar); + clearStateChar(); + stateChar = c; + if (options.noext) clearStateChar(); + continue; + + case '(': + if (inClass) { + re += '('; + continue; + } + + if (!stateChar) { + re += '\\('; + continue; + } + + patternListStack.push({ + type: stateChar, + start: i - 1, + reStart: re.length, + open: plTypes[stateChar].open, + close: plTypes[stateChar].close + }); + re += stateChar === '!' ? '(?:(?!(?:' : '(?:'; + this.debug('plType %j %j', stateChar, re); + stateChar = false; + continue; + + case ')': + if (inClass || !patternListStack.length) { + re += '\\)'; + continue; + } + + clearStateChar(); + hasMagic = true; + var pl = patternListStack.pop(); + re += pl.close; + + if (pl.type === '!') { + negativeLists.push(pl); + } + + pl.reEnd = re.length; + continue; + + case '|': + if (inClass || !patternListStack.length || escaping) { + re += '\\|'; + escaping = false; + continue; + } + + clearStateChar(); + re += '|'; + continue; + + case '[': + clearStateChar(); + + if (inClass) { + re += '\\' + c; + continue; + } + + inClass = true; + classStart = i; + reClassStart = re.length; + re += c; + continue; + + case ']': + if (i === classStart + 1 || !inClass) { + re += '\\' + c; + escaping = false; + continue; + } + + if (inClass) { + var cs = pattern.substring(classStart + 1, i); + + try { + RegExp('[' + cs + ']'); + } catch (er) { + var sp = this.parse(cs, SUBPARSE); + re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'; + hasMagic = hasMagic || sp[1]; + inClass = false; + continue; + } + } + + hasMagic = true; + inClass = false; + re += c; + continue; + + default: + clearStateChar(); + + if (escaping) { + escaping = false; + } else if (reSpecials[c] && !(c === '^' && inClass)) { + re += '\\'; + } + + re += c; + } + } + + if (inClass) { + cs = pattern.substr(classStart + 1); + sp = this.parse(cs, SUBPARSE); + re = re.substr(0, reClassStart) + '\\[' + sp[0]; + hasMagic = hasMagic || sp[1]; + } + + for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) { + var tail = re.slice(pl.reStart + pl.open.length); + this.debug('setting tail', re, pl); + tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) { + if (!$2) { + $2 = '\\'; + } + + return $1 + $1 + $2 + '|'; + }); + this.debug('tail=%j\n %s', tail, tail, pl, re); + var t = pl.type === '*' ? star : pl.type === '?' ? qmark : '\\' + pl.type; + hasMagic = true; + re = re.slice(0, pl.reStart) + t + '\\(' + tail; + } + + clearStateChar(); + + if (escaping) { + re += '\\\\'; + } + + var addPatternStart = false; + + switch (re.charAt(0)) { + case '.': + case '[': + case '(': + addPatternStart = true; + } + + for (var n = negativeLists.length - 1; n > -1; n--) { + var nl = negativeLists[n]; + var nlBefore = re.slice(0, nl.reStart); + var nlFirst = re.slice(nl.reStart, nl.reEnd - 8); + var nlLast = re.slice(nl.reEnd - 8, nl.reEnd); + var nlAfter = re.slice(nl.reEnd); + nlLast += nlAfter; + var openParensBefore = nlBefore.split('(').length - 1; + var cleanAfter = nlAfter; + + for (i = 0; i < openParensBefore; i++) { + cleanAfter = cleanAfter.replace(/\)[+*?]?/, ''); + } + + nlAfter = cleanAfter; + var dollar = ''; + + if (nlAfter === '' && isSub !== SUBPARSE) { + dollar = '$'; + } + + var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast; + re = newRe; + } + + if (re !== '' && hasMagic) { + re = '(?=.)' + re; + } + + if (addPatternStart) { + re = patternStart + re; + } + + if (isSub === SUBPARSE) { + return [re, hasMagic]; + } + + if (!hasMagic) { + return globUnescape(pattern); + } + + var flags = options.nocase ? 'i' : ''; + + try { + var regExp = new RegExp('^' + re + '$', flags); + } catch (er) { + return new RegExp('$.'); + } + + regExp._glob = pattern; + regExp._src = re; + return regExp; + } + + minimatch.makeRe = function (pattern, options) { + return new Minimatch(pattern, options || {}).makeRe(); + }; + + Minimatch.prototype.makeRe = makeRe; + + function makeRe() { + if (this.regexp || this.regexp === false) return this.regexp; + var set = this.set; + + if (!set.length) { + this.regexp = false; + return this.regexp; + } + + var options = this.options; + var twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot; + var flags = options.nocase ? 'i' : ''; + var re = set.map(function (pattern) { + return pattern.map(function (p) { + return p === GLOBSTAR ? twoStar : typeof p === 'string' ? regExpEscape(p) : p._src; + }).join('\\\/'); + }).join('|'); + re = '^(?:' + re + ')$'; + if (this.negate) re = '^(?!' + re + ').*$'; + + try { + this.regexp = new RegExp(re, flags); + } catch (ex) { + this.regexp = false; + } + + return this.regexp; + } + + minimatch.match = function (list, pattern, options) { + options = options || {}; + var mm = new Minimatch(pattern, options); + list = list.filter(function (f) { + return mm.match(f); + }); + + if (mm.options.nonull && !list.length) { + list.push(pattern); + } + + return list; + }; + + Minimatch.prototype.match = match; + + function match(f, partial) { + this.debug('match', f, this.pattern); + if (this.comment) return false; + if (this.empty) return f === ''; + if (f === '/' && partial) return true; + var options = this.options; + + if (path.sep !== '/') { + f = f.split(path.sep).join('/'); + } + + f = f.split(slashSplit); + this.debug(this.pattern, 'split', f); + var set = this.set; + this.debug(this.pattern, 'set', set); + var filename; + var i; + + for (i = f.length - 1; i >= 0; i--) { + filename = f[i]; + if (filename) break; + } + + for (i = 0; i < set.length; i++) { + var pattern = set[i]; + var file = f; + + if (options.matchBase && pattern.length === 1) { + file = [filename]; + } + + var hit = this.matchOne(file, pattern, partial); + + if (hit) { + if (options.flipNegate) return true; + return !this.negate; + } + } + + if (options.flipNegate) return false; + return this.negate; + } + + Minimatch.prototype.matchOne = function (file, pattern, partial) { + var options = this.options; + this.debug('matchOne', { + 'this': this, + file: file, + pattern: pattern + }); + this.debug('matchOne', file.length, pattern.length); + + for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) { + this.debug('matchOne loop'); + var p = pattern[pi]; + var f = file[fi]; + this.debug(pattern, p, f); + if (p === false) return false; + + if (p === GLOBSTAR) { + this.debug('GLOBSTAR', [pattern, p, f]); + var fr = fi; + var pr = pi + 1; + + if (pr === pl) { + this.debug('** at the end'); + + for (; fi < fl; fi++) { + if (file[fi] === '.' || file[fi] === '..' || !options.dot && file[fi].charAt(0) === '.') return false; + } + + return true; + } + + while (fr < fl) { + var swallowee = file[fr]; + this.debug('\nglobstar while', file, fr, pattern, pr, swallowee); + + if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) { + this.debug('globstar found match!', fr, fl, swallowee); + return true; + } else { + if (swallowee === '.' || swallowee === '..' || !options.dot && swallowee.charAt(0) === '.') { + this.debug('dot detected!', file, fr, pattern, pr); + break; + } + + this.debug('globstar swallow a segment, and continue'); + fr++; + } + } + + if (partial) { + this.debug('\n>>> no match, partial?', file, fr, pattern, pr); + if (fr === fl) return true; + } + + return false; + } + + var hit; + + if (typeof p === 'string') { + if (options.nocase) { + hit = f.toLowerCase() === p.toLowerCase(); + } else { + hit = f === p; + } + + this.debug('string match', p, f, hit); + } else { + hit = f.match(p); + this.debug('pattern match', p, f, hit); + } + + if (!hit) return false; + } + + if (fi === fl && pi === pl) { + return true; + } else if (fi === fl) { + return partial; + } else if (pi === pl) { + var emptyFileEnd = fi === fl - 1 && file[fi] === ''; + return emptyFileEnd; + } + + throw new Error('wtf?'); + }; + + function globUnescape(s) { + return s.replace(/\\(.)/g, '$1'); + } + + function regExpEscape(s) { + return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); + } + + return minimatch_1; +} + +var inherits = {exports: {}}; + +var inherits_browser = {exports: {}}; + +var hasRequiredInherits_browser; + +function requireInherits_browser() { + if (hasRequiredInherits_browser) return inherits_browser.exports; + hasRequiredInherits_browser = 1; + + if (typeof Object.create === 'function') { + inherits_browser.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor; + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }); + } + }; + } else { + inherits_browser.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor; + + var TempCtor = function TempCtor() {}; + + TempCtor.prototype = superCtor.prototype; + ctor.prototype = new TempCtor(); + ctor.prototype.constructor = ctor; + } + }; + } + + return inherits_browser.exports; +} + +var hasRequiredInherits; + +function requireInherits() { + if (hasRequiredInherits) return inherits.exports; + hasRequiredInherits = 1; + + (function (module) { + try { + var util = require('util'); + + if (typeof util.inherits !== 'function') throw ''; + module.exports = util.inherits; + } catch (e) { + module.exports = requireInherits_browser(); + } + })(inherits); + + return inherits.exports; +} + +var pathIsAbsolute = {exports: {}}; + +var hasRequiredPathIsAbsolute; + +function requirePathIsAbsolute() { + if (hasRequiredPathIsAbsolute) return pathIsAbsolute.exports; + hasRequiredPathIsAbsolute = 1; + + function posix(path) { + return path.charAt(0) === '/'; + } + + function win32(path) { + var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/; + var result = splitDeviceRe.exec(path); + var device = result[1] || ''; + var isUnc = Boolean(device && device.charAt(1) !== ':'); + return Boolean(result[2] || isUnc); + } + + pathIsAbsolute.exports = process.platform === 'win32' ? win32 : posix; + pathIsAbsolute.exports.posix = posix; + pathIsAbsolute.exports.win32 = win32; + return pathIsAbsolute.exports; +} + +var tryToString = tryToString$3; + +var $TypeError = TypeError; + +var deletePropertyOrThrow$2 = function (O, P) { + if (!delete O[P]) throw $TypeError('Cannot delete property ' + tryToString(P) + ' of ' + tryToString(O)); +}; + +var arraySlice$1 = arraySliceSimple; + +var floor = Math.floor; + +var mergeSort = function (array, comparefn) { + var length = array.length; + var middle = floor(length / 2); + return length < 8 ? insertionSort(array, comparefn) : merge( + array, + mergeSort(arraySlice$1(array, 0, middle), comparefn), + mergeSort(arraySlice$1(array, middle), comparefn), + comparefn + ); +}; + +var insertionSort = function (array, comparefn) { + var length = array.length; + var i = 1; + var element, j; + + while (i < length) { + j = i; + element = array[i]; + while (j && comparefn(array[j - 1], element) > 0) { + array[j] = array[--j]; + } + if (j !== i++) array[j] = element; + } return array; +}; + +var merge = function (array, left, right, comparefn) { + var llength = left.length; + var rlength = right.length; + var lindex = 0; + var rindex = 0; + + while (lindex < llength || rindex < rlength) { + array[lindex + rindex] = (lindex < llength && rindex < rlength) + ? comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++] + : lindex < llength ? left[lindex++] : right[rindex++]; + } return array; +}; + +var arraySort = mergeSort; + +var userAgent$1 = engineUserAgent; + +var firefox = userAgent$1.match(/firefox\/(\d+)/i); + +var engineFfVersion = !!firefox && +firefox[1]; + +var UA = engineUserAgent; + +var engineIsIeOrEdge = /MSIE|Trident/.test(UA); + +var userAgent = engineUserAgent; + +var webkit = userAgent.match(/AppleWebKit\/(\d+)\./); + +var engineWebkitVersion = !!webkit && +webkit[1]; + +var $$4 = _export; +var uncurryThis$1 = functionUncurryThis; +var aCallable = aCallable$3; +var toObject$1 = toObject$7; +var lengthOfArrayLike$1 = lengthOfArrayLike$7; +var deletePropertyOrThrow$1 = deletePropertyOrThrow$2; +var toString = toString$a; +var fails$1 = fails$p; +var internalSort = arraySort; +var arrayMethodIsStrict = arrayMethodIsStrict$2; +var FF = engineFfVersion; +var IE_OR_EDGE = engineIsIeOrEdge; +var V8 = engineV8Version; +var WEBKIT = engineWebkitVersion; + +var test$1 = []; +var un$Sort = uncurryThis$1(test$1.sort); +var push = uncurryThis$1(test$1.push); + +// IE8- +var FAILS_ON_UNDEFINED = fails$1(function () { + test$1.sort(undefined); +}); +// V8 bug +var FAILS_ON_NULL = fails$1(function () { + test$1.sort(null); +}); +// Old WebKit +var STRICT_METHOD = arrayMethodIsStrict('sort'); + +var STABLE_SORT = !fails$1(function () { + // feature detection can be too slow, so check engines versions + if (V8) return V8 < 70; + if (FF && FF > 3) return; + if (IE_OR_EDGE) return true; + if (WEBKIT) return WEBKIT < 603; + + var result = ''; + var code, chr, value, index; + + // generate an array with more 512 elements (Chakra and old V8 fails only in this case) + for (code = 65; code < 76; code++) { + chr = String.fromCharCode(code); + + switch (code) { + case 66: case 69: case 70: case 72: value = 3; break; + case 68: case 71: value = 4; break; + default: value = 2; + } + + for (index = 0; index < 47; index++) { + test$1.push({ k: chr + index, v: value }); + } + } + + test$1.sort(function (a, b) { return b.v - a.v; }); + + for (index = 0; index < test$1.length; index++) { + chr = test$1[index].k.charAt(0); + if (result.charAt(result.length - 1) !== chr) result += chr; + } + + return result !== 'DGBEFHACIJK'; +}); + +var FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD || !STABLE_SORT; + +var getSortCompare = function (comparefn) { + return function (x, y) { + if (y === undefined) return -1; + if (x === undefined) return 1; + if (comparefn !== undefined) return +comparefn(x, y) || 0; + return toString(x) > toString(y) ? 1 : -1; + }; +}; + +// `Array.prototype.sort` method +// https://tc39.es/ecma262/#sec-array.prototype.sort +$$4({ target: 'Array', proto: true, forced: FORCED }, { + sort: function sort(comparefn) { + if (comparefn !== undefined) aCallable(comparefn); + + var array = toObject$1(this); + + if (STABLE_SORT) return comparefn === undefined ? un$Sort(array) : un$Sort(array, comparefn); + + var items = []; + var arrayLength = lengthOfArrayLike$1(array); + var itemsLength, index; + + for (index = 0; index < arrayLength; index++) { + if (index in array) push(items, array[index]); + } + + internalSort(items, getSortCompare(comparefn)); + + itemsLength = items.length; + index = 0; + + while (index < itemsLength) array[index] = items[index++]; + while (index < arrayLength) deletePropertyOrThrow$1(array, index++); + + return array; + } +}); + +var common$1 = {}; + +var hasRequiredCommon$1; + +function requireCommon$1() { + if (hasRequiredCommon$1) return common$1; + hasRequiredCommon$1 = 1; + common$1.setopts = setopts; + common$1.ownProp = ownProp; + common$1.makeAbs = makeAbs; + common$1.finish = finish; + common$1.mark = mark; + common$1.isIgnored = isIgnored; + common$1.childrenIgnored = childrenIgnored; + + function ownProp(obj, field) { + return Object.prototype.hasOwnProperty.call(obj, field); + } + + var path = require$$2__default["default"]; + var minimatch = requireMinimatch(); + var isAbsolute = requirePathIsAbsolute(); + var Minimatch = minimatch.Minimatch; + + function alphasort(a, b) { + return a.localeCompare(b, 'en'); + } + + function setupIgnores(self, options) { + self.ignore = options.ignore || []; + if (!Array.isArray(self.ignore)) self.ignore = [self.ignore]; + + if (self.ignore.length) { + self.ignore = self.ignore.map(ignoreMap); + } + } + + function ignoreMap(pattern) { + var gmatcher = null; + + if (pattern.slice(-3) === '/**') { + var gpattern = pattern.replace(/(\/\*\*)+$/, ''); + gmatcher = new Minimatch(gpattern, { + dot: true + }); + } + + return { + matcher: new Minimatch(pattern, { + dot: true + }), + gmatcher: gmatcher + }; + } + + function setopts(self, pattern, options) { + if (!options) options = {}; + + if (options.matchBase && -1 === pattern.indexOf("/")) { + if (options.noglobstar) { + throw new Error("base matching requires globstar"); + } + + pattern = "**/" + pattern; + } + + self.silent = !!options.silent; + self.pattern = pattern; + self.strict = options.strict !== false; + self.realpath = !!options.realpath; + self.realpathCache = options.realpathCache || Object.create(null); + self.follow = !!options.follow; + self.dot = !!options.dot; + self.mark = !!options.mark; + self.nodir = !!options.nodir; + if (self.nodir) self.mark = true; + self.sync = !!options.sync; + self.nounique = !!options.nounique; + self.nonull = !!options.nonull; + self.nosort = !!options.nosort; + self.nocase = !!options.nocase; + self.stat = !!options.stat; + self.noprocess = !!options.noprocess; + self.absolute = !!options.absolute; + self.maxLength = options.maxLength || Infinity; + self.cache = options.cache || Object.create(null); + self.statCache = options.statCache || Object.create(null); + self.symlinks = options.symlinks || Object.create(null); + setupIgnores(self, options); + self.changedCwd = false; + var cwd = process.cwd(); + if (!ownProp(options, "cwd")) self.cwd = cwd;else { + self.cwd = path.resolve(options.cwd); + self.changedCwd = self.cwd !== cwd; + } + self.root = options.root || path.resolve(self.cwd, "/"); + self.root = path.resolve(self.root); + if (process.platform === "win32") self.root = self.root.replace(/\\/g, "/"); + self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd); + if (process.platform === "win32") self.cwdAbs = self.cwdAbs.replace(/\\/g, "/"); + self.nomount = !!options.nomount; + options.nonegate = true; + options.nocomment = true; + self.minimatch = new Minimatch(pattern, options); + self.options = self.minimatch.options; + } + + function finish(self) { + var nou = self.nounique; + var all = nou ? [] : Object.create(null); + + for (var i = 0, l = self.matches.length; i < l; i++) { + var matches = self.matches[i]; + + if (!matches || Object.keys(matches).length === 0) { + if (self.nonull) { + var literal = self.minimatch.globSet[i]; + if (nou) all.push(literal);else all[literal] = true; + } + } else { + var m = Object.keys(matches); + if (nou) all.push.apply(all, m);else m.forEach(function (m) { + all[m] = true; + }); + } + } + + if (!nou) all = Object.keys(all); + if (!self.nosort) all = all.sort(alphasort); + + if (self.mark) { + for (var i = 0; i < all.length; i++) { + all[i] = self._mark(all[i]); + } + + if (self.nodir) { + all = all.filter(function (e) { + var notDir = !/\/$/.test(e); + var c = self.cache[e] || self.cache[makeAbs(self, e)]; + if (notDir && c) notDir = c !== 'DIR' && !Array.isArray(c); + return notDir; + }); + } + } + + if (self.ignore.length) all = all.filter(function (m) { + return !isIgnored(self, m); + }); + self.found = all; + } + + function mark(self, p) { + var abs = makeAbs(self, p); + var c = self.cache[abs]; + var m = p; + + if (c) { + var isDir = c === 'DIR' || Array.isArray(c); + var slash = p.slice(-1) === '/'; + if (isDir && !slash) m += '/';else if (!isDir && slash) m = m.slice(0, -1); + + if (m !== p) { + var mabs = makeAbs(self, m); + self.statCache[mabs] = self.statCache[abs]; + self.cache[mabs] = self.cache[abs]; + } + } + + return m; + } + + function makeAbs(self, f) { + var abs = f; + + if (f.charAt(0) === '/') { + abs = path.join(self.root, f); + } else if (isAbsolute(f) || f === '') { + abs = f; + } else if (self.changedCwd) { + abs = path.resolve(self.cwd, f); + } else { + abs = path.resolve(f); + } + + if (process.platform === 'win32') abs = abs.replace(/\\/g, '/'); + return abs; + } + + function isIgnored(self, path) { + if (!self.ignore.length) return false; + return self.ignore.some(function (item) { + return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path)); + }); + } + + function childrenIgnored(self, path) { + if (!self.ignore.length) return false; + return self.ignore.some(function (item) { + return !!(item.gmatcher && item.gmatcher.match(path)); + }); + } + + return common$1; +} + +var sync; +var hasRequiredSync; + +function requireSync() { + if (hasRequiredSync) return sync; + hasRequiredSync = 1; + sync = globSync; + globSync.GlobSync = GlobSync; + var fs = require$$1__default["default"]; + var rp = requireFs_realpath(); + var minimatch = requireMinimatch(); + minimatch.Minimatch; + requireGlob().Glob; + var path = require$$2__default["default"]; + var assert = require$$6__default["default"]; + var isAbsolute = requirePathIsAbsolute(); + var common = requireCommon$1(); + var setopts = common.setopts; + var ownProp = common.ownProp; + var childrenIgnored = common.childrenIgnored; + var isIgnored = common.isIgnored; + + function globSync(pattern, options) { + if (typeof options === 'function' || arguments.length === 3) throw new TypeError('callback provided to sync glob\n' + 'See: https://github.com/isaacs/node-glob/issues/167'); + return new GlobSync(pattern, options).found; + } + + function GlobSync(pattern, options) { + if (!pattern) throw new Error('must provide pattern'); + if (typeof options === 'function' || arguments.length === 3) throw new TypeError('callback provided to sync glob\n' + 'See: https://github.com/isaacs/node-glob/issues/167'); + if (!(this instanceof GlobSync)) return new GlobSync(pattern, options); + setopts(this, pattern, options); + if (this.noprocess) return this; + var n = this.minimatch.set.length; + this.matches = new Array(n); + + for (var i = 0; i < n; i++) { + this._process(this.minimatch.set[i], i, false); + } + + this._finish(); + } + + GlobSync.prototype._finish = function () { + assert(this instanceof GlobSync); + + if (this.realpath) { + var self = this; + this.matches.forEach(function (matchset, index) { + var set = self.matches[index] = Object.create(null); + + for (var p in matchset) { + try { + p = self._makeAbs(p); + var real = rp.realpathSync(p, self.realpathCache); + set[real] = true; + } catch (er) { + if (er.syscall === 'stat') set[self._makeAbs(p)] = true;else throw er; + } + } + }); + } + + common.finish(this); + }; + + GlobSync.prototype._process = function (pattern, index, inGlobStar) { + assert(this instanceof GlobSync); + var n = 0; + + while (typeof pattern[n] === 'string') { + n++; + } + + var prefix; + + switch (n) { + case pattern.length: + this._processSimple(pattern.join('/'), index); + + return; + + case 0: + prefix = null; + break; + + default: + prefix = pattern.slice(0, n).join('/'); + break; + } + + var remain = pattern.slice(n); + 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 (childrenIgnored(this, read)) return; + var isGlobStar = remain[0] === minimatch.GLOBSTAR; + if (isGlobStar) this._processGlobStar(prefix, read, abs, remain, index, inGlobStar);else this._processReaddir(prefix, read, abs, remain, index, inGlobStar); + }; + + GlobSync.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar) { + var entries = this._readdir(abs, inGlobStar); + + if (!entries) return; + 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); + } + } + + var len = matchedEntries.length; + if (len === 0) return; + + 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.slice(-1) !== '/') e = prefix + '/' + e;else e = prefix + e; + } + + if (e.charAt(0) === '/' && !this.nomount) { + e = path.join(this.root, e); + } + + this._emitMatch(index, e); + } + + return; + } + + remain.shift(); + + for (var i = 0; i < len; i++) { + var e = matchedEntries[i]; + var newPattern; + if (prefix) newPattern = [prefix, e];else newPattern = [e]; + + this._process(newPattern.concat(remain), index, inGlobStar); + } + }; + + GlobSync.prototype._emitMatch = function (index, e) { + if (isIgnored(this, e)) return; + + var abs = 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; + if (this.stat) this._stat(e); + }; + + GlobSync.prototype._readdirInGlobStar = function (abs) { + if (this.follow) return this._readdir(abs, false); + var entries; + var lstat; + + try { + lstat = fs.lstatSync(abs); + } catch (er) { + if (er.code === 'ENOENT') { + return null; + } + } + + var isSym = lstat && lstat.isSymbolicLink(); + this.symlinks[abs] = isSym; + if (!isSym && lstat && !lstat.isDirectory()) this.cache[abs] = 'FILE';else entries = this._readdir(abs, false); + return entries; + }; + + GlobSync.prototype._readdir = function (abs, inGlobStar) { + if (inGlobStar && !ownProp(this.symlinks, abs)) return this._readdirInGlobStar(abs); + + if (ownProp(this.cache, abs)) { + var c = this.cache[abs]; + if (!c || c === 'FILE') return null; + if (Array.isArray(c)) return c; + } + + try { + return this._readdirEntries(abs, fs.readdirSync(abs)); + } catch (er) { + this._readdirError(abs, er); + + return null; + } + }; + + GlobSync.prototype._readdirEntries = function (abs, entries) { + 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 entries; + }; + + GlobSync.prototype._readdirError = function (f, er) { + switch (er.code) { + case 'ENOTSUP': + case 'ENOTDIR': + 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; + throw error; + } + + break; + + case 'ENOENT': + case 'ELOOP': + case 'ENAMETOOLONG': + case 'UNKNOWN': + this.cache[this._makeAbs(f)] = false; + break; + + default: + this.cache[this._makeAbs(f)] = false; + if (this.strict) throw er; + if (!this.silent) console.error('glob error', er); + break; + } + }; + + GlobSync.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar) { + var entries = this._readdir(abs, inGlobStar); + + if (!entries) return; + var remainWithoutGlobStar = remain.slice(1); + var gspref = prefix ? [prefix] : []; + var noGlobStar = gspref.concat(remainWithoutGlobStar); + + this._process(noGlobStar, index, false); + + var len = entries.length; + var isSym = this.symlinks[abs]; + if (isSym && inGlobStar) return; + + for (var i = 0; i < len; i++) { + var e = entries[i]; + if (e.charAt(0) === '.' && !this.dot) continue; + var instead = gspref.concat(entries[i], remainWithoutGlobStar); + + this._process(instead, index, true); + + var below = gspref.concat(entries[i], remain); + + this._process(below, index, true); + } + }; + + GlobSync.prototype._processSimple = function (prefix, index) { + var exists = this._stat(prefix); + + if (!this.matches[index]) this.matches[index] = Object.create(null); + if (!exists) return; + + 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 += '/'; + } + } + + if (process.platform === 'win32') prefix = prefix.replace(/\\/g, '/'); + + this._emitMatch(index, prefix); + }; + + GlobSync.prototype._stat = function (f) { + var abs = this._makeAbs(f); + + var needDir = f.slice(-1) === '/'; + if (f.length > this.maxLength) return false; + + if (!this.stat && ownProp(this.cache, abs)) { + var c = this.cache[abs]; + if (Array.isArray(c)) c = 'DIR'; + if (!needDir || c === 'DIR') return c; + if (needDir && c === 'FILE') return false; + } + var stat = this.statCache[abs]; + + if (!stat) { + var lstat; + + try { + lstat = fs.lstatSync(abs); + } catch (er) { + if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) { + this.statCache[abs] = false; + return false; + } + } + + if (lstat && lstat.isSymbolicLink()) { + try { + stat = fs.statSync(abs); + } catch (er) { + stat = lstat; + } + } else { + stat = lstat; + } + } + + this.statCache[abs] = stat; + var c = true; + if (stat) c = stat.isDirectory() ? 'DIR' : 'FILE'; + this.cache[abs] = this.cache[abs] || c; + if (needDir && c === 'FILE') return false; + return c; + }; + + GlobSync.prototype._mark = function (p) { + return common.mark(this, p); + }; + + GlobSync.prototype._makeAbs = function (f) { + return common.makeAbs(this, f); + }; + + return sync; +} + +var $$3 = _export; +var toObject = toObject$7; +var toAbsoluteIndex = toAbsoluteIndex$4; +var toIntegerOrInfinity = toIntegerOrInfinity$5; +var lengthOfArrayLike = lengthOfArrayLike$7; +var doesNotExceedSafeInteger = doesNotExceedSafeInteger$2; +var arraySpeciesCreate = arraySpeciesCreate$3; +var createProperty = createProperty$4; +var deletePropertyOrThrow = deletePropertyOrThrow$2; +var arrayMethodHasSpeciesSupport = arrayMethodHasSpeciesSupport$5; + +var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('splice'); + +var max = Math.max; +var min = Math.min; + +// `Array.prototype.splice` method +// https://tc39.es/ecma262/#sec-array.prototype.splice +// with adding support of @@species +$$3({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, { + splice: function splice(start, deleteCount /* , ...items */) { + var O = toObject(this); + var len = lengthOfArrayLike(O); + var actualStart = toAbsoluteIndex(start, len); + var argumentsLength = arguments.length; + var insertCount, actualDeleteCount, A, k, from, to; + if (argumentsLength === 0) { + insertCount = actualDeleteCount = 0; + } else if (argumentsLength === 1) { + insertCount = 0; + actualDeleteCount = len - actualStart; + } else { + insertCount = argumentsLength - 2; + actualDeleteCount = min(max(toIntegerOrInfinity(deleteCount), 0), len - actualStart); + } + doesNotExceedSafeInteger(len + insertCount - actualDeleteCount); + A = arraySpeciesCreate(O, actualDeleteCount); + for (k = 0; k < actualDeleteCount; k++) { + from = actualStart + k; + if (from in O) createProperty(A, k, O[from]); + } + A.length = actualDeleteCount; + if (insertCount < actualDeleteCount) { + for (k = actualStart; k < len - actualDeleteCount; k++) { + from = k + actualDeleteCount; + to = k + insertCount; + if (from in O) O[to] = O[from]; + else deletePropertyOrThrow(O, to); + } + for (k = len; k > len - actualDeleteCount + insertCount; k--) deletePropertyOrThrow(O, k - 1); + } else if (insertCount > actualDeleteCount) { + for (k = len - actualDeleteCount; k > actualStart; k--) { + from = k + actualDeleteCount - 1; + to = k + insertCount - 1; + if (from in O) O[to] = O[from]; + else deletePropertyOrThrow(O, to); + } + } + for (k = 0; k < insertCount; k++) { + O[k + actualStart] = arguments[k + 2]; + } + O.length = len - actualDeleteCount + insertCount; + return A; + } +}); + +var wrappy_1; +var hasRequiredWrappy; + +function requireWrappy() { + if (hasRequiredWrappy) return wrappy_1; + hasRequiredWrappy = 1; + wrappy_1 = wrappy; + + function wrappy(fn, cb) { + if (fn && cb) return wrappy(fn)(cb); + if (typeof fn !== 'function') throw new TypeError('need wrapper function'); + Object.keys(fn).forEach(function (k) { + wrapper[k] = fn[k]; + }); + return wrapper; + + function wrapper() { + var args = new Array(arguments.length); + + for (var i = 0; i < args.length; i++) { + args[i] = arguments[i]; + } + + var ret = fn.apply(this, args); + var cb = args[args.length - 1]; + + if (typeof ret === 'function' && ret !== cb) { + Object.keys(cb).forEach(function (k) { + ret[k] = cb[k]; + }); + } + + return ret; + } + } + + return wrappy_1; +} + +var once = {exports: {}}; + +var hasRequiredOnce; + +function requireOnce() { + if (hasRequiredOnce) return once.exports; + hasRequiredOnce = 1; + var wrappy = requireWrappy(); + once.exports = wrappy(once$1); + once.exports.strict = wrappy(onceStrict); + once$1.proto = once$1(function () { + Object.defineProperty(Function.prototype, 'once', { + value: function value() { + return once$1(this); + }, + configurable: true + }); + Object.defineProperty(Function.prototype, 'onceStrict', { + value: function value() { + return onceStrict(this); + }, + configurable: true + }); + }); + + function once$1(fn) { + var f = function f() { + if (f.called) return f.value; + f.called = true; + return f.value = fn.apply(this, arguments); + }; + + f.called = false; + return f; + } + + function onceStrict(fn) { + var f = function f() { + if (f.called) throw new Error(f.onceError); + f.called = true; + return f.value = fn.apply(this, arguments); + }; + + var name = fn.name || 'Function wrapped with `once`'; + f.onceError = name + " shouldn't be called more than once"; + f.called = false; + return f; + } + + return once.exports; +} + +var inflight_1; +var hasRequiredInflight; + +function requireInflight() { + if (hasRequiredInflight) return inflight_1; + hasRequiredInflight = 1; + var wrappy = requireWrappy(); + var reqs = Object.create(null); + var once = requireOnce(); + inflight_1 = wrappy(inflight); + + function inflight(key, cb) { + if (reqs[key]) { + reqs[key].push(cb); + return null; + } else { + reqs[key] = [cb]; + return makeres(key); + } + } + + function makeres(key) { + return once(function RES() { + var cbs = reqs[key]; + var len = cbs.length; + var args = slice(arguments); + + try { + for (var i = 0; i < len; i++) { + cbs[i].apply(null, args); + } + } finally { + if (cbs.length > len) { + cbs.splice(0, len); + process.nextTick(function () { + RES.apply(null, args); + }); + } else { + delete reqs[key]; + } + } + }); + } + + function slice(args) { + var length = args.length; + var array = []; + + for (var i = 0; i < length; i++) array[i] = args[i]; + + return array; + } + + return inflight_1; +} + +var glob_1; +var hasRequiredGlob; + +function requireGlob() { + if (hasRequiredGlob) return glob_1; + hasRequiredGlob = 1; + glob_1 = glob; + var fs = require$$1__default["default"]; + var rp = requireFs_realpath(); + var minimatch = requireMinimatch(); + minimatch.Minimatch; + var inherits = requireInherits(); + var EE = require$$4__default["default"].EventEmitter; + var path = require$$2__default["default"]; + var assert = require$$6__default["default"]; + var isAbsolute = requirePathIsAbsolute(); + var globSync = requireSync(); + var common = requireCommon$1(); + var setopts = common.setopts; + var ownProp = common.ownProp; + var inflight = requireInflight(); + var childrenIgnored = common.childrenIgnored; + var isIgnored = common.isIgnored; + var once = requireOnce(); + + function glob(pattern, options, cb) { + if (typeof options === 'function') cb = options, options = {}; + if (!options) options = {}; + + if (options.sync) { + if (cb) throw new TypeError('callback provided to sync glob'); + return globSync(pattern, options); + } + + return new Glob(pattern, options, cb); + } + + glob.sync = globSync; + var GlobSync = glob.GlobSync = globSync.GlobSync; + glob.glob = glob; + + function extend(origin, add) { + if (add === null || typeof add !== 'object') { + return origin; + } + + var keys = Object.keys(add); + var i = keys.length; + + while (i--) { + origin[keys[i]] = add[keys[i]]; + } + + return origin; + } + + 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; + }; + + glob.Glob = Glob; + inherits(Glob, EE); + + function Glob(pattern, options, cb) { + if (typeof options === 'function') { + cb = options; + options = null; + } + + if (options && options.sync) { + if (cb) throw new TypeError('callback provided to sync glob'); + return new GlobSync(pattern, options); + } + + if (!(this instanceof Glob)) return new Glob(pattern, options, cb); + setopts(this, pattern, options); + this._didRealPath = false; + var n = this.minimatch.set.length; + this.matches = new Array(n); + + if (typeof cb === 'function') { + cb = once(cb); + this.on('error', cb); + this.on('end', function (matches) { + cb(null, matches); + }); + } + + var self = this; + this._processing = 0; + this._emitQueue = []; + this._processQueue = []; + this.paused = false; + if (this.noprocess) return this; + if (n === 0) return done(); + var sync = true; + + for (var i = 0; i < n; i++) { + this._process(this.minimatch.set[i], i, false, done); + } + + sync = false; + + function done() { + --self._processing; + + if (self._processing <= 0) { + if (sync) { + process.nextTick(function () { + self._finish(); + }); + } else { + self._finish(); + } + } + } + } + + Glob.prototype._finish = function () { + assert(this instanceof Glob); + if (this.aborted) return; + if (this.realpath && !this._didRealpath) return this._realpath(); + common.finish(this); + this.emit('end', this.found); + }; + + Glob.prototype._realpath = function () { + if (this._didRealpath) return; + this._didRealpath = true; + var n = this.matches.length; + if (n === 0) return this._finish(); + var self = this; + + for (var i = 0; i < this.matches.length; i++) this._realpathSet(i, next); + + function next() { + if (--n === 0) self._finish(); + } + }; + + 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(); + var set = this.matches[index] = Object.create(null); + found.forEach(function (p, i) { + 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); + + if (--n === 0) { + self.matches[index] = set; + cb(); + } + }); + }); + }; + + Glob.prototype._mark = function (p) { + return common.mark(this, p); + }; + + Glob.prototype._makeAbs = function (f) { + return common.makeAbs(this, f); + }; + + Glob.prototype.abort = function () { + this.aborted = true; + this.emit('abort'); + }; + + Glob.prototype.pause = function () { + if (!this.paused) { + this.paused = true; + this.emit('pause'); + } + }; + + 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]); + } + } + } + }; + + Glob.prototype._process = function (pattern, index, inGlobStar, cb) { + assert(this instanceof Glob); + assert(typeof cb === 'function'); + if (this.aborted) return; + this._processing++; + + if (this.paused) { + this._processQueue.push([pattern, index, inGlobStar, cb]); + + return; + } + + var n = 0; + + while (typeof pattern[n] === 'string') { + n++; + } + + var prefix; + + switch (n) { + case pattern.length: + this._processSimple(pattern.join('/'), index, cb); + + return; + + case 0: + prefix = null; + break; + + default: + prefix = pattern.slice(0, n).join('/'); + break; + } + + var remain = pattern.slice(n); + 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 (childrenIgnored(this, read)) return cb(); + 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); + }; + + 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); + }); + }; + + Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) { + if (!entries) return cb(); + 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); + } + } + + var len = matchedEntries.length; + if (len === 0) return cb(); + + 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); + } + + return cb(); + } + + remain.shift(); + + for (var i = 0; i < len; i++) { + var e = matchedEntries[i]; + + if (prefix) { + if (prefix !== '/') e = prefix + '/' + e;else e = prefix + e; + } + + this._process([e].concat(remain), index, inGlobStar, cb); + } + + 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; + } + + 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); + }; + + Glob.prototype._readdirInGlobStar = function (abs, cb) { + if (this.aborted) return; + 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 (!isSym && lstat && !lstat.isDirectory()) { + self.cache[abs] = 'FILE'; + cb(); + } else self._readdir(abs, false, cb); + } + }; + + Glob.prototype._readdir = function (abs, inGlobStar, cb) { + if (this.aborted) return; + cb = inflight('readdir\0' + abs + '\0' + inGlobStar, cb); + if (!cb) return; + 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); + } + 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 (!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; + + switch (er.code) { + case 'ENOTSUP': + case 'ENOTDIR': + 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': + case 'ELOOP': + case 'ENAMETOOLONG': + case 'UNKNOWN': + this.cache[this._makeAbs(f)] = false; + break; + + default: + this.cache[this._makeAbs(f)] = false; + + if (this.strict) { + this.emit('error', er); + 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) { + if (!entries) return cb(); + var remainWithoutGlobStar = remain.slice(1); + var gspref = prefix ? [prefix] : []; + var noGlobStar = gspref.concat(remainWithoutGlobStar); + + this._process(noGlobStar, index, false, cb); + + var isSym = this.symlinks[abs]; + var len = entries.length; + if (isSym && inGlobStar) return cb(); + + for (var i = 0; i < len; i++) { + var e = entries[i]; + if (e.charAt(0) === '.' && !this.dot) continue; + 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(); + }; + + Glob.prototype._processSimple = function (prefix, index, cb) { + 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) { + if (!this.matches[index]) this.matches[index] = Object.create(null); + if (!exists) return cb(); + + 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 += '/'; + } + } + + if (process.platform === 'win32') prefix = prefix.replace(/\\/g, '/'); + + this._emitMatch(index, prefix); + + cb(); + }; + + Glob.prototype._stat = function (f, cb) { + var abs = this._makeAbs(f); + + var needDir = f.slice(-1) === '/'; + if (f.length > this.maxLength) return cb(); + + if (!this.stat && ownProp(this.cache, abs)) { + var c = this.cache[abs]; + if (Array.isArray(c)) c = 'DIR'; + if (!needDir || c === 'DIR') return cb(null, c); + if (needDir && c === 'FILE') return cb(); + } + 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); + } + } + + var self = this; + var statcb = inflight('stat\0' + abs, lstatcb_); + if (statcb) fs.lstat(abs, statcb); + + function lstatcb_(er, lstat) { + if (lstat && lstat.isSymbolicLink()) { + 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); + } + } + }; + + Glob.prototype._stat2 = function (f, abs, er, stat, cb) { + if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) { + this.statCache[abs] = false; + return cb(); + } + + var needDir = f.slice(-1) === '/'; + this.statCache[abs] = stat; + if (abs.slice(-1) === '/' && stat && !stat.isDirectory()) return cb(null, false, stat); + var c = true; + if (stat) c = stat.isDirectory() ? 'DIR' : 'FILE'; + this.cache[abs] = this.cache[abs] || c; + if (needDir && c === 'FILE') return cb(); + return cb(null, c, stat); + }; + + return glob_1; +} + +var hasRequiredCommon; + +function requireCommon() { + if (hasRequiredCommon) return common$2; + hasRequiredCommon = 1; + + var os = require$$0__default["default"]; + var fs = require$$1__default["default"]; + var glob = requireGlob(); + var shell = requireShell(); + var shellMethods = Object.create(shell); + common$2.extend = Object.assign; + var isElectron = Boolean(process.versions.electron); + var DEFAULT_CONFIG = { + fatal: false, + globOptions: {}, + maxdepth: 255, + noglob: false, + silent: false, + verbose: false, + execPath: null, + bufLength: 64 * 1024 + }; + var config = { + reset: function reset() { + Object.assign(this, DEFAULT_CONFIG); + + if (!isElectron) { + this.execPath = process.execPath; + } + }, + resetForTesting: function resetForTesting() { + this.reset(); + this.silent = true; + } + }; + config.reset(); + common$2.config = config; + var state = { + error: null, + errorCode: 0, + currentCmd: 'shell.js' + }; + common$2.state = state; + delete process.env.OLDPWD; + + function isObject(a) { + return typeof a === 'object' && a !== null; + } + + common$2.isObject = isObject; + + function log() { + if (!config.silent) { + console.error.apply(console, arguments); + } + } + + common$2.log = log; + + function convertErrorOutput(msg) { + if (typeof msg !== 'string') { + throw new TypeError('input must be a string'); + } + + return msg.replace(/\\/g, '/'); + } + + common$2.convertErrorOutput = convertErrorOutput; + + function error(msg, _code, options) { + if (typeof msg !== 'string') throw new Error('msg must be a string'); + var DEFAULT_OPTIONS = { + continue: false, + code: 1, + prefix: state.currentCmd + ': ', + silent: false + }; + + if (typeof _code === 'number' && isObject(options)) { + options.code = _code; + } else if (isObject(_code)) { + options = _code; + } else if (typeof _code === 'number') { + options = { + code: _code + }; + } else if (typeof _code !== 'number') { + options = {}; + } + + options = Object.assign({}, DEFAULT_OPTIONS, options); + if (!state.errorCode) state.errorCode = options.code; + var logEntry = convertErrorOutput(options.prefix + msg); + state.error = state.error ? state.error + '\n' : ''; + state.error += logEntry; + if (config.fatal) throw new Error(logEntry); + if (msg.length > 0 && !options.silent) log(logEntry); + + if (!options.continue) { + throw { + msg: 'earlyExit', + retValue: new ShellString('', state.error, state.errorCode) + }; + } + } + + common$2.error = error; + + function ShellString(stdout, stderr, code) { + var that; + + if (stdout instanceof Array) { + that = stdout; + that.stdout = stdout.join('\n'); + if (stdout.length > 0) that.stdout += '\n'; + } else { + that = new String(stdout); + that.stdout = stdout; + } + + that.stderr = stderr; + that.code = code; + pipeMethods.forEach(function (cmd) { + that[cmd] = shellMethods[cmd].bind(that); + }); + return that; + } + + common$2.ShellString = ShellString; + + function parseOptions(opt, map, errorOptions) { + if (typeof opt !== 'string' && !isObject(opt)) { + throw new Error('options must be strings or key-value pairs'); + } else if (!isObject(map)) { + throw new Error('parseOptions() internal error: map must be an object'); + } else if (errorOptions && !isObject(errorOptions)) { + throw new Error('parseOptions() internal error: errorOptions must be object'); + } + + if (opt === '--') { + return {}; + } + + var options = {}; + Object.keys(map).forEach(function (letter) { + var optName = map[letter]; + + if (optName[0] !== '!') { + options[optName] = false; + } + }); + if (opt === '') return options; + + if (typeof opt === 'string') { + if (opt[0] !== '-') { + throw new Error("Options string must start with a '-'"); + } + + var chars = opt.slice(1).split(''); + chars.forEach(function (c) { + if (c in map) { + var optionName = map[c]; + + if (optionName[0] === '!') { + options[optionName.slice(1)] = false; + } else { + options[optionName] = true; + } + } else { + error('option not recognized: ' + c, errorOptions || {}); + } + }); + } else { + Object.keys(opt).forEach(function (key) { + var c = key[1]; + + if (c in map) { + var optionName = map[c]; + options[optionName] = opt[key]; + } else { + error('option not recognized: ' + c, errorOptions || {}); + } + }); + } + + return options; + } + + common$2.parseOptions = parseOptions; + + function expand(list) { + if (!Array.isArray(list)) { + throw new TypeError('must be an array'); + } + + var expanded = []; + list.forEach(function (listEl) { + if (typeof listEl !== 'string') { + expanded.push(listEl); + } else { + var ret; + + try { + ret = glob.sync(listEl, config.globOptions); + ret = ret.length > 0 ? ret : [listEl]; + } catch (e) { + ret = [listEl]; + } + + expanded = expanded.concat(ret); + } + }); + return expanded; + } + + common$2.expand = expand; + var buffer = typeof Buffer.alloc === 'function' ? function (len) { + return Buffer.alloc(len || config.bufLength); + } : function (len) { + return new Buffer(len || config.bufLength); + }; + common$2.buffer = buffer; + + function unlinkSync(file) { + try { + fs.unlinkSync(file); + } catch (e) { + if (e.code === 'EPERM') { + fs.chmodSync(file, '0666'); + fs.unlinkSync(file); + } else { + throw e; + } + } + } + + common$2.unlinkSync = unlinkSync; + + function statFollowLinks() { + return fs.statSync.apply(fs, arguments); + } + + common$2.statFollowLinks = statFollowLinks; + + function statNoFollowLinks() { + return fs.lstatSync.apply(fs, arguments); + } + + common$2.statNoFollowLinks = statNoFollowLinks; + + function randomFileName() { + function randomHash(count) { + if (count === 1) { + return parseInt(16 * Math.random(), 10).toString(16); + } + + var hash = ''; + + for (var i = 0; i < count; i++) { + hash += randomHash(1); + } + + return hash; + } + + return 'shelljs_' + randomHash(20); + } + + common$2.randomFileName = randomFileName; + + function wrap(cmd, fn, options) { + options = options || {}; + return function () { + var retValue = null; + state.currentCmd = cmd; + state.error = null; + state.errorCode = 0; + + try { + var args = [].slice.call(arguments, 0); + + if (config.verbose) { + console.error.apply(console, [cmd].concat(args)); + } + + state.pipedValue = this && typeof this.stdout === 'string' ? this.stdout : ''; + + if (options.unix === false) { + retValue = fn.apply(this, args); + } else { + if (isObject(args[0]) && args[0].constructor.name === 'Object') {} else if (args.length === 0 || typeof args[0] !== 'string' || args[0].length <= 1 || args[0][0] !== '-') { + args.unshift(''); + } + + args = args.reduce(function (accum, cur) { + if (Array.isArray(cur)) { + return accum.concat(cur); + } + + accum.push(cur); + return accum; + }, []); + args = args.map(function (arg) { + if (isObject(arg) && arg.constructor.name === 'String') { + return arg.toString(); + } + + return arg; + }); + var homeDir = os.homedir(); + args = args.map(function (arg) { + if (typeof arg === 'string' && arg.slice(0, 2) === '~/' || arg === '~') { + return arg.replace(/^~/, homeDir); + } + + return arg; + }); + + if (!config.noglob && options.allowGlobbing === true) { + args = args.slice(0, options.globStart).concat(expand(args.slice(options.globStart))); + } + + try { + if (isObject(options.cmdOptions)) { + args[0] = parseOptions(args[0], options.cmdOptions); + } + + retValue = fn.apply(this, args); + } catch (e) { + if (e.msg === 'earlyExit') { + retValue = e.retValue; + } else { + throw e; + } + } + } + } catch (e) { + if (!state.error) { + e.name = 'ShellJSInternalError'; + throw e; + } + + if (config.fatal) throw e; + } + + if (options.wrapOutput && (typeof retValue === 'string' || Array.isArray(retValue))) { + retValue = new ShellString(retValue, state.error, state.errorCode); + } + + state.currentCmd = 'shell.js'; + return retValue; + }; + } + + common$2.wrap = wrap; + + function _readFromPipe() { + return state.pipedValue; + } + + common$2.readFromPipe = _readFromPipe; + var DEFAULT_WRAP_OPTIONS = { + allowGlobbing: true, + canReceivePipe: false, + cmdOptions: null, + globStart: 1, + pipeOnly: false, + wrapOutput: true, + unix: true + }; + var pipeMethods = []; + + function _register(name, implementation, wrapOptions) { + wrapOptions = wrapOptions || {}; + Object.keys(wrapOptions).forEach(function (option) { + if (!DEFAULT_WRAP_OPTIONS.hasOwnProperty(option)) { + throw new Error("Unknown option '" + option + "'"); + } + + if (typeof wrapOptions[option] !== typeof DEFAULT_WRAP_OPTIONS[option]) { + throw new TypeError("Unsupported type '" + typeof wrapOptions[option] + "' for option '" + option + "'"); + } + }); + wrapOptions = Object.assign({}, DEFAULT_WRAP_OPTIONS, wrapOptions); + + if (shell.hasOwnProperty(name)) { + throw new Error('Command `' + name + '` already exists'); + } + + if (wrapOptions.pipeOnly) { + wrapOptions.canReceivePipe = true; + shellMethods[name] = wrap(name, implementation, wrapOptions); + } else { + shell[name] = wrap(name, implementation, wrapOptions); + } + + if (wrapOptions.canReceivePipe) { + pipeMethods.push(name); + } + } + + common$2.register = _register; + return common$2; +} + +var cat; +var hasRequiredCat; + +function requireCat() { + if (hasRequiredCat) return cat; + hasRequiredCat = 1; + var common = requireCommon(); + var fs = require$$1__default["default"]; + common.register('cat', _cat, { + canReceivePipe: true, + cmdOptions: { + 'n': 'number' + } + }); + + function _cat(options, files) { + var cat = common.readFromPipe(); + if (!files && !cat) common.error('no paths given'); + files = [].slice.call(arguments, 1); + files.forEach(function (file) { + if (!fs.existsSync(file)) { + common.error('no such file or directory: ' + file); + } else if (common.statFollowLinks(file).isDirectory()) { + common.error(file + ': Is a directory'); + } + + cat += fs.readFileSync(file, 'utf8'); + }); + + if (options.number) { + cat = addNumbers(cat); + } + + return cat; + } + + cat = _cat; + + function addNumbers(cat) { + var lines = cat.split('\n'); + var lastLine = lines.pop(); + lines = lines.map(function (line, i) { + return numberedLine(i + 1, line); + }); + + if (lastLine.length) { + lastLine = numberedLine(lines.length + 1, lastLine); + } + + lines.push(lastLine); + return lines.join('\n'); + } + + function numberedLine(n, line) { + var number = (' ' + n).slice(-6) + '\t'; + return number + line; + } + + return cat; +} + +var cd; +var hasRequiredCd; + +function requireCd() { + if (hasRequiredCd) return cd; + hasRequiredCd = 1; + var os = require$$0__default["default"]; + var common = requireCommon(); + common.register('cd', _cd, {}); + + function _cd(options, dir) { + if (!dir) dir = os.homedir(); + + if (dir === '-') { + if (!process.env.OLDPWD) { + common.error('could not find previous directory'); + } else { + dir = process.env.OLDPWD; + } + } + + try { + var curDir = process.cwd(); + process.chdir(dir); + process.env.OLDPWD = curDir; + } catch (e) { + var err; + + try { + common.statFollowLinks(dir); + err = 'not a directory: ' + dir; + } catch (e2) { + err = 'no such file or directory: ' + dir; + } + + if (err) common.error(err); + } + + return ''; + } + + cd = _cd; + return cd; +} + +var chmod; +var hasRequiredChmod; + +function requireChmod() { + if (hasRequiredChmod) return chmod; + hasRequiredChmod = 1; + var common = requireCommon(); + var fs = require$$1__default["default"]; + var path = require$$2__default["default"]; + + var PERMS = function (base) { + return { + OTHER_EXEC: base.EXEC, + OTHER_WRITE: base.WRITE, + OTHER_READ: base.READ, + GROUP_EXEC: base.EXEC << 3, + GROUP_WRITE: base.WRITE << 3, + GROUP_READ: base.READ << 3, + OWNER_EXEC: base.EXEC << 6, + OWNER_WRITE: base.WRITE << 6, + OWNER_READ: base.READ << 6, + STICKY: parseInt('01000', 8), + SETGID: parseInt('02000', 8), + SETUID: parseInt('04000', 8), + TYPE_MASK: parseInt('0770000', 8) + }; + }({ + EXEC: 1, + WRITE: 2, + READ: 4 + }); + + common.register('chmod', _chmod, {}); + + function _chmod(options, mode, filePattern) { + if (!filePattern) { + if (options.length > 0 && options.charAt(0) === '-') { + [].unshift.call(arguments, ''); + } else { + common.error('You must specify a file.'); + } + } + + options = common.parseOptions(options, { + 'R': 'recursive', + 'c': 'changes', + 'v': 'verbose' + }); + filePattern = [].slice.call(arguments, 2); + var files; + + if (options.recursive) { + files = []; + filePattern.forEach(function addFile(expandedFile) { + var stat = common.statNoFollowLinks(expandedFile); + + if (!stat.isSymbolicLink()) { + files.push(expandedFile); + + if (stat.isDirectory()) { + fs.readdirSync(expandedFile).forEach(function (child) { + addFile(expandedFile + '/' + child); + }); + } + } + }); + } else { + files = filePattern; + } + + files.forEach(function innerChmod(file) { + file = path.resolve(file); + + if (!fs.existsSync(file)) { + common.error('File not found: ' + file); + } + + if (options.recursive && common.statNoFollowLinks(file).isSymbolicLink()) { + return; + } + + var stat = common.statFollowLinks(file); + var isDir = stat.isDirectory(); + var perms = stat.mode; + var type = perms & PERMS.TYPE_MASK; + var newPerms = perms; + + if (isNaN(parseInt(mode, 8))) { + mode.split(',').forEach(function (symbolicMode) { + var pattern = /([ugoa]*)([=\+-])([rwxXst]*)/i; + var matches = pattern.exec(symbolicMode); + + if (matches) { + var applyTo = matches[1]; + var operator = matches[2]; + var change = matches[3]; + var changeOwner = applyTo.indexOf('u') !== -1 || applyTo === 'a' || applyTo === ''; + var changeGroup = applyTo.indexOf('g') !== -1 || applyTo === 'a' || applyTo === ''; + var changeOther = applyTo.indexOf('o') !== -1 || applyTo === 'a' || applyTo === ''; + var changeRead = change.indexOf('r') !== -1; + var changeWrite = change.indexOf('w') !== -1; + var changeExec = change.indexOf('x') !== -1; + var changeExecDir = change.indexOf('X') !== -1; + var changeSticky = change.indexOf('t') !== -1; + var changeSetuid = change.indexOf('s') !== -1; + + if (changeExecDir && isDir) { + changeExec = true; + } + + var mask = 0; + + if (changeOwner) { + mask |= (changeRead ? PERMS.OWNER_READ : 0) + (changeWrite ? PERMS.OWNER_WRITE : 0) + (changeExec ? PERMS.OWNER_EXEC : 0) + (changeSetuid ? PERMS.SETUID : 0); + } + + if (changeGroup) { + mask |= (changeRead ? PERMS.GROUP_READ : 0) + (changeWrite ? PERMS.GROUP_WRITE : 0) + (changeExec ? PERMS.GROUP_EXEC : 0) + (changeSetuid ? PERMS.SETGID : 0); + } + + if (changeOther) { + mask |= (changeRead ? PERMS.OTHER_READ : 0) + (changeWrite ? PERMS.OTHER_WRITE : 0) + (changeExec ? PERMS.OTHER_EXEC : 0); + } + + if (changeSticky) { + mask |= PERMS.STICKY; + } + + switch (operator) { + case '+': + newPerms |= mask; + break; + + case '-': + newPerms &= ~mask; + break; + + case '=': + newPerms = type + mask; + + if (common.statFollowLinks(file).isDirectory()) { + newPerms |= PERMS.SETUID + PERMS.SETGID & perms; + } + + break; + + default: + common.error('Could not recognize operator: `' + operator + '`'); + } + + if (options.verbose) { + console.log(file + ' -> ' + newPerms.toString(8)); + } + + if (perms !== newPerms) { + if (!options.verbose && options.changes) { + console.log(file + ' -> ' + newPerms.toString(8)); + } + + fs.chmodSync(file, newPerms); + perms = newPerms; + } + } else { + common.error('Invalid symbolic mode change: ' + symbolicMode); + } + }); + } else { + newPerms = type + parseInt(mode, 8); + + if (common.statFollowLinks(file).isDirectory()) { + newPerms |= PERMS.SETUID + PERMS.SETGID & perms; + } + + fs.chmodSync(file, newPerms); + } + }); + return ''; + } + + chmod = _chmod; + return chmod; +} + +var cp; +var hasRequiredCp; + +function requireCp() { + if (hasRequiredCp) return cp; + hasRequiredCp = 1; + var fs = require$$1__default["default"]; + var path = require$$2__default["default"]; + var common = requireCommon(); + common.register('cp', _cp, { + cmdOptions: { + 'f': '!no_force', + 'n': 'no_force', + 'u': 'update', + 'R': 'recursive', + 'r': 'recursive', + 'L': 'followsymlink', + 'P': 'noFollowsymlink' + }, + wrapOutput: false + }); + + function copyFileSync(srcFile, destFile, options) { + if (!fs.existsSync(srcFile)) { + common.error('copyFileSync: no such file or directory: ' + srcFile); + } + + var isWindows = process.platform === 'win32'; + + try { + if (options.update && common.statFollowLinks(srcFile).mtime < fs.statSync(destFile).mtime) { + return; + } + } catch (e) {} + + if (common.statNoFollowLinks(srcFile).isSymbolicLink() && !options.followsymlink) { + try { + common.statNoFollowLinks(destFile); + common.unlinkSync(destFile); + } catch (e) {} + + var symlinkFull = fs.readlinkSync(srcFile); + fs.symlinkSync(symlinkFull, destFile, isWindows ? 'junction' : null); + } else { + var buf = common.buffer(); + var bufLength = buf.length; + var bytesRead = bufLength; + var pos = 0; + var fdr = null; + var fdw = null; + + try { + fdr = fs.openSync(srcFile, 'r'); + } catch (e) { + common.error('copyFileSync: could not read src file (' + srcFile + ')'); + } + + try { + fdw = fs.openSync(destFile, 'w'); + } catch (e) { + common.error('copyFileSync: could not write to dest file (code=' + e.code + '):' + destFile); + } + + while (bytesRead === bufLength) { + bytesRead = fs.readSync(fdr, buf, 0, bufLength, pos); + fs.writeSync(fdw, buf, 0, bytesRead); + pos += bytesRead; + } + + fs.closeSync(fdr); + fs.closeSync(fdw); + fs.chmodSync(destFile, common.statFollowLinks(srcFile).mode); + } + } + + function cpdirSyncRecursive(sourceDir, destDir, currentDepth, opts) { + if (!opts) opts = {}; + if (currentDepth >= common.config.maxdepth) return; + currentDepth++; + var isWindows = process.platform === 'win32'; + + try { + fs.mkdirSync(destDir); + } catch (e) { + if (e.code !== 'EEXIST') throw e; + } + + var files = fs.readdirSync(sourceDir); + + for (var i = 0; i < files.length; i++) { + var srcFile = sourceDir + '/' + files[i]; + var destFile = destDir + '/' + files[i]; + var srcFileStat = common.statNoFollowLinks(srcFile); + var symlinkFull; + + if (opts.followsymlink) { + if (cpcheckcycle(sourceDir, srcFile)) { + console.error('Cycle link found.'); + symlinkFull = fs.readlinkSync(srcFile); + fs.symlinkSync(symlinkFull, destFile, isWindows ? 'junction' : null); + continue; + } + } + + if (srcFileStat.isDirectory()) { + cpdirSyncRecursive(srcFile, destFile, currentDepth, opts); + } else if (srcFileStat.isSymbolicLink() && !opts.followsymlink) { + symlinkFull = fs.readlinkSync(srcFile); + + try { + common.statNoFollowLinks(destFile); + common.unlinkSync(destFile); + } catch (e) {} + + fs.symlinkSync(symlinkFull, destFile, isWindows ? 'junction' : null); + } else if (srcFileStat.isSymbolicLink() && opts.followsymlink) { + srcFileStat = common.statFollowLinks(srcFile); + + if (srcFileStat.isDirectory()) { + cpdirSyncRecursive(srcFile, destFile, currentDepth, opts); + } else { + copyFileSync(srcFile, destFile, opts); + } + } else { + if (fs.existsSync(destFile) && opts.no_force) { + common.log('skipping existing file: ' + files[i]); + } else { + copyFileSync(srcFile, destFile, opts); + } + } + } + + var checkDir = common.statFollowLinks(sourceDir); + fs.chmodSync(destDir, checkDir.mode); + } + + function checkRecentCreated(sources, index) { + var lookedSource = sources[index]; + return sources.slice(0, index).some(function (src) { + return path.basename(src) === path.basename(lookedSource); + }); + } + + function cpcheckcycle(sourceDir, srcFile) { + var srcFileStat = common.statNoFollowLinks(srcFile); + + if (srcFileStat.isSymbolicLink()) { + var cyclecheck = common.statFollowLinks(srcFile); + + if (cyclecheck.isDirectory()) { + var sourcerealpath = fs.realpathSync(sourceDir); + var symlinkrealpath = fs.realpathSync(srcFile); + var re = new RegExp(symlinkrealpath); + + if (re.test(sourcerealpath)) { + return true; + } + } + } + + return false; + } + + function _cp(options, sources, dest) { + if (options.followsymlink) { + options.noFollowsymlink = false; + } + + if (!options.recursive && !options.noFollowsymlink) { + options.followsymlink = true; + } + + if (arguments.length < 3) { + common.error('missing and/or '); + } else { + sources = [].slice.call(arguments, 1, arguments.length - 1); + dest = arguments[arguments.length - 1]; + } + + var destExists = fs.existsSync(dest); + var destStat = destExists && common.statFollowLinks(dest); + + if ((!destExists || !destStat.isDirectory()) && sources.length > 1) { + common.error('dest is not a directory (too many sources)'); + } + + if (destExists && destStat.isFile() && options.no_force) { + return new common.ShellString('', '', 0); + } + + sources.forEach(function (src, srcIndex) { + if (!fs.existsSync(src)) { + if (src === '') src = "''"; + common.error('no such file or directory: ' + src, { + continue: true + }); + return; + } + + var srcStat = common.statFollowLinks(src); + + if (!options.noFollowsymlink && srcStat.isDirectory()) { + if (!options.recursive) { + common.error("omitting directory '" + src + "'", { + continue: true + }); + } else { + var newDest = destStat && destStat.isDirectory() ? path.join(dest, path.basename(src)) : dest; + + try { + common.statFollowLinks(path.dirname(dest)); + cpdirSyncRecursive(src, newDest, 0, { + no_force: options.no_force, + followsymlink: options.followsymlink + }); + } catch (e) { + common.error("cannot create directory '" + dest + "': No such file or directory"); + } + } + } else { + var thisDest = dest; + + if (destStat && destStat.isDirectory()) { + thisDest = path.normalize(dest + '/' + path.basename(src)); + } + + var thisDestExists = fs.existsSync(thisDest); + + if (thisDestExists && checkRecentCreated(sources, srcIndex)) { + if (!options.no_force) { + common.error("will not overwrite just-created '" + thisDest + "' with '" + src + "'", { + continue: true + }); + } + + return; + } + + if (thisDestExists && options.no_force) { + return; + } + + if (path.relative(src, thisDest) === '') { + common.error("'" + thisDest + "' and '" + src + "' are the same file", { + continue: true + }); + return; + } + + copyFileSync(src, thisDest, options); + } + }); + return new common.ShellString('', common.state.error, common.state.errorCode); + } + + cp = _cp; + return cp; +} + +var dirs = {}; + +var hasRequiredDirs; + +function requireDirs() { + if (hasRequiredDirs) return dirs; + hasRequiredDirs = 1; + var common = requireCommon(); + + var _cd = requireCd(); + + var path = require$$2__default["default"]; + common.register('dirs', _dirs, { + wrapOutput: false + }); + common.register('pushd', _pushd, { + wrapOutput: false + }); + common.register('popd', _popd, { + wrapOutput: false + }); + var _dirStack = []; + + function _isStackIndex(index) { + return /^[\-+]\d+$/.test(index); + } + + function _parseStackIndex(index) { + if (_isStackIndex(index)) { + if (Math.abs(index) < _dirStack.length + 1) { + return /^-/.test(index) ? Number(index) - 1 : Number(index); + } + + common.error(index + ': directory stack index out of range'); + } else { + common.error(index + ': invalid number'); + } + } + + function _actualDirStack() { + return [process.cwd()].concat(_dirStack); + } + + function _pushd(options, dir) { + if (_isStackIndex(options)) { + dir = options; + options = ''; + } + + options = common.parseOptions(options, { + 'n': 'no-cd', + 'q': 'quiet' + }); + + var dirs = _actualDirStack(); + + if (dir === '+0') { + return dirs; + } else if (!dir) { + if (dirs.length > 1) { + dirs = dirs.splice(1, 1).concat(dirs); + } else { + return common.error('no other directory'); + } + } else if (_isStackIndex(dir)) { + var n = _parseStackIndex(dir); + + dirs = dirs.slice(n).concat(dirs.slice(0, n)); + } else { + if (options['no-cd']) { + dirs.splice(1, 0, dir); + } else { + dirs.unshift(dir); + } + } + + if (options['no-cd']) { + dirs = dirs.slice(1); + } else { + dir = path.resolve(dirs.shift()); + + _cd('', dir); + } + + _dirStack = dirs; + return _dirs(options.quiet ? '-q' : ''); + } + + dirs.pushd = _pushd; + + function _popd(options, index) { + if (_isStackIndex(options)) { + index = options; + options = ''; + } + + options = common.parseOptions(options, { + 'n': 'no-cd', + 'q': 'quiet' + }); + + if (!_dirStack.length) { + return common.error('directory stack empty'); + } + + index = _parseStackIndex(index || '+0'); + + if (options['no-cd'] || index > 0 || _dirStack.length + index === 0) { + index = index > 0 ? index - 1 : index; + + _dirStack.splice(index, 1); + } else { + var dir = path.resolve(_dirStack.shift()); + + _cd('', dir); + } + + return _dirs(options.quiet ? '-q' : ''); + } + + dirs.popd = _popd; + + function _dirs(options, index) { + if (_isStackIndex(options)) { + index = options; + options = ''; + } + + options = common.parseOptions(options, { + 'c': 'clear', + 'q': 'quiet' + }); + + if (options.clear) { + _dirStack = []; + return _dirStack; + } + + var stack = _actualDirStack(); + + if (index) { + index = _parseStackIndex(index); + + if (index < 0) { + index = stack.length + index; + } + + if (!options.quiet) { + common.log(stack[index]); + } + + return stack[index]; + } + + if (!options.quiet) { + common.log(stack.join(' ')); + } + + return stack; + } + + dirs.dirs = _dirs; + return dirs; +} + +var echo; +var hasRequiredEcho; + +function requireEcho() { + if (hasRequiredEcho) return echo; + hasRequiredEcho = 1; + var format = require$$4__default$1["default"].format; + var common = requireCommon(); + common.register('echo', _echo, { + allowGlobbing: false + }); + + function _echo(opts) { + var messages = [].slice.call(arguments, opts ? 0 : 1); + var options = {}; + + try { + options = common.parseOptions(messages[0], { + 'e': 'escapes', + 'n': 'no_newline' + }, { + silent: true + }); + + if (messages[0]) { + messages.shift(); + } + } catch (_) { + common.state.error = null; + } + + var output = format.apply(null, messages); + + if (!options.no_newline) { + output += '\n'; + } + + process.stdout.write(output); + return output; + } + + echo = _echo; + return echo; +} + +var error_1; +var hasRequiredError; + +function requireError() { + if (hasRequiredError) return error_1; + hasRequiredError = 1; + var common = requireCommon(); + + function error() { + return common.state.error; + } + + error_1 = error; + return error_1; +} + +var execChild = {exports: {}}; + +var hasRequiredExecChild; + +function requireExecChild() { + if (hasRequiredExecChild) return execChild.exports; + hasRequiredExecChild = 1; + + (function (module) { + if (require.main !== module) { + throw new Error('This file should not be required'); + } + + var childProcess = require$$0__default$1["default"]; + var fs = require$$1__default["default"]; + var paramFilePath = process.argv[2]; + var serializedParams = fs.readFileSync(paramFilePath, 'utf8'); + var params = JSON.parse(serializedParams); + var cmd = params.command; + var execOptions = params.execOptions; + var pipe = params.pipe; + var stdoutFile = params.stdoutFile; + var stderrFile = params.stderrFile; + var c = childProcess.exec(cmd, execOptions, function (err) { + if (!err) { + process.exitCode = 0; + } else if (err.code === undefined) { + process.exitCode = 1; + } else { + process.exitCode = err.code; + } + }); + var stdoutStream = fs.createWriteStream(stdoutFile); + var stderrStream = fs.createWriteStream(stderrFile); + c.stdout.pipe(stdoutStream); + c.stderr.pipe(stderrStream); + c.stdout.pipe(process.stdout); + c.stderr.pipe(process.stderr); + + if (pipe) { + c.stdin.end(pipe); + } + })(execChild); + + return execChild.exports; +} + +var $$2 = _export; +var getBuiltIn = getBuiltIn$8; +var apply = functionApply; +var call = functionCall; +var uncurryThis = functionUncurryThis; +var fails = fails$p; +var isArray = isArray$4; +var isCallable = isCallable$m; +var isObject = isObject$d; +var isSymbol = isSymbol$3; +var arraySlice = arraySlice$3; +var NATIVE_SYMBOL = nativeSymbol; + +var $stringify = getBuiltIn('JSON', 'stringify'); +var exec$2 = uncurryThis(/./.exec); +var charAt = uncurryThis(''.charAt); +var charCodeAt = uncurryThis(''.charCodeAt); +var replace = uncurryThis(''.replace); +var numberToString = uncurryThis(1.0.toString); + +var tester = /[\uD800-\uDFFF]/g; +var low = /^[\uD800-\uDBFF]$/; +var hi = /^[\uDC00-\uDFFF]$/; + +var WRONG_SYMBOLS_CONVERSION = !NATIVE_SYMBOL || fails(function () { + var symbol = getBuiltIn('Symbol')(); + // MS Edge converts symbol values to JSON as {} + return $stringify([symbol]) != '[null]' + // WebKit converts symbol values to JSON as null + || $stringify({ a: symbol }) != '{}' + // V8 throws on boxed symbols + || $stringify(Object(symbol)) != '{}'; +}); + +// https://github.com/tc39/proposal-well-formed-stringify +var ILL_FORMED_UNICODE = fails(function () { + return $stringify('\uDF06\uD834') !== '"\\udf06\\ud834"' + || $stringify('\uDEAD') !== '"\\udead"'; +}); + +var stringifyWithSymbolsFix = function (it, replacer) { + var args = arraySlice(arguments); + var $replacer = replacer; + if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined + if (!isArray(replacer)) replacer = function (key, value) { + if (isCallable($replacer)) value = call($replacer, this, key, value); + if (!isSymbol(value)) return value; + }; + args[1] = replacer; + return apply($stringify, null, args); +}; + +var fixIllFormed = function (match, offset, string) { + var prev = charAt(string, offset - 1); + var next = charAt(string, offset + 1); + if ((exec$2(low, match) && !exec$2(hi, next)) || (exec$2(hi, match) && !exec$2(low, prev))) { + return '\\u' + numberToString(charCodeAt(match, 0), 16); + } return match; +}; + +if ($stringify) { + // `JSON.stringify` method + // https://tc39.es/ecma262/#sec-json.stringify + $$2({ target: 'JSON', stat: true, arity: 3, forced: WRONG_SYMBOLS_CONVERSION || ILL_FORMED_UNICODE }, { + // eslint-disable-next-line no-unused-vars -- required for `.length` + stringify: function stringify(it, replacer, space) { + var args = arraySlice(arguments); + var result = apply(WRONG_SYMBOLS_CONVERSION ? stringifyWithSymbolsFix : $stringify, null, args); + return ILL_FORMED_UNICODE && typeof result == 'string' ? replace(result, tester, fixIllFormed) : result; + } + }); +} + +var tempdir = {}; + +var hasRequiredTempdir; + +function requireTempdir() { + if (hasRequiredTempdir) return tempdir; + hasRequiredTempdir = 1; + var common = requireCommon(); + var os = require$$0__default["default"]; + var fs = require$$1__default["default"]; + common.register('tempdir', _tempDir, { + allowGlobbing: false, + wrapOutput: false + }); + + function writeableDir(dir) { + if (!dir || !fs.existsSync(dir)) return false; + if (!common.statFollowLinks(dir).isDirectory()) return false; + var testFile = dir + '/' + common.randomFileName(); + + try { + fs.writeFileSync(testFile, ' '); + common.unlinkSync(testFile); + return dir; + } catch (e) { + return false; + } + } + + var cachedTempDir; + + function _tempDir() { + if (cachedTempDir) return cachedTempDir; + cachedTempDir = writeableDir(os.tmpdir()) || writeableDir(process.env.TMPDIR) || writeableDir(process.env.TEMP) || writeableDir(process.env.TMP) || writeableDir(process.env.Wimp$ScrapDir) || writeableDir('C:\\TEMP') || writeableDir('C:\\TMP') || writeableDir('\\TEMP') || writeableDir('\\TMP') || writeableDir('/tmp') || writeableDir('/var/tmp') || writeableDir('/usr/tmp') || writeableDir('.'); + return cachedTempDir; + } + + function isCached() { + return cachedTempDir; + } + + function clearCache() { + cachedTempDir = undefined; + } + + tempdir.tempDir = _tempDir; + tempdir.isCached = isCached; + tempdir.clearCache = clearCache; + return tempdir; +} + +var pwd; +var hasRequiredPwd; + +function requirePwd() { + if (hasRequiredPwd) return pwd; + hasRequiredPwd = 1; + var path = require$$2__default["default"]; + var common = requireCommon(); + common.register('pwd', _pwd, { + allowGlobbing: false + }); + + function _pwd() { + var pwd = path.resolve(process.cwd()); + return pwd; + } + + pwd = _pwd; + return pwd; +} + +var exec$1; +var hasRequiredExec; + +function requireExec() { + if (hasRequiredExec) return exec$1; + hasRequiredExec = 1; + var common = requireCommon(); + var _tempDir = requireTempdir().tempDir; + + var _pwd = requirePwd(); + + var path = require$$2__default["default"]; + var fs = require$$1__default["default"]; + var child = require$$0__default$1["default"]; + var DEFAULT_MAXBUFFER_SIZE = 20 * 1024 * 1024; + var DEFAULT_ERROR_CODE = 1; + common.register('exec', _exec, { + unix: false, + canReceivePipe: true, + wrapOutput: false + }); + + function execSync(cmd, opts, pipe) { + if (!common.config.execPath) { + common.error('Unable to find a path to the node binary. Please manually set config.execPath'); + } + + var tempDir = _tempDir(); + + var paramsFile = path.resolve(tempDir + '/' + common.randomFileName()); + var stderrFile = path.resolve(tempDir + '/' + common.randomFileName()); + var stdoutFile = path.resolve(tempDir + '/' + common.randomFileName()); + opts = common.extend({ + silent: common.config.silent, + cwd: _pwd().toString(), + env: process.env, + maxBuffer: DEFAULT_MAXBUFFER_SIZE, + encoding: 'utf8' + }, opts); + if (fs.existsSync(paramsFile)) common.unlinkSync(paramsFile); + if (fs.existsSync(stderrFile)) common.unlinkSync(stderrFile); + if (fs.existsSync(stdoutFile)) common.unlinkSync(stdoutFile); + opts.cwd = path.resolve(opts.cwd); + var paramsToSerialize = { + command: cmd, + execOptions: opts, + pipe: pipe, + stdoutFile: stdoutFile, + stderrFile: stderrFile + }; + + function writeFileLockedDown(filePath, data) { + fs.writeFileSync(filePath, data, { + encoding: 'utf8', + mode: parseInt('600', 8) + }); + } + + writeFileLockedDown(stdoutFile, ''); + writeFileLockedDown(stderrFile, ''); + writeFileLockedDown(paramsFile, JSON.stringify(paramsToSerialize)); + var execArgs = [path.join(__dirname, 'exec-child.js'), paramsFile]; + + if (opts.silent) { + opts.stdio = 'ignore'; + } else { + opts.stdio = [0, 1, 2]; + } + + var code = 0; + + try { + delete opts.shell; + child.execFileSync(common.config.execPath, execArgs, opts); + } catch (e) { + code = e.status || DEFAULT_ERROR_CODE; + } + + var stdout = ''; + var stderr = ''; + + if (opts.encoding === 'buffer') { + stdout = fs.readFileSync(stdoutFile); + stderr = fs.readFileSync(stderrFile); + } else { + stdout = fs.readFileSync(stdoutFile, opts.encoding); + stderr = fs.readFileSync(stderrFile, opts.encoding); + } + + try { + common.unlinkSync(paramsFile); + } catch (e) {} + + try { + common.unlinkSync(stderrFile); + } catch (e) {} + + try { + common.unlinkSync(stdoutFile); + } catch (e) {} + + if (code !== 0) { + common.error(stderr, code, { + continue: true, + silent: true + }); + } + + var obj = common.ShellString(stdout, stderr, code); + return obj; + } + + function execAsync(cmd, opts, pipe, callback) { + opts = common.extend({ + silent: common.config.silent, + cwd: _pwd().toString(), + env: process.env, + maxBuffer: DEFAULT_MAXBUFFER_SIZE, + encoding: 'utf8' + }, opts); + var c = child.exec(cmd, opts, function (err, stdout, stderr) { + if (callback) { + if (!err) { + callback(0, stdout, stderr); + } else if (err.code === undefined) { + callback(1, stdout, stderr); + } else { + callback(err.code, stdout, stderr); + } + } + }); + if (pipe) c.stdin.end(pipe); + + if (!opts.silent) { + c.stdout.pipe(process.stdout); + c.stderr.pipe(process.stderr); + } + + return c; + } + + function _exec(command, options, callback) { + options = options || {}; + if (!command) common.error('must specify command'); + var pipe = common.readFromPipe(); + + if (typeof options === 'function') { + callback = options; + options = { + async: true + }; + } + + if (typeof options === 'object' && typeof callback === 'function') { + options.async = true; + } + + options = common.extend({ + silent: common.config.silent, + async: false + }, options); + + if (options.async) { + return execAsync(command, options, pipe, callback); + } else { + return execSync(command, options, pipe); + } + } + + exec$1 = _exec; + return exec$1; +} + +var ls; +var hasRequiredLs; + +function requireLs() { + if (hasRequiredLs) return ls; + hasRequiredLs = 1; + var path = require$$2__default["default"]; + var fs = require$$1__default["default"]; + var common = requireCommon(); + var glob = requireGlob(); + var globPatternRecursive = path.sep + '**'; + common.register('ls', _ls, { + cmdOptions: { + 'R': 'recursive', + 'A': 'all', + 'L': 'link', + 'a': 'all_deprecated', + 'd': 'directory', + 'l': 'long' + } + }); + + function _ls(options, paths) { + if (options.all_deprecated) { + common.log('ls: Option -a is deprecated. Use -A instead'); + options.all = true; + } + + if (!paths) { + paths = ['.']; + } else { + paths = [].slice.call(arguments, 1); + } + + var list = []; + + function pushFile(abs, relName, stat) { + if (process.platform === 'win32') { + relName = relName.replace(/\\/g, '/'); + } + + if (options.long) { + stat = stat || (options.link ? common.statFollowLinks(abs) : common.statNoFollowLinks(abs)); + list.push(addLsAttributes(relName, stat)); + } else { + list.push(relName); + } + } + + paths.forEach(function (p) { + var stat; + + try { + stat = options.link ? common.statFollowLinks(p) : common.statNoFollowLinks(p); + + if (stat.isSymbolicLink()) { + try { + var _stat = common.statFollowLinks(p); + + if (_stat.isDirectory()) { + stat = _stat; + } + } catch (_) {} + } + } catch (e) { + common.error('no such file or directory: ' + p, 2, { + continue: true + }); + return; + } + + if (stat.isDirectory() && !options.directory) { + if (options.recursive) { + glob.sync(p + globPatternRecursive, { + dot: options.all, + follow: options.link + }).forEach(function (item) { + if (path.relative(p, item)) { + pushFile(item, path.relative(p, item)); + } + }); + } else if (options.all) { + fs.readdirSync(p).forEach(function (item) { + pushFile(path.join(p, item), item); + }); + } else { + fs.readdirSync(p).forEach(function (item) { + if (item[0] !== '.') { + pushFile(path.join(p, item), item); + } + }); + } + } else { + pushFile(p, p, stat); + } + }); + return list; + } + + function addLsAttributes(pathName, stats) { + stats.name = pathName; + + stats.toString = function () { + return [this.mode, this.nlink, this.uid, this.gid, this.size, this.mtime, this.name].join(' '); + }; + + return stats; + } + + ls = _ls; + return ls; +} + +var find; +var hasRequiredFind; + +function requireFind() { + if (hasRequiredFind) return find; + hasRequiredFind = 1; + var path = require$$2__default["default"]; + var common = requireCommon(); + + var _ls = requireLs(); + + common.register('find', _find, {}); + + function _find(options, paths) { + if (!paths) { + common.error('no path specified'); + } else if (typeof paths === 'string') { + paths = [].slice.call(arguments, 1); + } + + var list = []; + + function pushFile(file) { + if (process.platform === 'win32') { + file = file.replace(/\\/g, '/'); + } + + list.push(file); + } + + paths.forEach(function (file) { + var stat; + + try { + stat = common.statFollowLinks(file); + } catch (e) { + common.error('no such file or directory: ' + file); + } + + pushFile(file); + + if (stat.isDirectory()) { + _ls({ + recursive: true, + all: true + }, file).forEach(function (subfile) { + pushFile(path.join(file, subfile)); + }); + } + }); + return list; + } + + find = _find; + return find; +} + +var grep; +var hasRequiredGrep; + +function requireGrep() { + if (hasRequiredGrep) return grep; + hasRequiredGrep = 1; + var common = requireCommon(); + var fs = require$$1__default["default"]; + common.register('grep', _grep, { + globStart: 2, + canReceivePipe: true, + cmdOptions: { + 'v': 'inverse', + 'l': 'nameOnly', + 'i': 'ignoreCase' + } + }); + + function _grep(options, regex, files) { + var pipe = common.readFromPipe(); + if (!files && !pipe) common.error('no paths given', 2); + files = [].slice.call(arguments, 2); + + if (pipe) { + files.unshift('-'); + } + + var grep = []; + + if (options.ignoreCase) { + regex = new RegExp(regex, 'i'); + } + + files.forEach(function (file) { + if (!fs.existsSync(file) && file !== '-') { + common.error('no such file or directory: ' + file, 2, { + continue: true + }); + return; + } + + var contents = file === '-' ? pipe : fs.readFileSync(file, 'utf8'); + + if (options.nameOnly) { + if (contents.match(regex)) { + grep.push(file); + } + } else { + var lines = contents.split('\n'); + lines.forEach(function (line) { + var matched = line.match(regex); + + if (options.inverse && !matched || !options.inverse && matched) { + grep.push(line); + } + }); + } + }); + return grep.join('\n') + '\n'; + } + + grep = _grep; + return grep; +} + +var head; +var hasRequiredHead; + +function requireHead() { + if (hasRequiredHead) return head; + hasRequiredHead = 1; + var common = requireCommon(); + var fs = require$$1__default["default"]; + common.register('head', _head, { + canReceivePipe: true, + cmdOptions: { + 'n': 'numLines' + } + }); + + function readSomeLines(file, numLines) { + var buf = common.buffer(); + var bufLength = buf.length; + var bytesRead = bufLength; + var pos = 0; + var fdr = fs.openSync(file, 'r'); + var numLinesRead = 0; + var ret = ''; + + while (bytesRead === bufLength && numLinesRead < numLines) { + bytesRead = fs.readSync(fdr, buf, 0, bufLength, pos); + var bufStr = buf.toString('utf8', 0, bytesRead); + numLinesRead += bufStr.split('\n').length - 1; + ret += bufStr; + pos += bytesRead; + } + + fs.closeSync(fdr); + return ret; + } + + function _head(options, files) { + var head = []; + var pipe = common.readFromPipe(); + if (!files && !pipe) common.error('no paths given'); + var idx = 1; + + if (options.numLines === true) { + idx = 2; + options.numLines = Number(arguments[1]); + } else if (options.numLines === false) { + options.numLines = 10; + } + + files = [].slice.call(arguments, idx); + + if (pipe) { + files.unshift('-'); + } + + var shouldAppendNewline = false; + files.forEach(function (file) { + if (file !== '-') { + if (!fs.existsSync(file)) { + common.error('no such file or directory: ' + file, { + continue: true + }); + return; + } else if (common.statFollowLinks(file).isDirectory()) { + common.error("error reading '" + file + "': Is a directory", { + continue: true + }); + return; + } + } + + var contents; + + if (file === '-') { + contents = pipe; + } else if (options.numLines < 0) { + contents = fs.readFileSync(file, 'utf8'); + } else { + contents = readSomeLines(file, options.numLines); + } + + var lines = contents.split('\n'); + var hasTrailingNewline = lines[lines.length - 1] === ''; + + if (hasTrailingNewline) { + lines.pop(); + } + + shouldAppendNewline = hasTrailingNewline || options.numLines < lines.length; + head = head.concat(lines.slice(0, options.numLines)); + }); + + if (shouldAppendNewline) { + head.push(''); + } + + return head.join('\n'); + } + + head = _head; + return head; +} + +var ln; +var hasRequiredLn; + +function requireLn() { + if (hasRequiredLn) return ln; + hasRequiredLn = 1; + var fs = require$$1__default["default"]; + var path = require$$2__default["default"]; + var common = requireCommon(); + common.register('ln', _ln, { + cmdOptions: { + 's': 'symlink', + 'f': 'force' + } + }); + + function _ln(options, source, dest) { + if (!source || !dest) { + common.error('Missing and/or '); + } + + source = String(source); + var sourcePath = path.normalize(source).replace(RegExp(path.sep + '$'), ''); + var isAbsolute = path.resolve(source) === sourcePath; + dest = path.resolve(process.cwd(), String(dest)); + + if (fs.existsSync(dest)) { + if (!options.force) { + common.error('Destination file exists', { + continue: true + }); + } + + fs.unlinkSync(dest); + } + + if (options.symlink) { + var isWindows = process.platform === 'win32'; + var linkType = isWindows ? 'file' : null; + var resolvedSourcePath = isAbsolute ? sourcePath : path.resolve(process.cwd(), path.dirname(dest), source); + + if (!fs.existsSync(resolvedSourcePath)) { + common.error('Source file does not exist', { + continue: true + }); + } else if (isWindows && common.statFollowLinks(resolvedSourcePath).isDirectory()) { + linkType = 'junction'; + } + + try { + fs.symlinkSync(linkType === 'junction' ? resolvedSourcePath : source, dest, linkType); + } catch (err) { + common.error(err.message); + } + } else { + if (!fs.existsSync(source)) { + common.error('Source file does not exist', { + continue: true + }); + } + + try { + fs.linkSync(source, dest); + } catch (err) { + common.error(err.message); + } + } + + return ''; + } + + ln = _ln; + return ln; +} + +var mkdir; +var hasRequiredMkdir; + +function requireMkdir() { + if (hasRequiredMkdir) return mkdir; + hasRequiredMkdir = 1; + var common = requireCommon(); + var fs = require$$1__default["default"]; + var path = require$$2__default["default"]; + common.register('mkdir', _mkdir, { + cmdOptions: { + 'p': 'fullpath' + } + }); + + function mkdirSyncRecursive(dir) { + var baseDir = path.dirname(dir); + + if (baseDir === dir) { + common.error('dirname() failed: [' + dir + ']'); + } + + if (fs.existsSync(baseDir)) { + fs.mkdirSync(dir, parseInt('0777', 8)); + return; + } + + mkdirSyncRecursive(baseDir); + fs.mkdirSync(dir, parseInt('0777', 8)); + } + + function _mkdir(options, dirs) { + if (!dirs) common.error('no paths given'); + + if (typeof dirs === 'string') { + dirs = [].slice.call(arguments, 1); + } + + dirs.forEach(function (dir) { + try { + var stat = common.statNoFollowLinks(dir); + + if (!options.fullpath) { + common.error('path already exists: ' + dir, { + continue: true + }); + } else if (stat.isFile()) { + common.error('cannot create directory ' + dir + ': File exists', { + continue: true + }); + } + + return; + } catch (e) {} + + var baseDir = path.dirname(dir); + + if (!fs.existsSync(baseDir) && !options.fullpath) { + common.error('no such file or directory: ' + baseDir, { + continue: true + }); + return; + } + + try { + if (options.fullpath) { + mkdirSyncRecursive(path.resolve(dir)); + } else { + fs.mkdirSync(dir, parseInt('0777', 8)); + } + } catch (e) { + var reason; + + if (e.code === 'EACCES') { + reason = 'Permission denied'; + } else if (e.code === 'ENOTDIR' || e.code === 'ENOENT') { + reason = 'Not a directory'; + } else { + throw e; + } + + common.error('cannot create directory ' + dir + ': ' + reason, { + continue: true + }); + } + }); + return ''; + } + + mkdir = _mkdir; + return mkdir; +} + +var rm; +var hasRequiredRm; + +function requireRm() { + if (hasRequiredRm) return rm; + hasRequiredRm = 1; + var common = requireCommon(); + var fs = require$$1__default["default"]; + common.register('rm', _rm, { + cmdOptions: { + 'f': 'force', + 'r': 'recursive', + 'R': 'recursive' + } + }); + + function rmdirSyncRecursive(dir, force, fromSymlink) { + var files; + files = fs.readdirSync(dir); + + for (var i = 0; i < files.length; i++) { + var file = dir + '/' + files[i]; + var currFile = common.statNoFollowLinks(file); + + if (currFile.isDirectory()) { + rmdirSyncRecursive(file, force); + } else { + if (force || isWriteable(file)) { + try { + common.unlinkSync(file); + } catch (e) { + common.error('could not remove file (code ' + e.code + '): ' + file, { + continue: true + }); + } + } + } + } + + if (fromSymlink) return; + var result; + + try { + var start = Date.now(); + + for (;;) { + try { + result = fs.rmdirSync(dir); + if (fs.existsSync(dir)) throw { + code: 'EAGAIN' + }; + break; + } catch (er) { + if (process.platform === 'win32' && (er.code === 'ENOTEMPTY' || er.code === 'EBUSY' || er.code === 'EPERM' || er.code === 'EAGAIN')) { + if (Date.now() - start > 1000) throw er; + } else if (er.code === 'ENOENT') { + break; + } else { + throw er; + } + } + } + } catch (e) { + common.error('could not remove directory (code ' + e.code + '): ' + dir, { + continue: true + }); + } + + return result; + } + + function isWriteable(file) { + var writePermission = true; + + try { + var __fd = fs.openSync(file, 'a'); + + fs.closeSync(__fd); + } catch (e) { + writePermission = false; + } + + return writePermission; + } + + function handleFile(file, options) { + if (options.force || isWriteable(file)) { + common.unlinkSync(file); + } else { + common.error('permission denied: ' + file, { + continue: true + }); + } + } + + function handleDirectory(file, options) { + if (options.recursive) { + rmdirSyncRecursive(file, options.force); + } else { + common.error('path is a directory', { + continue: true + }); + } + } + + function handleSymbolicLink(file, options) { + var stats; + + try { + stats = common.statFollowLinks(file); + } catch (e) { + common.unlinkSync(file); + return; + } + + if (stats.isFile()) { + common.unlinkSync(file); + } else if (stats.isDirectory()) { + if (file[file.length - 1] === '/') { + if (options.recursive) { + var fromSymlink = true; + rmdirSyncRecursive(file, options.force, fromSymlink); + } else { + common.error('path is a directory', { + continue: true + }); + } + } else { + common.unlinkSync(file); + } + } + } + + function handleFIFO(file) { + common.unlinkSync(file); + } + + function _rm(options, files) { + if (!files) common.error('no paths given'); + files = [].slice.call(arguments, 1); + files.forEach(function (file) { + var lstats; + + try { + var filepath = file[file.length - 1] === '/' ? file.slice(0, -1) : file; + lstats = common.statNoFollowLinks(filepath); + } catch (e) { + if (!options.force) { + common.error('no such file or directory: ' + file, { + continue: true + }); + } + + return; + } + + if (lstats.isFile()) { + handleFile(file, options); + } else if (lstats.isDirectory()) { + handleDirectory(file, options); + } else if (lstats.isSymbolicLink()) { + handleSymbolicLink(file, options); + } else if (lstats.isFIFO()) { + handleFIFO(file); + } + }); + return ''; + } + + rm = _rm; + return rm; +} + +var mv; +var hasRequiredMv; + +function requireMv() { + if (hasRequiredMv) return mv; + hasRequiredMv = 1; + var fs = require$$1__default["default"]; + var path = require$$2__default["default"]; + var common = requireCommon(); + var cp = requireCp(); + var rm = requireRm(); + common.register('mv', _mv, { + cmdOptions: { + 'f': '!no_force', + 'n': 'no_force' + } + }); + + function checkRecentCreated(sources, index) { + var lookedSource = sources[index]; + return sources.slice(0, index).some(function (src) { + return path.basename(src) === path.basename(lookedSource); + }); + } + + function _mv(options, sources, dest) { + if (arguments.length < 3) { + common.error('missing and/or '); + } else if (arguments.length > 3) { + sources = [].slice.call(arguments, 1, arguments.length - 1); + dest = arguments[arguments.length - 1]; + } else if (typeof sources === 'string') { + sources = [sources]; + } else { + common.error('invalid arguments'); + } + + var exists = fs.existsSync(dest); + var stats = exists && common.statFollowLinks(dest); + + if ((!exists || !stats.isDirectory()) && sources.length > 1) { + common.error('dest is not a directory (too many sources)'); + } + + if (exists && stats.isFile() && options.no_force) { + common.error('dest file already exists: ' + dest); + } + + sources.forEach(function (src, srcIndex) { + if (!fs.existsSync(src)) { + common.error('no such file or directory: ' + src, { + continue: true + }); + return; + } + + var thisDest = dest; + + if (fs.existsSync(dest) && common.statFollowLinks(dest).isDirectory()) { + thisDest = path.normalize(dest + '/' + path.basename(src)); + } + + var thisDestExists = fs.existsSync(thisDest); + + if (thisDestExists && checkRecentCreated(sources, srcIndex)) { + if (!options.no_force) { + common.error("will not overwrite just-created '" + thisDest + "' with '" + src + "'", { + continue: true + }); + } + + return; + } + + if (fs.existsSync(thisDest) && options.no_force) { + common.error('dest file already exists: ' + thisDest, { + continue: true + }); + return; + } + + if (path.resolve(src) === path.dirname(path.resolve(thisDest))) { + common.error('cannot move to self: ' + src, { + continue: true + }); + return; + } + + try { + fs.renameSync(src, thisDest); + } catch (e) { + if (e.code === 'EXDEV') { + cp('-r', src, thisDest); + rm('-rf', src); + } + } + }); + return ''; + } + + mv = _mv; + return mv; +} + +var popd = {}; + +var hasRequiredPopd; + +function requirePopd() { + if (hasRequiredPopd) return popd; + hasRequiredPopd = 1; + return popd; +} + +var pushd = {}; + +var hasRequiredPushd; + +function requirePushd() { + if (hasRequiredPushd) return pushd; + hasRequiredPushd = 1; + return pushd; +} + +var sed; +var hasRequiredSed; + +function requireSed() { + if (hasRequiredSed) return sed; + hasRequiredSed = 1; + var common = requireCommon(); + var fs = require$$1__default["default"]; + common.register('sed', _sed, { + globStart: 3, + canReceivePipe: true, + cmdOptions: { + 'i': 'inplace' + } + }); + + function _sed(options, regex, replacement, files) { + var pipe = common.readFromPipe(); + + if (typeof replacement !== 'string' && typeof replacement !== 'function') { + if (typeof replacement === 'number') { + replacement = replacement.toString(); + } else { + common.error('invalid replacement string'); + } + } + + if (typeof regex === 'string') { + regex = RegExp(regex); + } + + if (!files && !pipe) { + common.error('no files given'); + } + + files = [].slice.call(arguments, 3); + + if (pipe) { + files.unshift('-'); + } + + var sed = []; + files.forEach(function (file) { + if (!fs.existsSync(file) && file !== '-') { + common.error('no such file or directory: ' + file, 2, { + continue: true + }); + return; + } + + var contents = file === '-' ? pipe : fs.readFileSync(file, 'utf8'); + var lines = contents.split('\n'); + var result = lines.map(function (line) { + return line.replace(regex, replacement); + }).join('\n'); + sed.push(result); + + if (options.inplace) { + fs.writeFileSync(file, result, 'utf8'); + } + }); + return sed.join('\n'); + } + + sed = _sed; + return sed; +} + +var set; +var hasRequiredSet; + +function requireSet() { + if (hasRequiredSet) return set; + hasRequiredSet = 1; + var common = requireCommon(); + common.register('set', _set, { + allowGlobbing: false, + wrapOutput: false + }); + + function _set(options) { + if (!options) { + var args = [].slice.call(arguments, 0); + if (args.length < 2) common.error('must provide an argument'); + options = args[1]; + } + + var negate = options[0] === '+'; + + if (negate) { + options = '-' + options.slice(1); + } + + options = common.parseOptions(options, { + 'e': 'fatal', + 'v': 'verbose', + 'f': 'noglob' + }); + + if (negate) { + Object.keys(options).forEach(function (key) { + options[key] = !options[key]; + }); + } + + Object.keys(options).forEach(function (key) { + if (negate !== options[key]) { + common.config[key] = options[key]; + } + }); + return; + } + + set = _set; + return set; +} + +var $trimEnd = stringTrim.end; +var forcedStringTrimMethod = stringTrimForced; + +// `String.prototype.{ trimEnd, trimRight }` method +// https://tc39.es/ecma262/#sec-string.prototype.trimend +// https://tc39.es/ecma262/#String.prototype.trimright +var stringTrimEnd = forcedStringTrimMethod('trimEnd') ? function trimEnd() { + return $trimEnd(this); +// eslint-disable-next-line es-x/no-string-prototype-trimstart-trimend -- safe +} : ''.trimEnd; + +var $$1 = _export; +var trimEnd$1 = stringTrimEnd; + +// `String.prototype.trimRight` method +// https://tc39.es/ecma262/#sec-string.prototype.trimend +// eslint-disable-next-line es-x/no-string-prototype-trimleft-trimright -- safe +$$1({ target: 'String', proto: true, name: 'trimEnd', forced: ''.trimRight !== trimEnd$1 }, { + trimRight: trimEnd$1 +}); + +// TODO: Remove this line from `core-js@4` + +var $ = _export; +var trimEnd = stringTrimEnd; + +// `String.prototype.trimEnd` method +// https://tc39.es/ecma262/#sec-string.prototype.trimend +// eslint-disable-next-line es-x/no-string-prototype-trimstart-trimend -- safe +$({ target: 'String', proto: true, name: 'trimEnd', forced: ''.trimEnd !== trimEnd }, { + trimEnd: trimEnd +}); + +var sort; +var hasRequiredSort; + +function requireSort() { + if (hasRequiredSort) return sort; + hasRequiredSort = 1; + var common = requireCommon(); + var fs = require$$1__default["default"]; + common.register('sort', _sort, { + canReceivePipe: true, + cmdOptions: { + 'r': 'reverse', + 'n': 'numerical' + } + }); + + function parseNumber(str) { + var match = str.match(/^\s*(\d*)\s*(.*)$/); + return { + num: Number(match[1]), + value: match[2] + }; + } + + function unixCmp(a, b) { + var aLower = a.toLowerCase(); + var bLower = b.toLowerCase(); + return aLower === bLower ? -1 * a.localeCompare(b) : aLower.localeCompare(bLower); + } + + function numericalCmp(a, b) { + var objA = parseNumber(a); + var objB = parseNumber(b); + + if (objA.hasOwnProperty('num') && objB.hasOwnProperty('num')) { + return objA.num !== objB.num ? objA.num - objB.num : unixCmp(objA.value, objB.value); + } else { + return unixCmp(objA.value, objB.value); + } + } + + function _sort(options, files) { + var pipe = common.readFromPipe(); + if (!files && !pipe) common.error('no files given'); + files = [].slice.call(arguments, 1); + + if (pipe) { + files.unshift('-'); + } + + var lines = files.reduce(function (accum, file) { + if (file !== '-') { + if (!fs.existsSync(file)) { + common.error('no such file or directory: ' + file, { + continue: true + }); + return accum; + } else if (common.statFollowLinks(file).isDirectory()) { + common.error('read failed: ' + file + ': Is a directory', { + continue: true + }); + return accum; + } + } + + var contents = file === '-' ? pipe : fs.readFileSync(file, 'utf8'); + return accum.concat(contents.trimRight().split('\n')); + }, []); + var sorted = lines.sort(options.numerical ? numericalCmp : unixCmp); + + if (options.reverse) { + sorted = sorted.reverse(); + } + + return sorted.join('\n') + '\n'; + } + + sort = _sort; + return sort; +} + +var tail; +var hasRequiredTail; + +function requireTail() { + if (hasRequiredTail) return tail; + hasRequiredTail = 1; + var common = requireCommon(); + var fs = require$$1__default["default"]; + common.register('tail', _tail, { + canReceivePipe: true, + cmdOptions: { + 'n': 'numLines' + } + }); + + function _tail(options, files) { + var tail = []; + var pipe = common.readFromPipe(); + if (!files && !pipe) common.error('no paths given'); + var idx = 1; + + if (options.numLines === true) { + idx = 2; + options.numLines = Number(arguments[1]); + } else if (options.numLines === false) { + options.numLines = 10; + } + + options.numLines = -1 * Math.abs(options.numLines); + files = [].slice.call(arguments, idx); + + if (pipe) { + files.unshift('-'); + } + + var shouldAppendNewline = false; + files.forEach(function (file) { + if (file !== '-') { + if (!fs.existsSync(file)) { + common.error('no such file or directory: ' + file, { + continue: true + }); + return; + } else if (common.statFollowLinks(file).isDirectory()) { + common.error("error reading '" + file + "': Is a directory", { + continue: true + }); + return; + } + } + + var contents = file === '-' ? pipe : fs.readFileSync(file, 'utf8'); + var lines = contents.split('\n'); + + if (lines[lines.length - 1] === '') { + lines.pop(); + shouldAppendNewline = true; + } else { + shouldAppendNewline = false; + } + + tail = tail.concat(lines.slice(options.numLines)); + }); + + if (shouldAppendNewline) { + tail.push(''); + } + + return tail.join('\n'); + } + + tail = _tail; + return tail; +} + +var test; +var hasRequiredTest; + +function requireTest() { + if (hasRequiredTest) return test; + hasRequiredTest = 1; + var common = requireCommon(); + var fs = require$$1__default["default"]; + common.register('test', _test, { + cmdOptions: { + 'b': 'block', + 'c': 'character', + 'd': 'directory', + 'e': 'exists', + 'f': 'file', + 'L': 'link', + 'p': 'pipe', + 'S': 'socket' + }, + wrapOutput: false, + allowGlobbing: false + }); + + function _test(options, path) { + if (!path) common.error('no path given'); + var canInterpret = false; + Object.keys(options).forEach(function (key) { + if (options[key] === true) { + canInterpret = true; + } + }); + if (!canInterpret) common.error('could not interpret expression'); + + if (options.link) { + try { + return common.statNoFollowLinks(path).isSymbolicLink(); + } catch (e) { + return false; + } + } + + if (!fs.existsSync(path)) return false; + if (options.exists) return true; + var stats = common.statFollowLinks(path); + if (options.block) return stats.isBlockDevice(); + if (options.character) return stats.isCharacterDevice(); + if (options.directory) return stats.isDirectory(); + if (options.file) return stats.isFile(); + if (options.pipe) return stats.isFIFO(); + if (options.socket) return stats.isSocket(); + return false; + } + + test = _test; + return test; +} + +var to; +var hasRequiredTo; + +function requireTo() { + if (hasRequiredTo) return to; + hasRequiredTo = 1; + var common = requireCommon(); + var fs = require$$1__default["default"]; + var path = require$$2__default["default"]; + common.register('to', _to, { + pipeOnly: true, + wrapOutput: false + }); + + function _to(options, file) { + if (!file) common.error('wrong arguments'); + + if (!fs.existsSync(path.dirname(file))) { + common.error('no such file or directory: ' + path.dirname(file)); + } + + try { + fs.writeFileSync(file, this.stdout || this.toString(), 'utf8'); + return this; + } catch (e) { + common.error('could not write to file (code ' + e.code + '): ' + file, { + continue: true + }); + } + } + + to = _to; + return to; +} + +var toEnd; +var hasRequiredToEnd; + +function requireToEnd() { + if (hasRequiredToEnd) return toEnd; + hasRequiredToEnd = 1; + var common = requireCommon(); + var fs = require$$1__default["default"]; + var path = require$$2__default["default"]; + common.register('toEnd', _toEnd, { + pipeOnly: true, + wrapOutput: false + }); + + function _toEnd(options, file) { + if (!file) common.error('wrong arguments'); + + if (!fs.existsSync(path.dirname(file))) { + common.error('no such file or directory: ' + path.dirname(file)); + } + + try { + fs.appendFileSync(file, this.stdout || this.toString(), 'utf8'); + return this; + } catch (e) { + common.error('could not append to file (code ' + e.code + '): ' + file, { + continue: true + }); + } + } + + toEnd = _toEnd; + return toEnd; +} + +var touch; +var hasRequiredTouch; + +function requireTouch() { + if (hasRequiredTouch) return touch; + hasRequiredTouch = 1; + var common = requireCommon(); + var fs = require$$1__default["default"]; + common.register('touch', _touch, { + cmdOptions: { + 'a': 'atime_only', + 'c': 'no_create', + 'd': 'date', + 'm': 'mtime_only', + 'r': 'reference' + } + }); + + function _touch(opts, files) { + if (!files) { + common.error('no files given'); + } else if (typeof files === 'string') { + files = [].slice.call(arguments, 1); + } else { + common.error('file arg should be a string file path or an Array of string file paths'); + } + + files.forEach(function (f) { + touchFile(opts, f); + }); + return ''; + } + + function touchFile(opts, file) { + var stat = tryStatFile(file); + + if (stat && stat.isDirectory()) { + return; + } + + if (!stat && opts.no_create) { + return; + } + + fs.closeSync(fs.openSync(file, 'a')); + var now = new Date(); + var mtime = opts.date || now; + var atime = opts.date || now; + + if (opts.reference) { + var refStat = tryStatFile(opts.reference); + + if (!refStat) { + common.error('failed to get attributess of ' + opts.reference); + } + + mtime = refStat.mtime; + atime = refStat.atime; + } else if (opts.date) { + mtime = opts.date; + atime = opts.date; + } + + if (opts.atime_only && opts.mtime_only) ; else if (opts.atime_only) { + mtime = stat.mtime; + } else if (opts.mtime_only) { + atime = stat.atime; + } + + fs.utimesSync(file, atime, mtime); + } + + touch = _touch; + + function tryStatFile(filePath) { + try { + return common.statFollowLinks(filePath); + } catch (e) { + return null; + } + } + + return touch; +} + +var uniq; +var hasRequiredUniq; + +function requireUniq() { + if (hasRequiredUniq) return uniq; + hasRequiredUniq = 1; + var common = requireCommon(); + var fs = require$$1__default["default"]; + + function lpad(c, str) { + var res = '' + str; + + if (res.length < c) { + res = Array(c - res.length + 1).join(' ') + res; + } + + return res; + } + + common.register('uniq', _uniq, { + canReceivePipe: true, + cmdOptions: { + 'i': 'ignoreCase', + 'c': 'count', + 'd': 'duplicates' + } + }); + + function _uniq(options, input, output) { + var pipe = common.readFromPipe(); + + if (!pipe) { + if (!input) common.error('no input given'); + + if (!fs.existsSync(input)) { + common.error(input + ': No such file or directory'); + } else if (common.statFollowLinks(input).isDirectory()) { + common.error("error reading '" + input + "'"); + } + } + + if (output && fs.existsSync(output) && common.statFollowLinks(output).isDirectory()) { + common.error(output + ': Is a directory'); + } + + var lines = (input ? fs.readFileSync(input, 'utf8') : pipe).trimRight().split('\n'); + + var compare = function compare(a, b) { + return options.ignoreCase ? a.toLocaleLowerCase().localeCompare(b.toLocaleLowerCase()) : a.localeCompare(b); + }; + + var uniqed = lines.reduceRight(function (res, e) { + if (res.length === 0) { + return [{ + count: 1, + ln: e + }]; + } else if (compare(res[0].ln, e) === 0) { + return [{ + count: res[0].count + 1, + ln: e + }].concat(res.slice(1)); + } else { + return [{ + count: 1, + ln: e + }].concat(res); + } + }, []).filter(function (obj) { + return options.duplicates ? obj.count > 1 : true; + }).map(function (obj) { + return (options.count ? lpad(7, obj.count) + ' ' : '') + obj.ln; + }).join('\n') + '\n'; + + if (output) { + new common.ShellString(uniqed).to(output); + return ''; + } else { + return uniqed; + } + } + + uniq = _uniq; + return uniq; +} + +var which; +var hasRequiredWhich; + +function requireWhich() { + if (hasRequiredWhich) return which; + hasRequiredWhich = 1; + var common = requireCommon(); + var fs = require$$1__default["default"]; + var path = require$$2__default["default"]; + common.register('which', _which, { + allowGlobbing: false, + cmdOptions: { + 'a': 'all' + } + }); + var XP_DEFAULT_PATHEXT = '.com;.exe;.bat;.cmd;.vbs;.vbe;.js;.jse;.wsf;.wsh'; + var FILE_EXECUTABLE_MODE = 1; + + function isWindowsPlatform() { + return process.platform === 'win32'; + } + + function splitPath(p) { + return p ? p.split(path.delimiter) : []; + } + + function isExecutable(pathName) { + try { + fs.accessSync(pathName, FILE_EXECUTABLE_MODE); + } catch (err) { + return false; + } + + return true; + } + + function checkPath(pathName) { + return fs.existsSync(pathName) && !common.statFollowLinks(pathName).isDirectory() && (isWindowsPlatform() || isExecutable(pathName)); + } + + function _which(options, cmd) { + if (!cmd) common.error('must specify command'); + var isWindows = isWindowsPlatform(); + var pathArray = splitPath(process.env.PATH); + var queryMatches = []; + + if (cmd.indexOf('/') === -1) { + var pathExtArray = ['']; + + if (isWindows) { + var pathExtEnv = process.env.PATHEXT || XP_DEFAULT_PATHEXT; + pathExtArray = splitPath(pathExtEnv.toUpperCase()); + } + + for (var k = 0; k < pathArray.length; k++) { + if (queryMatches.length > 0 && !options.all) break; + var attempt = path.resolve(pathArray[k], cmd); + + if (isWindows) { + attempt = attempt.toUpperCase(); + } + + var match = attempt.match(/\.[^<>:"/\|?*.]+$/); + + if (match && pathExtArray.indexOf(match[0]) >= 0) { + if (checkPath(attempt)) { + queryMatches.push(attempt); + break; + } + } else { + for (var i = 0; i < pathExtArray.length; i++) { + var ext = pathExtArray[i]; + var newAttempt = attempt + ext; + + if (checkPath(newAttempt)) { + queryMatches.push(newAttempt); + break; + } + } + } + } + } else if (checkPath(cmd)) { + queryMatches.push(path.resolve(cmd)); + } + + if (queryMatches.length > 0) { + return options.all ? queryMatches : queryMatches[0]; + } + + return options.all ? [] : null; + } + + which = _which; + return which; +} + +var dynamicModules; + +function getDynamicModules() { + return dynamicModules || (dynamicModules = { + "/node_modules/shelljs/src/cat.js": requireCat, + "/node_modules/shelljs/src/cd.js": requireCd, + "/node_modules/shelljs/src/chmod.js": requireChmod, + "/node_modules/shelljs/src/common.js": requireCommon, + "/node_modules/shelljs/src/cp.js": requireCp, + "/node_modules/shelljs/src/dirs.js": requireDirs, + "/node_modules/shelljs/src/echo.js": requireEcho, + "/node_modules/shelljs/src/error.js": requireError, + "/node_modules/shelljs/src/exec-child.js": requireExecChild, + "/node_modules/shelljs/src/exec.js": requireExec, + "/node_modules/shelljs/src/find.js": requireFind, + "/node_modules/shelljs/src/grep.js": requireGrep, + "/node_modules/shelljs/src/head.js": requireHead, + "/node_modules/shelljs/src/ln.js": requireLn, + "/node_modules/shelljs/src/ls.js": requireLs, + "/node_modules/shelljs/src/mkdir.js": requireMkdir, + "/node_modules/shelljs/src/mv.js": requireMv, + "/node_modules/shelljs/src/popd.js": requirePopd, + "/node_modules/shelljs/src/pushd.js": requirePushd, + "/node_modules/shelljs/src/pwd.js": requirePwd, + "/node_modules/shelljs/src/rm.js": requireRm, + "/node_modules/shelljs/src/sed.js": requireSed, + "/node_modules/shelljs/src/set.js": requireSet, + "/node_modules/shelljs/src/sort.js": requireSort, + "/node_modules/shelljs/src/tail.js": requireTail, + "/node_modules/shelljs/src/tempdir.js": requireTempdir, + "/node_modules/shelljs/src/test.js": requireTest, + "/node_modules/shelljs/src/to.js": requireTo, + "/node_modules/shelljs/src/toEnd.js": requireToEnd, + "/node_modules/shelljs/src/touch.js": requireTouch, + "/node_modules/shelljs/src/uniq.js": requireUniq, + "/node_modules/shelljs/src/which.js": requireWhich + }); +} + +function createCommonjsRequire(originalModuleDir) { + function handleRequire(path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return getDynamicModules()[resolvedPath](); + } + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); + } + handleRequire.resolve = function (path) { + var resolvedPath = commonjsResolve(path, originalModuleDir); + if (resolvedPath !== null) { + return resolvedPath; + } + return require.resolve(path); + }; + return handleRequire; +} + +function commonjsResolve (path, originalModuleDir) { + var shouldTryNodeModules = isPossibleNodeModulesPath(path); + path = normalize(path); + var relPath; + if (path[0] === '/') { + originalModuleDir = ''; + } + var modules = getDynamicModules(); + var checkedExtensions = ['', '.js', '.json']; + while (true) { + if (!shouldTryNodeModules) { + relPath = normalize(originalModuleDir + '/' + path); + } else { + relPath = normalize(originalModuleDir + '/node_modules/' + path); + } + + if (relPath.endsWith('/..')) { + break; // Travelled too far up, avoid infinite loop + } + + for (var extensionIndex = 0; extensionIndex < checkedExtensions.length; extensionIndex++) { + var resolvedPath = relPath + checkedExtensions[extensionIndex]; + if (modules[resolvedPath]) { + return resolvedPath; + } + } + if (!shouldTryNodeModules) break; + var nextDir = normalize(originalModuleDir + '/..'); + if (nextDir === originalModuleDir) break; + originalModuleDir = nextDir; + } + return null; +} + +function isPossibleNodeModulesPath (modulePath) { + var c0 = modulePath[0]; + if (c0 === '/' || c0 === '\\') return false; + var c1 = modulePath[1], c2 = modulePath[2]; + if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\')) || + (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\'))) return false; + if (c1 === ':' && (c2 === '/' || c2 === '\\')) return false; + return true; +} + +function normalize (path) { + path = path.replace(/\\/g, '/'); + var parts = path.split('/'); + var slashed = parts[0] === ''; + for (var i = 1; i < parts.length; i++) { + if (parts[i] === '.' || parts[i] === '') { + parts.splice(i--, 1); + } + } + for (var i = 1; i < parts.length; i++) { + if (parts[i] !== '..') continue; + if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') { + parts.splice(--i, 2); + i--; + } + } + path = parts.join('/'); + if (slashed && path[0] !== '/') path = '/' + path; + else if (path.length === 0) path = '.'; + return path; +} + +var shell$2 = {}; + +var commands = ['cat', 'cd', 'chmod', 'cp', 'dirs', 'echo', 'exec', 'find', 'grep', 'head', 'ln', 'ls', 'mkdir', 'mv', 'pwd', 'rm', 'sed', 'set', 'sort', 'tail', 'tempdir', 'test', 'to', 'toEnd', 'touch', 'uniq', 'which']; + +var hasRequiredShell; + +function requireShell() { + if (hasRequiredShell) return shell$2; + hasRequiredShell = 1; + var common = requireCommon(); + commands.forEach(function (command) { + createCommonjsRequire("/node_modules/shelljs")('./src/' + command); + }); + shell$2.exit = process.exit; + shell$2.error = requireError(); + shell$2.ShellString = common.ShellString; + shell$2.env = process.env; + shell$2.config = common.config; + return shell$2; +} + +var shell$1 = requireShell(); +var common = requireCommon(); +Object.keys(shell$1).forEach(function (cmd) { + commonjsGlobal[cmd] = shell$1[cmd]; +}); + +var _to = requireTo(); + +String.prototype.to = common.wrap('to', _to); + +var _toEnd = requireToEnd(); + +String.prototype.toEnd = common.wrap('toEnd', _toEnd); + +commonjsGlobal.config.fatal = true; +commonjsGlobal.target = {}; +var args = process.argv.slice(2), + targetArgs, + dashesLoc = args.indexOf('--'); + +if (dashesLoc > -1) { + targetArgs = args.slice(dashesLoc + 1, args.length); + args = args.slice(0, dashesLoc); +} + +setTimeout(function () { + var t; + + if (args.length === 1 && args[0] === '--help') { + console.log('Available targets:'); + + for (t in commonjsGlobal.target) console.log(' ' + t); + + return; + } + + for (t in commonjsGlobal.target) { + (function (t, oldTarget) { + commonjsGlobal.target[t] = function () { + if (!oldTarget.done) { + oldTarget.done = true; + oldTarget.result = oldTarget.apply(oldTarget, arguments); + } + + return oldTarget.result; + }; + })(t, commonjsGlobal.target[t]); + } + + if (args.length > 0) { + args.forEach(function (arg) { + if (arg in commonjsGlobal.target) commonjsGlobal.target[arg](targetArgs);else { + console.log('no such target: ' + arg); + } + }); + } else if ('all' in commonjsGlobal.target) { + commonjsGlobal.target.all(targetArgs); + } +}, 0); + +const shell = global; +const target = global.target; +const SOURCES = ["packages", "codemods", "eslint"]; +const YARN_PATH = shell.which("yarn").stdout; +const NODE_PATH = process.execPath; +shell.config.verbose = true; + +function print(...msgs) { + console.log.apply(console, msgs); +} + +function exec(executable, args, cwd, inheritStdio = true) { + print(`${executable.replaceAll(YARN_PATH, "yarn").replaceAll(NODE_PATH, "node")} ${args.join(" ")}`); + + try { + return require$$0$1.execFileSync(executable, args, { + stdio: inheritStdio ? "inherit" : undefined, + cwd: cwd && require$$2__default["default"].resolve(cwd), + env: process.env + }); + } catch (error) { + if (inheritStdio && error.status != 0) { + console.error(new Error(`\ncommand: ${executable} ${args.join(" ")}\ncode: ${error.status}`)); + process.exit(error.status); + } + + throw error; + } +} + +function yarn(args, cwd, inheritStdio) { + return exec(YARN_PATH, args, cwd, inheritStdio); +} + +function node(args, cwd, inheritStdio) { + return exec(NODE_PATH, args, cwd, inheritStdio); +} + +function env(fun, env) { + const envBak = process.env; + process.env = Object.assign(Object.assign({}, envBak), env); + fun(); + process.env = envBak; +} + +target["clean-all"] = function () { + ["node_modules", "package-lock.json", ".changelog"].forEach(path => { + shell.rm("-rf", path); + }); + SOURCES.forEach(source => { + shell.rm("-rf", `${source}/*/test/tmp`); + shell.rm("-rf", `${source}/*/package-lock.json`); + }); + target["clean"](); + target["clean-lib"](); +}; + +target["clean"] = function () { + target["test-clean"](); + [".npmrc", "coverage", "packages/*/npm-debug*", "node_modules/.cache"].forEach(path => { + shell.rm("-rf", path); + }); +}; + +target["test-clean"] = function () { + SOURCES.forEach(source => { + shell.rm("-rf", `${source}/*/test/tmp`); + shell.rm("-rf", `${source}/*/test-fixtures.json`); + }); +}; + +target["clean-lib"] = function () { + SOURCES.forEach(source => { + shell.rm("-rf", `${source}/*/lib`); + }); +}; + +target["clean-runtime-helpers"] = function () { + ["packages/babel-runtime/helpers/**/*.js", "packages/babel-runtime-corejs2/helpers/**/*.js", "packages/babel-runtime-corejs3/helpers/**/*.js", "packages/babel-runtime/helpers/**/*.mjs", "packages/babel-runtime-corejs2/helpers/**/*.mjs", "packages/babel-runtime-corejs3/helpers/**/*.mjs", "packages/babel-runtime-corejs2/core-js"].forEach(path => { + shell.rm("-rf", path); + }); +}; + +target["use-cjs"] = function () { + node(["scripts/set-module-type.js", "script"]); + target["bootstrap"](); +}; + +target["use-esm"] = function () { + node(["scripts/set-module-type.js", "module"]); + target["bootstrap"](); +}; + +target["bootstrap-only"] = function () { + target["clean-all"](); + yarn(["install"]); +}; + +target["bootstrap"] = function () { + target["bootstrap-only"](); + target["generate-tsconfig"](); + target["build"](); +}; + +target["build"] = function () { + target["build-bundle"](); + + if (process.env.BABEL_COVERAGE != "true") { + target["build-standalone"](); + } +}; + +target["build-standalone"] = function () { + yarn(["gulp", "build-babel-standalone"]); +}; + +target["build-bundle"] = function () { + node(["scripts/set-module-type.js"]); + target["clean"](); + target["clean-lib"](); + yarn(["gulp", "build"]); + target["build-flow-typings"](); + target["build-dist"](); +}; + +target["build-no-bundle"] = function () { + node(["scripts/set-module-type.js"]); + target["clean"](); + target["clean-lib"](); + env(() => { + yarn(["gulp", "build-dev"]); + }, { + BABEL_ENV: "development" + }); + target["build-flow-typings"](); + target["build-dist"](); +}; + +target["build-flow-typings"] = function () { + require$$1.writeFileSync("packages/babel-types/lib/index.js.flow", node(["packages/babel-types/scripts/generators/flow.js"], undefined, false)); +}; + +target["build-dist"] = function () { + target["build-plugin-transform-runtime-dist"](); +}; + +target["build-plugin-transform-runtime-dist"] = function () { + node(["scripts/build-dist.js"], "packages/babel-plugin-transform-runtime"); +}; + +target["prepublish-build"] = function () { + target["clean-lib"](); + target["clean-runtime-helpers"](); + env(() => { + target["build-bundle"](); + }, { + NODE_ENV: "production", + BABEL_ENV: "production", + STRIP_BABEL_8_FLAG: "true" + }); + env(() => { + target["prepublish-build-standalone"](); + target["clone-license"](); + target["prepublish-prepare-dts"](); + }, { + STRIP_BABEL_8_FLAG: "true" + }); +}; + +target["prepublish-build-standalone"] = function () { + env(() => { + target["build-standalone"](); + }, { + BABEL_ENV: "production", + IS_PUBLISH: "true" + }); +}; + +target["prepublish-prepare-dts"] = function () { + target["tscheck"](); + yarn(["gulp", "bundle-dts"]); + target["build-typescript-legacy-typings"](); +}; + +target["tscheck"] = function () { + target["generate-tsconfig"](); + shell.rm("-rf", "dts"); + yarn(["tsc", "-b", "."]); +}; + +target["generate-tsconfig"] = function () { + node(["scripts/generators/tsconfig.js"]); + node(["scripts/generators/archived-libs-typings.js"]); +}; + +target["generate-type-helpers"] = function () { + yarn(["gulp", "generate-type-helpers"]); +}; + +target["clone-license"] = function () { + node(["scripts/clone-license.js"]); +}; + +target["build-typescript-legacy-typings"] = function () { + require$$1.writeFileSync("packages/babel-types/lib/index-legacy.d.ts", node(["packages/babel-types/scripts/generators/typescript-legacy.js"], undefined, false)); +}; + +target["lint"] = function () { + env(() => { + yarn(["eslint", "scripts", "benchmark", ...SOURCES, "*.{js,cjs,mjs,ts}", "--format", "codeframe", "--ext", ".js,.cjs,.mjs,.ts"]); + }, { + BABEL_ENV: "test" + }); +}; + +target["fix"] = function () { + target["fix-json"](); + target["fix-js"](); +}; + +target["fix-js"] = function () { + yarn(["eslint", "scripts", "benchmark", ...SOURCES, "*.{js,cjs,mjs,ts}", "--format", "codeframe", "--ext", ".js,.cjs,.mjs,.ts", "--fix"]); +}; + +target["fix-json"] = function () { + yarn(["prettier", `{${SOURCES.join(",")}}/*/test/fixtures/**/options.json`, "--write", "--loglevel", "warn"]); +}; + +target["watch"] = function () { + target["build-no-bundle"](); + env(() => { + yarn(["gulp", "watch"]); + }, { + BABEL_ENV: "development", + WATCH_SKIP_BUILD: "true" + }); +}; + +target["test"] = function () { + target["lint"](); + target["test-only"](); +}; + +target["test-only"] = function (args = []) { + yarn(["jest", ...args]); +}; + +target["new-version-checklist"] = function () { +}; + +target["new-version"] = function () { + target["new-version-checklist"](); + exec("git", ["pull", "--rebase"]); + yarn(["release-tool", "version", "-f", "@babel/standalone"]); +}; + +target["new-version"] = function () { + target["new-version-checklist"](); + exec("git", ["pull", "--rebase"]); + yarn(["release-tool", "version", "-f", "@babel/standalone"]); +}; diff --git a/Makefile.mjs b/Makefile.mjs deleted file mode 100644 index 73ddeccb6fd8..000000000000 --- a/Makefile.mjs +++ /dev/null @@ -1,7851 +0,0 @@ -/* eslint-disable */ - //prettier-ignore - import require$$0 from 'os'; -import require$$1, { writeFileSync } from 'fs'; -import require$$2 from 'path'; -import require$$4 from 'events'; -import require$$6 from 'assert'; -import require$$4$1 from 'util'; -import require$$0$1, { execFileSync } from 'child_process'; - -var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; - -var common$2 = {}; - -var old = {}; - -var hasRequiredOld; - -function requireOld () { - if (hasRequiredOld) return old; - hasRequiredOld = 1; - // Copyright Joyent, Inc. and other Node contributors. - // - // Permission is hereby granted, free of charge, to any person obtaining a - // copy of this software and associated documentation files (the - // "Software"), to deal in the Software without restriction, including - // without limitation the rights to use, copy, modify, merge, publish, - // distribute, sublicense, and/or sell copies of the Software, and to permit - // persons to whom the Software is furnished to do so, subject to the - // following conditions: - // - // The above copyright notice and this permission notice shall be included - // in all copies or substantial portions of the Software. - // - // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN - // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, - // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR - // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE - // USE OR OTHER DEALINGS IN THE SOFTWARE. - - var pathModule = require$$2; - var isWindows = process.platform === 'win32'; - var fs = require$$1; - - // JavaScript implementation of realpath, ported from node pre-v6 - - var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG); - - function rethrow() { - // Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and - // is fairly slow to generate. - var callback; - if (DEBUG) { - var backtrace = new Error; - callback = debugCallback; - } else - callback = missingCallback; - - return callback; - - function debugCallback(err) { - if (err) { - backtrace.message = err.message; - err = backtrace; - missingCallback(err); - } - } - - function missingCallback(err) { - if (err) { - if (process.throwDeprecation) - throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs - else if (!process.noDeprecation) { - var msg = 'fs: missing callback ' + (err.stack || err.message); - if (process.traceDeprecation) - console.trace(msg); - else - console.error(msg); - } - } - } - } - - function maybeCallback(cb) { - return typeof cb === 'function' ? cb : rethrow(); - } - - pathModule.normalize; - - // Regexp that finds the next partion of a (partial) path - // result is [base_with_slash, base], e.g. ['somedir/', 'somedir'] - if (isWindows) { - var nextPartRe = /(.*?)(?:[\/\\]+|$)/g; - } else { - var nextPartRe = /(.*?)(?:[\/]+|$)/g; - } - - // Regex to find the device root, including trailing slash. E.g. 'c:\\'. - if (isWindows) { - var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/; - } else { - var splitRootRe = /^[\/]*/; - } - - old.realpathSync = function realpathSync(p, cache) { - // make p is absolute - p = pathModule.resolve(p); - - if (cache && Object.prototype.hasOwnProperty.call(cache, p)) { - return cache[p]; - } - - var original = p, - seenLinks = {}, - knownHard = {}; - - // current character position in p - var pos; - // the partial path so far, including a trailing slash if any - var current; - // the partial path without a trailing slash (except when pointing at a root) - var base; - // the partial path scanned in the previous round, with slash - var previous; - - start(); - - function start() { - // Skip over roots - var m = splitRootRe.exec(p); - pos = m[0].length; - current = m[0]; - base = m[0]; - previous = ''; - - // On windows, check that the root exists. On unix there is no need. - if (isWindows && !knownHard[base]) { - fs.lstatSync(base); - knownHard[base] = true; - } - } - - // walk down the path, swapping out linked pathparts for their real - // values - // NB: p.length changes. - while (pos < p.length) { - // find the next part - nextPartRe.lastIndex = pos; - var result = nextPartRe.exec(p); - previous = current; - current += result[0]; - base = previous + result[1]; - pos = nextPartRe.lastIndex; - - // continue if not a symlink - if (knownHard[base] || (cache && cache[base] === base)) { - continue; - } - - var resolvedLink; - if (cache && Object.prototype.hasOwnProperty.call(cache, base)) { - // some known symbolic link. no need to stat again. - resolvedLink = cache[base]; - } else { - var stat = fs.lstatSync(base); - if (!stat.isSymbolicLink()) { - knownHard[base] = true; - if (cache) cache[base] = base; - continue; - } - - // read the link if it wasn't read before - // dev/ino always return 0 on windows, so skip the check. - var linkTarget = null; - if (!isWindows) { - var id = stat.dev.toString(32) + ':' + stat.ino.toString(32); - if (seenLinks.hasOwnProperty(id)) { - linkTarget = seenLinks[id]; - } - } - if (linkTarget === null) { - fs.statSync(base); - linkTarget = fs.readlinkSync(base); - } - resolvedLink = pathModule.resolve(previous, linkTarget); - // track this, if given a cache. - if (cache) cache[base] = resolvedLink; - if (!isWindows) seenLinks[id] = linkTarget; - } - - // resolve the link, then start over - p = pathModule.resolve(resolvedLink, p.slice(pos)); - start(); - } - - if (cache) cache[original] = p; - - return p; - }; - - - old.realpath = function realpath(p, cache, cb) { - if (typeof cb !== 'function') { - cb = maybeCallback(cache); - cache = null; - } - - // make p is absolute - p = pathModule.resolve(p); - - if (cache && Object.prototype.hasOwnProperty.call(cache, p)) { - return process.nextTick(cb.bind(null, null, cache[p])); - } - - var original = p, - seenLinks = {}, - knownHard = {}; - - // current character position in p - var pos; - // the partial path so far, including a trailing slash if any - var current; - // the partial path without a trailing slash (except when pointing at a root) - var base; - // the partial path scanned in the previous round, with slash - var previous; - - start(); - - function start() { - // Skip over roots - var m = splitRootRe.exec(p); - pos = m[0].length; - current = m[0]; - base = m[0]; - previous = ''; - - // On windows, check that the root exists. On unix there is no need. - if (isWindows && !knownHard[base]) { - fs.lstat(base, function(err) { - if (err) return cb(err); - knownHard[base] = true; - LOOP(); - }); - } else { - process.nextTick(LOOP); - } - } - - // walk down the path, swapping out linked pathparts for their real - // values - function LOOP() { - // stop if scanned past end of path - if (pos >= p.length) { - if (cache) cache[original] = p; - return cb(null, p); - } - - // find the next part - nextPartRe.lastIndex = pos; - var result = nextPartRe.exec(p); - previous = current; - current += result[0]; - base = previous + result[1]; - pos = nextPartRe.lastIndex; - - // continue if not a symlink - if (knownHard[base] || (cache && cache[base] === base)) { - return process.nextTick(LOOP); - } - - if (cache && Object.prototype.hasOwnProperty.call(cache, base)) { - // known symbolic link. no need to stat again. - return gotResolvedLink(cache[base]); - } - - return fs.lstat(base, gotStat); - } - - function gotStat(err, stat) { - if (err) return cb(err); - - // if not a symlink, skip to the next path part - if (!stat.isSymbolicLink()) { - knownHard[base] = true; - if (cache) cache[base] = base; - return process.nextTick(LOOP); - } - - // stat & read the link if not read before - // call gotTarget as soon as the link target is known - // dev/ino always return 0 on windows, so skip the check. - if (!isWindows) { - var id = stat.dev.toString(32) + ':' + stat.ino.toString(32); - if (seenLinks.hasOwnProperty(id)) { - return gotTarget(null, seenLinks[id], base); - } - } - fs.stat(base, function(err) { - if (err) return cb(err); - - fs.readlink(base, function(err, target) { - if (!isWindows) seenLinks[id] = target; - gotTarget(err, target); - }); - }); - } - - function gotTarget(err, target, base) { - if (err) return cb(err); - - var resolvedLink = pathModule.resolve(previous, target); - if (cache) cache[base] = resolvedLink; - gotResolvedLink(resolvedLink); - } - - function gotResolvedLink(resolvedLink) { - // resolve the link, then start over - p = pathModule.resolve(resolvedLink, p.slice(pos)); - start(); - } - }; - return old; -} - -var fs_realpath; -var hasRequiredFs_realpath; - -function requireFs_realpath () { - if (hasRequiredFs_realpath) return fs_realpath; - hasRequiredFs_realpath = 1; - fs_realpath = realpath; - realpath.realpath = realpath; - realpath.sync = realpathSync; - realpath.realpathSync = realpathSync; - realpath.monkeypatch = monkeypatch; - realpath.unmonkeypatch = unmonkeypatch; - - var fs = require$$1; - var origRealpath = fs.realpath; - var origRealpathSync = fs.realpathSync; - - var version = process.version; - var ok = /^v[0-5]\./.test(version); - var old = requireOld(); - - function newError (er) { - return er && er.syscall === 'realpath' && ( - er.code === 'ELOOP' || - er.code === 'ENOMEM' || - er.code === 'ENAMETOOLONG' - ) - } - - function realpath (p, cache, cb) { - if (ok) { - return origRealpath(p, cache, cb) - } - - if (typeof cache === 'function') { - cb = cache; - cache = null; - } - origRealpath(p, cache, function (er, result) { - if (newError(er)) { - old.realpath(p, cache, cb); - } else { - cb(er, result); - } - }); - } - - function realpathSync (p, cache) { - if (ok) { - return origRealpathSync(p, cache) - } - - try { - return origRealpathSync(p, cache) - } catch (er) { - if (newError(er)) { - return old.realpathSync(p, cache) - } else { - throw er - } - } - } - - function monkeypatch () { - fs.realpath = realpath; - fs.realpathSync = realpathSync; - } - - function unmonkeypatch () { - fs.realpath = origRealpath; - fs.realpathSync = origRealpathSync; - } - return fs_realpath; -} - -var concatMap; -var hasRequiredConcatMap; - -function requireConcatMap () { - if (hasRequiredConcatMap) return concatMap; - hasRequiredConcatMap = 1; - concatMap = function (xs, fn) { - var res = []; - for (var i = 0; i < xs.length; i++) { - var x = fn(xs[i], i); - if (isArray(x)) res.push.apply(res, x); - else res.push(x); - } - return res; - }; - - var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; - }; - return concatMap; -} - -var balancedMatch; -var hasRequiredBalancedMatch; - -function requireBalancedMatch () { - if (hasRequiredBalancedMatch) return balancedMatch; - hasRequiredBalancedMatch = 1; - balancedMatch = balanced; - function balanced(a, b, str) { - if (a instanceof RegExp) a = maybeMatch(a, str); - if (b instanceof RegExp) b = maybeMatch(b, str); - - var r = range(a, b, str); - - return r && { - start: r[0], - end: r[1], - pre: str.slice(0, r[0]), - body: str.slice(r[0] + a.length, r[1]), - post: str.slice(r[1] + b.length) - }; - } - - function maybeMatch(reg, str) { - var m = str.match(reg); - return m ? m[0] : null; - } - - balanced.range = range; - function range(a, b, str) { - var begs, beg, left, right, result; - var ai = str.indexOf(a); - var bi = str.indexOf(b, ai + 1); - var i = ai; - - if (ai >= 0 && bi > 0) { - begs = []; - left = str.length; - - while (i >= 0 && !result) { - if (i == ai) { - begs.push(i); - ai = str.indexOf(a, i + 1); - } else if (begs.length == 1) { - result = [ begs.pop(), bi ]; - } else { - beg = begs.pop(); - if (beg < left) { - left = beg; - right = bi; - } - - bi = str.indexOf(b, i + 1); - } - - i = ai < bi && ai >= 0 ? ai : bi; - } - - if (begs.length) { - result = [ left, right ]; - } - } - - return result; - } - return balancedMatch; -} - -var braceExpansion; -var hasRequiredBraceExpansion; - -function requireBraceExpansion () { - if (hasRequiredBraceExpansion) return braceExpansion; - hasRequiredBraceExpansion = 1; - var concatMap = requireConcatMap(); - var balanced = requireBalancedMatch(); - - braceExpansion = expandTop; - - var escSlash = '\0SLASH'+Math.random()+'\0'; - var escOpen = '\0OPEN'+Math.random()+'\0'; - var escClose = '\0CLOSE'+Math.random()+'\0'; - var escComma = '\0COMMA'+Math.random()+'\0'; - var escPeriod = '\0PERIOD'+Math.random()+'\0'; - - function numeric(str) { - return parseInt(str, 10) == str - ? parseInt(str, 10) - : str.charCodeAt(0); - } - - function escapeBraces(str) { - return str.split('\\\\').join(escSlash) - .split('\\{').join(escOpen) - .split('\\}').join(escClose) - .split('\\,').join(escComma) - .split('\\.').join(escPeriod); - } - - function unescapeBraces(str) { - return str.split(escSlash).join('\\') - .split(escOpen).join('{') - .split(escClose).join('}') - .split(escComma).join(',') - .split(escPeriod).join('.'); - } - - - // Basically just str.split(","), but handling cases - // where we have nested braced sections, which should be - // treated as individual members, like {a,{b,c},d} - function parseCommaParts(str) { - if (!str) - return ['']; - - var parts = []; - var m = balanced('{', '}', str); - - if (!m) - return str.split(','); - - var pre = m.pre; - var body = m.body; - var post = m.post; - var p = pre.split(','); - - p[p.length-1] += '{' + body + '}'; - var postParts = parseCommaParts(post); - if (post.length) { - p[p.length-1] += postParts.shift(); - p.push.apply(p, postParts); - } - - parts.push.apply(parts, p); - - return parts; - } - - function expandTop(str) { - if (!str) - return []; - - // I don't know why Bash 4.3 does this, but it does. - // Anything starting with {} will have the first two bytes preserved - // but *only* at the top level, so {},a}b will not expand to anything, - // but a{},b}c will be expanded to [a}c,abc]. - // One could argue that this is a bug in Bash, but since the goal of - // this module is to match Bash's rules, we escape a leading {} - if (str.substr(0, 2) === '{}') { - str = '\\{\\}' + str.substr(2); - } - - return expand(escapeBraces(str), true).map(unescapeBraces); - } - - function embrace(str) { - return '{' + str + '}'; - } - function isPadded(el) { - return /^-?0\d/.test(el); - } - - function lte(i, y) { - return i <= y; - } - function gte(i, y) { - return i >= y; - } - - function expand(str, isTop) { - var expansions = []; - - var m = balanced('{', '}', str); - if (!m || /\$$/.test(m.pre)) return [str]; - - var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body); - var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body); - var isSequence = isNumericSequence || isAlphaSequence; - var isOptions = m.body.indexOf(',') >= 0; - if (!isSequence && !isOptions) { - // {a},b} - if (m.post.match(/,.*\}/)) { - str = m.pre + '{' + m.body + escClose + m.post; - return expand(str); - } - return [str]; - } - - var n; - if (isSequence) { - n = m.body.split(/\.\./); - } else { - n = parseCommaParts(m.body); - if (n.length === 1) { - // x{{a,b}}y ==> x{a}y x{b}y - n = expand(n[0], false).map(embrace); - if (n.length === 1) { - var post = m.post.length - ? expand(m.post, false) - : ['']; - return post.map(function(p) { - return m.pre + n[0] + p; - }); - } - } - } - - // at this point, n is the parts, and we know it's not a comma set - // with a single entry. - - // no need to expand pre, since it is guaranteed to be free of brace-sets - var pre = m.pre; - var post = m.post.length - ? expand(m.post, false) - : ['']; - - var N; - - if (isSequence) { - var x = numeric(n[0]); - var y = numeric(n[1]); - var width = Math.max(n[0].length, n[1].length); - var incr = n.length == 3 - ? Math.abs(numeric(n[2])) - : 1; - var test = lte; - var reverse = y < x; - if (reverse) { - incr *= -1; - test = gte; - } - var pad = n.some(isPadded); - - N = []; - - for (var i = x; test(i, y); i += incr) { - var c; - if (isAlphaSequence) { - c = String.fromCharCode(i); - if (c === '\\') - c = ''; - } else { - c = String(i); - if (pad) { - var need = width - c.length; - if (need > 0) { - var z = new Array(need + 1).join('0'); - if (i < 0) - c = '-' + z + c.slice(1); - else - c = z + c; - } - } - } - N.push(c); - } - } else { - N = concatMap(n, function(el) { return expand(el, false) }); - } - - for (var j = 0; j < N.length; j++) { - for (var k = 0; k < post.length; k++) { - var expansion = pre + N[j] + post[k]; - if (!isTop || isSequence || expansion) - expansions.push(expansion); - } - } - - return expansions; - } - return braceExpansion; -} - -var minimatch_1; -var hasRequiredMinimatch; - -function requireMinimatch () { - if (hasRequiredMinimatch) return minimatch_1; - hasRequiredMinimatch = 1; - minimatch_1 = minimatch; - minimatch.Minimatch = Minimatch; - - var path = { sep: '/' }; - try { - path = require('path'); - } catch (er) {} - - var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}; - var expand = requireBraceExpansion(); - - var plTypes = { - '!': { open: '(?:(?!(?:', close: '))[^/]*?)'}, - '?': { open: '(?:', close: ')?' }, - '+': { open: '(?:', close: ')+' }, - '*': { open: '(?:', close: ')*' }, - '@': { open: '(?:', close: ')' } - }; - - // any single thing other than / - // don't need to escape / when using new RegExp() - var qmark = '[^/]'; - - // * => any number of characters - var star = qmark + '*?'; - - // ** when dots are allowed. Anything goes, except .. and . - // not (^ or / followed by one or two dots followed by $ or /), - // followed by anything, any number of times. - var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?'; - - // not a ^ or / followed by a dot, - // followed by anything, any number of times. - var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?'; - - // characters that need to be escaped in RegExp. - var reSpecials = charSet('().*{}+?[]^$\\!'); - - // "abc" -> { a:true, b:true, c:true } - function charSet (s) { - return s.split('').reduce(function (set, c) { - set[c] = true; - return set - }, {}) - } - - // normalizes slashes. - var slashSplit = /\/+/; - - minimatch.filter = filter; - function filter (pattern, options) { - options = options || {}; - return function (p, i, list) { - return minimatch(p, pattern, options) - } - } - - function ext (a, b) { - a = a || {}; - b = b || {}; - var t = {}; - Object.keys(b).forEach(function (k) { - t[k] = b[k]; - }); - Object.keys(a).forEach(function (k) { - t[k] = a[k]; - }); - return t - } - - minimatch.defaults = function (def) { - if (!def || !Object.keys(def).length) return minimatch - - var orig = minimatch; - - var m = function minimatch (p, pattern, options) { - return orig.minimatch(p, pattern, ext(def, options)) - }; - - m.Minimatch = function Minimatch (pattern, options) { - return new orig.Minimatch(pattern, ext(def, options)) - }; - - return m - }; - - Minimatch.defaults = function (def) { - if (!def || !Object.keys(def).length) return Minimatch - return minimatch.defaults(def).Minimatch - }; - - function minimatch (p, pattern, options) { - if (typeof pattern !== 'string') { - throw new TypeError('glob pattern string required') - } - - if (!options) options = {}; - - // shortcut: comments match nothing. - if (!options.nocomment && pattern.charAt(0) === '#') { - return false - } - - // "" only matches "" - if (pattern.trim() === '') return p === '' - - return new Minimatch(pattern, options).match(p) - } - - function Minimatch (pattern, options) { - if (!(this instanceof Minimatch)) { - return new Minimatch(pattern, options) - } - - if (typeof pattern !== 'string') { - throw new TypeError('glob pattern string required') - } - - if (!options) options = {}; - pattern = pattern.trim(); - - // windows support: need to use /, not \ - if (path.sep !== '/') { - pattern = pattern.split(path.sep).join('/'); - } - - this.options = options; - this.set = []; - this.pattern = pattern; - this.regexp = null; - this.negate = false; - this.comment = false; - this.empty = false; - - // make the set of regexps etc. - this.make(); - } - - Minimatch.prototype.debug = function () {}; - - Minimatch.prototype.make = make; - function make () { - // don't do it more than once. - if (this._made) return - - var pattern = this.pattern; - var options = this.options; - - // empty patterns and comments match nothing. - if (!options.nocomment && pattern.charAt(0) === '#') { - this.comment = true; - return - } - if (!pattern) { - this.empty = true; - return - } - - // step 1: figure out negation, etc. - this.parseNegate(); - - // step 2: expand braces - var set = this.globSet = this.braceExpand(); - - if (options.debug) this.debug = console.error; - - this.debug(this.pattern, set); - - // step 3: now we have a set, so turn each one into a series of path-portion - // matching patterns. - // These will be regexps, except in the case of "**", which is - // set to the GLOBSTAR object for globstar behavior, - // and will not contain any / characters - set = this.globParts = set.map(function (s) { - return s.split(slashSplit) - }); - - this.debug(this.pattern, set); - - // glob --> regexps - set = set.map(function (s, si, set) { - return s.map(this.parse, this) - }, this); - - this.debug(this.pattern, set); - - // filter out everything that didn't compile properly. - set = set.filter(function (s) { - return s.indexOf(false) === -1 - }); - - this.debug(this.pattern, set); - - this.set = set; - } - - Minimatch.prototype.parseNegate = parseNegate; - function parseNegate () { - var pattern = this.pattern; - var negate = false; - var options = this.options; - var negateOffset = 0; - - if (options.nonegate) return - - for (var i = 0, l = pattern.length - ; i < l && pattern.charAt(i) === '!' - ; i++) { - negate = !negate; - negateOffset++; - } - - if (negateOffset) this.pattern = pattern.substr(negateOffset); - this.negate = negate; - } - - // Brace expansion: - // a{b,c}d -> abd acd - // a{b,}c -> abc ac - // a{0..3}d -> a0d a1d a2d a3d - // a{b,c{d,e}f}g -> abg acdfg acefg - // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg - // - // Invalid sets are not expanded. - // a{2..}b -> a{2..}b - // a{b}c -> a{b}c - minimatch.braceExpand = function (pattern, options) { - return braceExpand(pattern, options) - }; - - Minimatch.prototype.braceExpand = braceExpand; - - function braceExpand (pattern, options) { - if (!options) { - if (this instanceof Minimatch) { - options = this.options; - } else { - options = {}; - } - } - - pattern = typeof pattern === 'undefined' - ? this.pattern : pattern; - - if (typeof pattern === 'undefined') { - throw new TypeError('undefined pattern') - } - - if (options.nobrace || - !pattern.match(/\{.*\}/)) { - // shortcut. no need to expand. - return [pattern] - } - - return expand(pattern) - } - - // parse a component of the expanded set. - // At this point, no pattern may contain "/" in it - // so we're going to return a 2d array, where each entry is the full - // pattern, split on '/', and then turned into a regular expression. - // A regexp is made at the end which joins each array with an - // escaped /, and another full one which joins each regexp with |. - // - // Following the lead of Bash 4.1, note that "**" only has special meaning - // when it is the *only* thing in a path portion. Otherwise, any series - // of * is equivalent to a single *. Globstar behavior is enabled by - // default, and can be disabled by setting options.noglobstar. - Minimatch.prototype.parse = parse; - var SUBPARSE = {}; - function parse (pattern, isSub) { - if (pattern.length > 1024 * 64) { - throw new TypeError('pattern is too long') - } - - var options = this.options; - - // shortcuts - if (!options.noglobstar && pattern === '**') return GLOBSTAR - if (pattern === '') return '' - - var re = ''; - var hasMagic = !!options.nocase; - var escaping = false; - // ? => one single character - var patternListStack = []; - var negativeLists = []; - var stateChar; - var inClass = false; - var reClassStart = -1; - var classStart = -1; - // . and .. never match anything that doesn't start with ., - // even when options.dot is set. - var patternStart = pattern.charAt(0) === '.' ? '' // anything - // not (start or / followed by . or .. followed by / or end) - : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' - : '(?!\\.)'; - var self = this; - - function clearStateChar () { - if (stateChar) { - // we had some state-tracking character - // that wasn't consumed by this pass. - switch (stateChar) { - case '*': - re += star; - hasMagic = true; - break - case '?': - re += qmark; - hasMagic = true; - break - default: - re += '\\' + stateChar; - break - } - self.debug('clearStateChar %j %j', stateChar, re); - stateChar = false; - } - } - - for (var i = 0, len = pattern.length, c - ; (i < len) && (c = pattern.charAt(i)) - ; i++) { - this.debug('%s\t%s %s %j', pattern, i, re, c); - - // skip over any that are escaped. - if (escaping && reSpecials[c]) { - re += '\\' + c; - escaping = false; - continue - } - - switch (c) { - case '/': - // completely not allowed, even escaped. - // Should already be path-split by now. - return false - - case '\\': - clearStateChar(); - escaping = true; - continue - - // the various stateChar values - // for the "extglob" stuff. - case '?': - case '*': - case '+': - case '@': - case '!': - this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c); - - // all of those are literals inside a class, except that - // the glob [!a] means [^a] in regexp - if (inClass) { - this.debug(' in class'); - if (c === '!' && i === classStart + 1) c = '^'; - re += c; - continue - } - - // if we already have a stateChar, then it means - // that there was something like ** or +? in there. - // Handle the stateChar, then proceed with this one. - self.debug('call clearStateChar %j', stateChar); - clearStateChar(); - stateChar = c; - // if extglob is disabled, then +(asdf|foo) isn't a thing. - // just clear the statechar *now*, rather than even diving into - // the patternList stuff. - if (options.noext) clearStateChar(); - continue - - case '(': - if (inClass) { - re += '('; - continue - } - - if (!stateChar) { - re += '\\('; - continue - } - - patternListStack.push({ - type: stateChar, - start: i - 1, - reStart: re.length, - open: plTypes[stateChar].open, - close: plTypes[stateChar].close - }); - // negation is (?:(?!js)[^/]*) - re += stateChar === '!' ? '(?:(?!(?:' : '(?:'; - this.debug('plType %j %j', stateChar, re); - stateChar = false; - continue - - case ')': - if (inClass || !patternListStack.length) { - re += '\\)'; - continue - } - - clearStateChar(); - hasMagic = true; - var pl = patternListStack.pop(); - // negation is (?:(?!js)[^/]*) - // The others are (?:) - re += pl.close; - if (pl.type === '!') { - negativeLists.push(pl); - } - pl.reEnd = re.length; - continue - - case '|': - if (inClass || !patternListStack.length || escaping) { - re += '\\|'; - escaping = false; - continue - } - - clearStateChar(); - re += '|'; - continue - - // these are mostly the same in regexp and glob - case '[': - // swallow any state-tracking char before the [ - clearStateChar(); - - if (inClass) { - re += '\\' + c; - continue - } - - inClass = true; - classStart = i; - reClassStart = re.length; - re += c; - continue - - case ']': - // a right bracket shall lose its special - // meaning and represent itself in - // a bracket expression if it occurs - // first in the list. -- POSIX.2 2.8.3.2 - if (i === classStart + 1 || !inClass) { - re += '\\' + c; - escaping = false; - continue - } - - // handle the case where we left a class open. - // "[z-a]" is valid, equivalent to "\[z-a\]" - if (inClass) { - // split where the last [ was, make sure we don't have - // an invalid re. if so, re-walk the contents of the - // would-be class to re-translate any characters that - // were passed through as-is - // TODO: It would probably be faster to determine this - // without a try/catch and a new RegExp, but it's tricky - // to do safely. For now, this is safe and works. - var cs = pattern.substring(classStart + 1, i); - try { - RegExp('[' + cs + ']'); - } catch (er) { - // not a valid class! - var sp = this.parse(cs, SUBPARSE); - re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'; - hasMagic = hasMagic || sp[1]; - inClass = false; - continue - } - } - - // finish up the class. - hasMagic = true; - inClass = false; - re += c; - continue - - default: - // swallow any state char that wasn't consumed - clearStateChar(); - - if (escaping) { - // no need - escaping = false; - } else if (reSpecials[c] - && !(c === '^' && inClass)) { - re += '\\'; - } - - re += c; - - } // switch - } // for - - // handle the case where we left a class open. - // "[abc" is valid, equivalent to "\[abc" - if (inClass) { - // split where the last [ was, and escape it - // this is a huge pita. We now have to re-walk - // the contents of the would-be class to re-translate - // any characters that were passed through as-is - cs = pattern.substr(classStart + 1); - sp = this.parse(cs, SUBPARSE); - re = re.substr(0, reClassStart) + '\\[' + sp[0]; - hasMagic = hasMagic || sp[1]; - } - - // handle the case where we had a +( thing at the *end* - // of the pattern. - // each pattern list stack adds 3 chars, and we need to go through - // and escape any | chars that were passed through as-is for the regexp. - // Go through and escape them, taking care not to double-escape any - // | chars that were already escaped. - for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) { - var tail = re.slice(pl.reStart + pl.open.length); - this.debug('setting tail', re, pl); - // maybe some even number of \, then maybe 1 \, followed by a | - tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) { - if (!$2) { - // the | isn't already escaped, so escape it. - $2 = '\\'; - } - - // need to escape all those slashes *again*, without escaping the - // one that we need for escaping the | character. As it works out, - // escaping an even number of slashes can be done by simply repeating - // it exactly after itself. That's why this trick works. - // - // I am sorry that you have to see this. - return $1 + $1 + $2 + '|' - }); - - this.debug('tail=%j\n %s', tail, tail, pl, re); - var t = pl.type === '*' ? star - : pl.type === '?' ? qmark - : '\\' + pl.type; - - hasMagic = true; - re = re.slice(0, pl.reStart) + t + '\\(' + tail; - } - - // handle trailing things that only matter at the very end. - clearStateChar(); - if (escaping) { - // trailing \\ - re += '\\\\'; - } - - // only need to apply the nodot start if the re starts with - // something that could conceivably capture a dot - var addPatternStart = false; - switch (re.charAt(0)) { - case '.': - case '[': - case '(': addPatternStart = true; - } - - // Hack to work around lack of negative lookbehind in JS - // A pattern like: *.!(x).!(y|z) needs to ensure that a name - // like 'a.xyz.yz' doesn't match. So, the first negative - // lookahead, has to look ALL the way ahead, to the end of - // the pattern. - for (var n = negativeLists.length - 1; n > -1; n--) { - var nl = negativeLists[n]; - - var nlBefore = re.slice(0, nl.reStart); - var nlFirst = re.slice(nl.reStart, nl.reEnd - 8); - var nlLast = re.slice(nl.reEnd - 8, nl.reEnd); - var nlAfter = re.slice(nl.reEnd); - - nlLast += nlAfter; - - // Handle nested stuff like *(*.js|!(*.json)), where open parens - // mean that we should *not* include the ) in the bit that is considered - // "after" the negated section. - var openParensBefore = nlBefore.split('(').length - 1; - var cleanAfter = nlAfter; - for (i = 0; i < openParensBefore; i++) { - cleanAfter = cleanAfter.replace(/\)[+*?]?/, ''); - } - nlAfter = cleanAfter; - - var dollar = ''; - if (nlAfter === '' && isSub !== SUBPARSE) { - dollar = '$'; - } - var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast; - re = newRe; - } - - // if the re is not "" at this point, then we need to make sure - // it doesn't match against an empty path part. - // Otherwise a/* will match a/, which it should not. - if (re !== '' && hasMagic) { - re = '(?=.)' + re; - } - - if (addPatternStart) { - re = patternStart + re; - } - - // parsing just a piece of a larger pattern. - if (isSub === SUBPARSE) { - return [re, hasMagic] - } - - // skip the regexp for non-magical patterns - // unescape anything in it, though, so that it'll be - // an exact match against a file etc. - if (!hasMagic) { - return globUnescape(pattern) - } - - var flags = options.nocase ? 'i' : ''; - try { - var regExp = new RegExp('^' + re + '$', flags); - } catch (er) { - // If it was an invalid regular expression, then it can't match - // anything. This trick looks for a character after the end of - // the string, which is of course impossible, except in multi-line - // mode, but it's not a /m regex. - return new RegExp('$.') - } - - regExp._glob = pattern; - regExp._src = re; - - return regExp - } - - minimatch.makeRe = function (pattern, options) { - return new Minimatch(pattern, options || {}).makeRe() - }; - - Minimatch.prototype.makeRe = makeRe; - function makeRe () { - if (this.regexp || this.regexp === false) return this.regexp - - // at this point, this.set is a 2d array of partial - // pattern strings, or "**". - // - // It's better to use .match(). This function shouldn't - // be used, really, but it's pretty convenient sometimes, - // when you just want to work with a regex. - var set = this.set; - - if (!set.length) { - this.regexp = false; - return this.regexp - } - var options = this.options; - - var twoStar = options.noglobstar ? star - : options.dot ? twoStarDot - : twoStarNoDot; - var flags = options.nocase ? 'i' : ''; - - var re = set.map(function (pattern) { - return pattern.map(function (p) { - return (p === GLOBSTAR) ? twoStar - : (typeof p === 'string') ? regExpEscape(p) - : p._src - }).join('\\\/') - }).join('|'); - - // must match entire pattern - // ending in a * or ** will make it less strict. - re = '^(?:' + re + ')$'; - - // can match anything, as long as it's not this. - if (this.negate) re = '^(?!' + re + ').*$'; - - try { - this.regexp = new RegExp(re, flags); - } catch (ex) { - this.regexp = false; - } - return this.regexp - } - - minimatch.match = function (list, pattern, options) { - options = options || {}; - var mm = new Minimatch(pattern, options); - list = list.filter(function (f) { - return mm.match(f) - }); - if (mm.options.nonull && !list.length) { - list.push(pattern); - } - return list - }; - - Minimatch.prototype.match = match; - function match (f, partial) { - this.debug('match', f, this.pattern); - // short-circuit in the case of busted things. - // comments, etc. - if (this.comment) return false - if (this.empty) return f === '' - - if (f === '/' && partial) return true - - var options = this.options; - - // windows: need to use /, not \ - if (path.sep !== '/') { - f = f.split(path.sep).join('/'); - } - - // treat the test path as a set of pathparts. - f = f.split(slashSplit); - this.debug(this.pattern, 'split', f); - - // just ONE of the pattern sets in this.set needs to match - // in order for it to be valid. If negating, then just one - // match means that we have failed. - // Either way, return on the first hit. - - var set = this.set; - this.debug(this.pattern, 'set', set); - - // Find the basename of the path by looking for the last non-empty segment - var filename; - var i; - for (i = f.length - 1; i >= 0; i--) { - filename = f[i]; - if (filename) break - } - - for (i = 0; i < set.length; i++) { - var pattern = set[i]; - var file = f; - if (options.matchBase && pattern.length === 1) { - file = [filename]; - } - var hit = this.matchOne(file, pattern, partial); - if (hit) { - if (options.flipNegate) return true - return !this.negate - } - } - - // didn't get any hits. this is success if it's a negative - // pattern, failure otherwise. - if (options.flipNegate) return false - return this.negate - } - - // set partial to true to test if, for example, - // "/a/b" matches the start of "/*/b/*/d" - // Partial means, if you run out of file before you run - // out of pattern, then that's fine, as long as all - // the parts match. - Minimatch.prototype.matchOne = function (file, pattern, partial) { - var options = this.options; - - this.debug('matchOne', - { 'this': this, file: file, pattern: pattern }); - - this.debug('matchOne', file.length, pattern.length); - - for (var fi = 0, - pi = 0, - fl = file.length, - pl = pattern.length - ; (fi < fl) && (pi < pl) - ; fi++, pi++) { - this.debug('matchOne loop'); - var p = pattern[pi]; - var f = file[fi]; - - this.debug(pattern, p, f); - - // should be impossible. - // some invalid regexp stuff in the set. - if (p === false) return false - - if (p === GLOBSTAR) { - this.debug('GLOBSTAR', [pattern, p, f]); - - // "**" - // a/**/b/**/c would match the following: - // a/b/x/y/z/c - // a/x/y/z/b/c - // a/b/x/b/x/c - // a/b/c - // To do this, take the rest of the pattern after - // the **, and see if it would match the file remainder. - // If so, return success. - // If not, the ** "swallows" a segment, and try again. - // This is recursively awful. - // - // a/**/b/**/c matching a/b/x/y/z/c - // - a matches a - // - doublestar - // - matchOne(b/x/y/z/c, b/**/c) - // - b matches b - // - doublestar - // - matchOne(x/y/z/c, c) -> no - // - matchOne(y/z/c, c) -> no - // - matchOne(z/c, c) -> no - // - matchOne(c, c) yes, hit - var fr = fi; - var pr = pi + 1; - if (pr === pl) { - this.debug('** at the end'); - // a ** at the end will just swallow the rest. - // We have found a match. - // however, it will not swallow /.x, unless - // options.dot is set. - // . and .. are *never* matched by **, for explosively - // exponential reasons. - for (; fi < fl; fi++) { - if (file[fi] === '.' || file[fi] === '..' || - (!options.dot && file[fi].charAt(0) === '.')) return false - } - return true - } - - // ok, let's see if we can swallow whatever we can. - while (fr < fl) { - var swallowee = file[fr]; - - this.debug('\nglobstar while', file, fr, pattern, pr, swallowee); - - // XXX remove this slice. Just pass the start index. - if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) { - this.debug('globstar found match!', fr, fl, swallowee); - // found a match. - return true - } else { - // can't swallow "." or ".." ever. - // can only swallow ".foo" when explicitly asked. - if (swallowee === '.' || swallowee === '..' || - (!options.dot && swallowee.charAt(0) === '.')) { - this.debug('dot detected!', file, fr, pattern, pr); - break - } - - // ** swallows a segment, and continue. - this.debug('globstar swallow a segment, and continue'); - fr++; - } - } - - // no match was found. - // However, in partial mode, we can't say this is necessarily over. - // If there's more *pattern* left, then - if (partial) { - // ran out of file - this.debug('\n>>> no match, partial?', file, fr, pattern, pr); - if (fr === fl) return true - } - return false - } - - // something other than ** - // non-magic patterns just have to match exactly - // patterns with magic have been turned into regexps. - var hit; - if (typeof p === 'string') { - if (options.nocase) { - hit = f.toLowerCase() === p.toLowerCase(); - } else { - hit = f === p; - } - this.debug('string match', p, f, hit); - } else { - hit = f.match(p); - this.debug('pattern match', p, f, hit); - } - - if (!hit) return false - } - - // Note: ending in / means that we'll get a final "" - // at the end of the pattern. This can only match a - // corresponding "" at the end of the file. - // If the file ends in /, then it can only match a - // a pattern that ends in /, unless the pattern just - // doesn't have any more for it. But, a/b/ should *not* - // match "a/b/*", even though "" matches against the - // [^/]*? pattern, except in partial mode, where it might - // simply not be reached yet. - // However, a/b/ should still satisfy a/* - - // now either we fell off the end of the pattern, or we're done. - if (fi === fl && pi === pl) { - // ran out of pattern and filename at the same time. - // an exact hit! - return true - } else if (fi === fl) { - // ran out of file, but still had pattern left. - // this is ok if we're doing the match as part of - // a glob fs traversal. - return partial - } else if (pi === pl) { - // ran out of pattern, still have file left. - // this is only acceptable if we're on the very last - // empty segment of a file with a trailing slash. - // a/* should match a/b/ - var emptyFileEnd = (fi === fl - 1) && (file[fi] === ''); - return emptyFileEnd - } - - // should be unreachable. - throw new Error('wtf?') - }; - - // replace stuff like \* with * - function globUnescape (s) { - return s.replace(/\\(.)/g, '$1') - } - - function regExpEscape (s) { - return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&') - } - return minimatch_1; -} - -var inherits = {exports: {}}; - -var inherits_browser = {exports: {}}; - -var hasRequiredInherits_browser; - -function requireInherits_browser () { - if (hasRequiredInherits_browser) return inherits_browser.exports; - hasRequiredInherits_browser = 1; - if (typeof Object.create === 'function') { - // implementation from standard node.js 'util' module - inherits_browser.exports = function inherits(ctor, superCtor) { - if (superCtor) { - ctor.super_ = superCtor; - ctor.prototype = Object.create(superCtor.prototype, { - constructor: { - value: ctor, - enumerable: false, - writable: true, - configurable: true - } - }); - } - }; - } else { - // old school shim for old browsers - inherits_browser.exports = function inherits(ctor, superCtor) { - if (superCtor) { - ctor.super_ = superCtor; - var TempCtor = function () {}; - TempCtor.prototype = superCtor.prototype; - ctor.prototype = new TempCtor(); - ctor.prototype.constructor = ctor; - } - }; - } - return inherits_browser.exports; -} - -var hasRequiredInherits; - -function requireInherits () { - if (hasRequiredInherits) return inherits.exports; - hasRequiredInherits = 1; - (function (module) { - try { - var util = require('util'); - /* istanbul ignore next */ - if (typeof util.inherits !== 'function') throw ''; - module.exports = util.inherits; - } catch (e) { - /* istanbul ignore next */ - module.exports = requireInherits_browser(); - } -} (inherits)); - return inherits.exports; -} - -var pathIsAbsolute = {exports: {}}; - -var hasRequiredPathIsAbsolute; - -function requirePathIsAbsolute () { - if (hasRequiredPathIsAbsolute) return pathIsAbsolute.exports; - hasRequiredPathIsAbsolute = 1; - - function posix(path) { - return path.charAt(0) === '/'; - } - - function win32(path) { - // https://github.com/nodejs/node/blob/b3fcc245fb25539909ef1d5eaa01dbf92e168633/lib/path.js#L56 - var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/; - var result = splitDeviceRe.exec(path); - var device = result[1] || ''; - var isUnc = Boolean(device && device.charAt(1) !== ':'); - - // UNC paths are always absolute - return Boolean(result[2] || isUnc); - } - - pathIsAbsolute.exports = process.platform === 'win32' ? win32 : posix; - pathIsAbsolute.exports.posix = posix; - pathIsAbsolute.exports.win32 = win32; - return pathIsAbsolute.exports; -} - -var common$1 = {}; - -var hasRequiredCommon$1; - -function requireCommon$1 () { - if (hasRequiredCommon$1) return common$1; - hasRequiredCommon$1 = 1; - common$1.setopts = setopts; - common$1.ownProp = ownProp; - common$1.makeAbs = makeAbs; - common$1.finish = finish; - common$1.mark = mark; - common$1.isIgnored = isIgnored; - common$1.childrenIgnored = childrenIgnored; - - function ownProp (obj, field) { - return Object.prototype.hasOwnProperty.call(obj, field) - } - - var path = require$$2; - var minimatch = requireMinimatch(); - var isAbsolute = requirePathIsAbsolute(); - var Minimatch = minimatch.Minimatch; - - function alphasort (a, b) { - return a.localeCompare(b, 'en') - } - - function setupIgnores (self, options) { - self.ignore = options.ignore || []; - - if (!Array.isArray(self.ignore)) - self.ignore = [self.ignore]; - - if (self.ignore.length) { - self.ignore = self.ignore.map(ignoreMap); - } - } - - // ignore patterns are always in dot:true mode. - function ignoreMap (pattern) { - var gmatcher = null; - if (pattern.slice(-3) === '/**') { - var gpattern = pattern.replace(/(\/\*\*)+$/, ''); - gmatcher = new Minimatch(gpattern, { dot: true }); - } - - return { - matcher: new Minimatch(pattern, { dot: true }), - gmatcher: gmatcher - } - } - - function setopts (self, pattern, options) { - if (!options) - options = {}; - - // base-matching: just use globstar for that. - if (options.matchBase && -1 === pattern.indexOf("/")) { - if (options.noglobstar) { - throw new Error("base matching requires globstar") - } - pattern = "**/" + pattern; - } - - self.silent = !!options.silent; - self.pattern = pattern; - self.strict = options.strict !== false; - self.realpath = !!options.realpath; - self.realpathCache = options.realpathCache || Object.create(null); - self.follow = !!options.follow; - self.dot = !!options.dot; - self.mark = !!options.mark; - self.nodir = !!options.nodir; - if (self.nodir) - self.mark = true; - self.sync = !!options.sync; - self.nounique = !!options.nounique; - self.nonull = !!options.nonull; - self.nosort = !!options.nosort; - self.nocase = !!options.nocase; - self.stat = !!options.stat; - self.noprocess = !!options.noprocess; - self.absolute = !!options.absolute; - - self.maxLength = options.maxLength || Infinity; - self.cache = options.cache || Object.create(null); - self.statCache = options.statCache || Object.create(null); - self.symlinks = options.symlinks || Object.create(null); - - setupIgnores(self, options); - - self.changedCwd = false; - var cwd = process.cwd(); - if (!ownProp(options, "cwd")) - self.cwd = cwd; - else { - self.cwd = path.resolve(options.cwd); - self.changedCwd = self.cwd !== cwd; - } - - self.root = options.root || path.resolve(self.cwd, "/"); - self.root = path.resolve(self.root); - if (process.platform === "win32") - self.root = self.root.replace(/\\/g, "/"); - - // TODO: is an absolute `cwd` supposed to be resolved against `root`? - // e.g. { cwd: '/test', root: __dirname } === path.join(__dirname, '/test') - self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd); - if (process.platform === "win32") - self.cwdAbs = self.cwdAbs.replace(/\\/g, "/"); - self.nomount = !!options.nomount; - - // disable comments and negation in Minimatch. - // Note that they are not supported in Glob itself anyway. - options.nonegate = true; - options.nocomment = true; - - self.minimatch = new Minimatch(pattern, options); - self.options = self.minimatch.options; - } - - function finish (self) { - var nou = self.nounique; - var all = nou ? [] : Object.create(null); - - for (var i = 0, l = self.matches.length; i < l; i ++) { - var matches = self.matches[i]; - if (!matches || Object.keys(matches).length === 0) { - if (self.nonull) { - // do like the shell, and spit out the literal glob - var literal = self.minimatch.globSet[i]; - if (nou) - all.push(literal); - else - all[literal] = true; - } - } else { - // had matches - var m = Object.keys(matches); - if (nou) - all.push.apply(all, m); - else - m.forEach(function (m) { - all[m] = true; - }); - } - } - - if (!nou) - all = Object.keys(all); - - if (!self.nosort) - all = all.sort(alphasort); - - // at *some* point we statted all of these - if (self.mark) { - for (var i = 0; i < all.length; i++) { - all[i] = self._mark(all[i]); - } - if (self.nodir) { - all = all.filter(function (e) { - var notDir = !(/\/$/.test(e)); - var c = self.cache[e] || self.cache[makeAbs(self, e)]; - if (notDir && c) - notDir = c !== 'DIR' && !Array.isArray(c); - return notDir - }); - } - } - - if (self.ignore.length) - all = all.filter(function(m) { - return !isIgnored(self, m) - }); - - self.found = all; - } - - function mark (self, p) { - var abs = makeAbs(self, p); - var c = self.cache[abs]; - var m = p; - if (c) { - var isDir = c === 'DIR' || Array.isArray(c); - var slash = p.slice(-1) === '/'; - - if (isDir && !slash) - m += '/'; - else if (!isDir && slash) - m = m.slice(0, -1); - - if (m !== p) { - var mabs = makeAbs(self, m); - self.statCache[mabs] = self.statCache[abs]; - self.cache[mabs] = self.cache[abs]; - } - } - - return m - } - - // lotta situps... - function makeAbs (self, f) { - var abs = f; - if (f.charAt(0) === '/') { - abs = path.join(self.root, f); - } else if (isAbsolute(f) || f === '') { - abs = f; - } else if (self.changedCwd) { - abs = path.resolve(self.cwd, f); - } else { - abs = path.resolve(f); - } - - if (process.platform === 'win32') - abs = abs.replace(/\\/g, '/'); - - return abs - } - - - // Return true, if pattern ends with globstar '**', for the accompanying parent directory. - // Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents - function isIgnored (self, path) { - if (!self.ignore.length) - return false - - return self.ignore.some(function(item) { - return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path)) - }) - } - - function childrenIgnored (self, path) { - if (!self.ignore.length) - return false - - return self.ignore.some(function(item) { - return !!(item.gmatcher && item.gmatcher.match(path)) - }) - } - return common$1; -} - -var sync; -var hasRequiredSync; - -function requireSync () { - if (hasRequiredSync) return sync; - hasRequiredSync = 1; - sync = globSync; - globSync.GlobSync = GlobSync; - - var fs = require$$1; - var rp = requireFs_realpath(); - var minimatch = requireMinimatch(); - minimatch.Minimatch; - requireGlob().Glob; - var path = require$$2; - var assert = require$$6; - var isAbsolute = requirePathIsAbsolute(); - var common = requireCommon$1(); - var setopts = common.setopts; - var ownProp = common.ownProp; - var childrenIgnored = common.childrenIgnored; - var isIgnored = common.isIgnored; - - function globSync (pattern, options) { - if (typeof options === 'function' || arguments.length === 3) - throw new TypeError('callback provided to sync glob\n'+ - 'See: https://github.com/isaacs/node-glob/issues/167') - - return new GlobSync(pattern, options).found - } - - function GlobSync (pattern, options) { - if (!pattern) - throw new Error('must provide pattern') - - if (typeof options === 'function' || arguments.length === 3) - throw new TypeError('callback provided to sync glob\n'+ - 'See: https://github.com/isaacs/node-glob/issues/167') - - if (!(this instanceof GlobSync)) - return new GlobSync(pattern, options) - - setopts(this, pattern, options); - - if (this.noprocess) - return this - - var n = this.minimatch.set.length; - this.matches = new Array(n); - for (var i = 0; i < n; i ++) { - this._process(this.minimatch.set[i], i, false); - } - this._finish(); - } - - GlobSync.prototype._finish = function () { - assert(this instanceof GlobSync); - if (this.realpath) { - var self = this; - this.matches.forEach(function (matchset, index) { - var set = self.matches[index] = Object.create(null); - for (var p in matchset) { - try { - p = self._makeAbs(p); - var real = rp.realpathSync(p, self.realpathCache); - set[real] = true; - } catch (er) { - if (er.syscall === 'stat') - set[self._makeAbs(p)] = true; - else - throw er - } - } - }); - } - common.finish(this); - }; - - - GlobSync.prototype._process = function (pattern, index, inGlobStar) { - assert(this instanceof GlobSync); - - // 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. - - // 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); - return - - 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 - } - - 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 - - var isGlobStar = remain[0] === minimatch.GLOBSTAR; - if (isGlobStar) - this._processGlobStar(prefix, read, abs, remain, index, inGlobStar); - else - this._processReaddir(prefix, read, abs, remain, index, inGlobStar); - }; - - - GlobSync.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar) { - var entries = this._readdir(abs, inGlobStar); - - // if the abs isn't a dir, then nothing can match! - if (!entries) - 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) === '.'; - - 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); - } - } - - var len = matchedEntries.length; - // If there are no matched entries, then nothing matches. - if (len === 0) - return - - // 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.slice(-1) !== '/') - 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 - } - - // 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) - newPattern = [prefix, e]; - else - newPattern = [e]; - this._process(newPattern.concat(remain), index, inGlobStar); - } - }; - - - GlobSync.prototype._emitMatch = function (index, e) { - if (isIgnored(this, e)) - return - - var abs = 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; - - if (this.stat) - this._stat(e); - }; - - - GlobSync.prototype._readdirInGlobStar = function (abs) { - // follow all symlinked directories forever - // just proceed as if this is a non-globstar situation - if (this.follow) - return this._readdir(abs, false) - - var entries; - var lstat; - try { - lstat = fs.lstatSync(abs); - } catch (er) { - if (er.code === 'ENOENT') { - // lstat failed, doesn't exist - return null - } - } - - var isSym = lstat && lstat.isSymbolicLink(); - this.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()) - this.cache[abs] = 'FILE'; - else - entries = this._readdir(abs, false); - - return entries - }; - - GlobSync.prototype._readdir = function (abs, inGlobStar) { - - if (inGlobStar && !ownProp(this.symlinks, abs)) - return this._readdirInGlobStar(abs) - - if (ownProp(this.cache, abs)) { - var c = this.cache[abs]; - if (!c || c === 'FILE') - return null - - if (Array.isArray(c)) - return c - } - - try { - return this._readdirEntries(abs, fs.readdirSync(abs)) - } catch (er) { - this._readdirError(abs, er); - return null - } - }; - - GlobSync.prototype._readdirEntries = function (abs, entries) { - // 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; - - // mark and cache dir-ness - return entries - }; - - GlobSync.prototype._readdirError = function (f, er) { - // 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; - throw error - } - 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) - throw er - if (!this.silent) - console.error('glob error', er); - break - } - }; - - GlobSync.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar) { - - var entries = this._readdir(abs, inGlobStar); - - // no entries means not a dir, so it can never have matches - // foo.txt/** doesn't match foo.txt - if (!entries) - return - - // 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); - - var len = entries.length; - var isSym = this.symlinks[abs]; - - // If it's a symlink, and we're in a globstar, then stop - if (isSym && inGlobStar) - return - - 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); - - var below = gspref.concat(entries[i], remain); - this._process(below, index, true); - } - }; - - GlobSync.prototype._processSimple = function (prefix, index) { - // XXX review this. Shouldn't it be doing the mounting etc - // before doing stat? kinda weird? - var exists = this._stat(prefix); - - if (!this.matches[index]) - this.matches[index] = Object.create(null); - - // If it doesn't exist, then just mark the lack of results - if (!exists) - return - - 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 += '/'; - } - } - - if (process.platform === 'win32') - prefix = prefix.replace(/\\/g, '/'); - - // Mark this as a match - this._emitMatch(index, prefix); - }; - - // Returns either 'DIR', 'FILE', or false - GlobSync.prototype._stat = function (f) { - var abs = this._makeAbs(f); - var needDir = f.slice(-1) === '/'; - - if (f.length > this.maxLength) - return false - - if (!this.stat && ownProp(this.cache, abs)) { - var c = this.cache[abs]; - - if (Array.isArray(c)) - c = 'DIR'; - - // It exists, but maybe not how we need it - if (!needDir || c === 'DIR') - return c - - if (needDir && c === 'FILE') - return false - - // otherwise we have to stat, because maybe c=true - // if we know it exists, but not what it is. - } - var stat = this.statCache[abs]; - if (!stat) { - var lstat; - try { - lstat = fs.lstatSync(abs); - } catch (er) { - if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) { - this.statCache[abs] = false; - return false - } - } - - if (lstat && lstat.isSymbolicLink()) { - try { - stat = fs.statSync(abs); - } catch (er) { - stat = lstat; - } - } else { - stat = lstat; - } - } - - this.statCache[abs] = stat; - - var c = true; - if (stat) - c = stat.isDirectory() ? 'DIR' : 'FILE'; - - this.cache[abs] = this.cache[abs] || c; - - if (needDir && c === 'FILE') - return false - - return c - }; - - GlobSync.prototype._mark = function (p) { - return common.mark(this, p) - }; - - GlobSync.prototype._makeAbs = function (f) { - return common.makeAbs(this, f) - }; - return sync; -} - -var wrappy_1; -var hasRequiredWrappy; - -function requireWrappy () { - if (hasRequiredWrappy) return wrappy_1; - hasRequiredWrappy = 1; - // Returns a wrapper function that returns a wrapped callback - // The wrapper function should do some stuff, and return a - // presumably different callback function. - // This makes sure that own properties are retained, so that - // decorations and such are not lost along the way. - wrappy_1 = wrappy; - function wrappy (fn, cb) { - if (fn && cb) return wrappy(fn)(cb) - - if (typeof fn !== 'function') - throw new TypeError('need wrapper function') - - Object.keys(fn).forEach(function (k) { - wrapper[k] = fn[k]; - }); - - return wrapper - - function wrapper() { - var args = new Array(arguments.length); - for (var i = 0; i < args.length; i++) { - args[i] = arguments[i]; - } - var ret = fn.apply(this, args); - var cb = args[args.length-1]; - if (typeof ret === 'function' && ret !== cb) { - Object.keys(cb).forEach(function (k) { - ret[k] = cb[k]; - }); - } - return ret - } - } - return wrappy_1; -} - -var once = {exports: {}}; - -var hasRequiredOnce; - -function requireOnce () { - if (hasRequiredOnce) return once.exports; - hasRequiredOnce = 1; - var wrappy = requireWrappy(); - once.exports = wrappy(once$1); - once.exports.strict = wrappy(onceStrict); - - once$1.proto = once$1(function () { - Object.defineProperty(Function.prototype, 'once', { - value: function () { - return once$1(this) - }, - configurable: true - }); - - Object.defineProperty(Function.prototype, 'onceStrict', { - value: function () { - return onceStrict(this) - }, - configurable: true - }); - }); - - function once$1 (fn) { - var f = function () { - if (f.called) return f.value - f.called = true; - return f.value = fn.apply(this, arguments) - }; - f.called = false; - return f - } - - function onceStrict (fn) { - var f = function () { - if (f.called) - throw new Error(f.onceError) - f.called = true; - return f.value = fn.apply(this, arguments) - }; - var name = fn.name || 'Function wrapped with `once`'; - f.onceError = name + " shouldn't be called more than once"; - f.called = false; - return f - } - return once.exports; -} - -var inflight_1; -var hasRequiredInflight; - -function requireInflight () { - if (hasRequiredInflight) return inflight_1; - hasRequiredInflight = 1; - var wrappy = requireWrappy(); - var reqs = Object.create(null); - var once = requireOnce(); - - inflight_1 = wrappy(inflight); - - function inflight (key, cb) { - if (reqs[key]) { - reqs[key].push(cb); - return null - } else { - reqs[key] = [cb]; - return makeres(key) - } - } - - function makeres (key) { - return once(function RES () { - var cbs = reqs[key]; - var len = cbs.length; - var args = slice(arguments); - - // XXX It's somewhat ambiguous whether a new callback added in this - // pass should be queued for later execution if something in the - // list of callbacks throws, or if it should just be discarded. - // However, it's such an edge case that it hardly matters, and either - // choice is likely as surprising as the other. - // As it happens, we do go ahead and schedule it for later execution. - try { - for (var i = 0; i < len; i++) { - cbs[i].apply(null, args); - } - } finally { - if (cbs.length > len) { - // added more in the interim. - // de-zalgo, just in case, but don't call again. - cbs.splice(0, len); - process.nextTick(function () { - RES.apply(null, args); - }); - } else { - delete reqs[key]; - } - } - }) - } - - function slice (args) { - var length = args.length; - var array = []; - - for (var i = 0; i < length; i++) array[i] = args[i]; - return array - } - return inflight_1; -} - -var glob_1; -var hasRequiredGlob; - -function requireGlob () { - if (hasRequiredGlob) return glob_1; - hasRequiredGlob = 1; - // 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. - - glob_1 = glob; - - var fs = require$$1; - var rp = requireFs_realpath(); - var minimatch = requireMinimatch(); - minimatch.Minimatch; - var inherits = requireInherits(); - var EE = require$$4.EventEmitter; - var path = require$$2; - var assert = require$$6; - var isAbsolute = requirePathIsAbsolute(); - var globSync = requireSync(); - var common = requireCommon$1(); - var setopts = common.setopts; - var ownProp = common.ownProp; - var inflight = requireInflight(); - var childrenIgnored = common.childrenIgnored; - var isIgnored = common.isIgnored; - - var once = requireOnce(); - - function glob (pattern, options, cb) { - if (typeof options === 'function') cb = options, options = {}; - if (!options) options = {}; - - if (options.sync) { - if (cb) - throw new TypeError('callback provided to sync glob') - return globSync(pattern, options) - } - - return new Glob(pattern, options, cb) - } - - glob.sync = globSync; - var GlobSync = glob.GlobSync = globSync.GlobSync; - - // old api surface - glob.glob = glob; - - function extend (origin, add) { - if (add === null || typeof add !== 'object') { - return origin - } - - var keys = Object.keys(add); - var i = keys.length; - while (i--) { - origin[keys[i]] = add[keys[i]]; - } - return origin - } - - 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 - }; - - glob.Glob = Glob; - inherits(Glob, EE); - function Glob (pattern, options, cb) { - if (typeof options === 'function') { - cb = options; - options = null; - } - - if (options && options.sync) { - if (cb) - throw new TypeError('callback provided to sync glob') - return new GlobSync(pattern, options) - } - - if (!(this instanceof Glob)) - return new Glob(pattern, options, cb) - - setopts(this, pattern, options); - this._didRealPath = false; - - // process each pattern in the minimatch set - var n = this.minimatch.set.length; - - // 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); - - if (typeof cb === 'function') { - cb = once(cb); - this.on('error', cb); - this.on('end', function (matches) { - cb(null, matches); - }); - } - - var self = this; - this._processing = 0; - - this._emitQueue = []; - this._processQueue = []; - this.paused = false; - - if (this.noprocess) - return this - - if (n === 0) - return done() - - var sync = true; - for (var i = 0; i < n; i ++) { - this._process(this.minimatch.set[i], i, false, done); - } - sync = false; - - function done () { - --self._processing; - if (self._processing <= 0) { - if (sync) { - process.nextTick(function () { - self._finish(); - }); - } else { - self._finish(); - } - } - } - } - - Glob.prototype._finish = function () { - assert(this instanceof Glob); - if (this.aborted) - return - - if (this.realpath && !this._didRealpath) - return this._realpath() - - common.finish(this); - this.emit('end', this.found); - }; - - Glob.prototype._realpath = function () { - if (this._didRealpath) - return - - this._didRealpath = true; - - var n = this.matches.length; - if (n === 0) - return this._finish() - - var self = this; - for (var i = 0; i < this.matches.length; i++) - this._realpathSet(i, next); - - function next () { - if (--n === 0) - self._finish(); - } - }; - - 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() - - 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(); - } - }); - }); - }; - - Glob.prototype._mark = function (p) { - return common.mark(this, p) - }; - - Glob.prototype._makeAbs = function (f) { - return common.makeAbs(this, f) - }; - - Glob.prototype.abort = function () { - this.aborted = true; - this.emit('abort'); - }; - - Glob.prototype.pause = function () { - if (!this.paused) { - this.paused = true; - this.emit('pause'); - } - }; - - 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]); - } - } - } - }; - - Glob.prototype._process = function (pattern, index, inGlobStar, cb) { - assert(this instanceof Glob); - assert(typeof cb === 'function'); - - if (this.aborted) - return - - this._processing++; - if (this.paused) { - this._processQueue.push([pattern, index, inGlobStar, cb]); - return - } - - //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. - - // 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 - - 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 - } - - 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() - - 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); - }; - - 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) - }); - }; - - 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); - } - } - - //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() - - // 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]; - if (prefix) { - if (prefix !== '/') - e = prefix + '/' + e; - else - e = prefix + e; - } - this._process([e].concat(remain), index, inGlobStar, cb); - } - 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 - } - - 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); - }; - - 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); - } - }; - - 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) - } - 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(); - }; - - 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) { - - //console.error('ps2', prefix, exists) - - if (!this.matches[index]) - this.matches[index] = Object.create(null); - - // If it doesn't exist, then just mark the lack of results - if (!exists) - return cb() - - 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 += '/'; - } - } - - if (process.platform === 'win32') - prefix = prefix.replace(/\\/g, '/'); - - // Mark this as a match - this._emitMatch(index, prefix); - cb(); - }; - - // Returns either 'DIR', 'FILE', or false - Glob.prototype._stat = function (f, cb) { - var abs = this._makeAbs(f); - var needDir = f.slice(-1) === '/'; - - if (f.length > this.maxLength) - return cb() - - if (!this.stat && ownProp(this.cache, abs)) { - var c = this.cache[abs]; - - if (Array.isArray(c)) - c = 'DIR'; - - // It exists, but maybe not how we need it - if (!needDir || c === 'DIR') - return cb(null, c) - - if (needDir && c === 'FILE') - return cb() - - // otherwise we have to stat, because maybe c=true - // if we know it exists, but not what it is. - } - 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) - } - } - - var self = this; - var statcb = inflight('stat\0' + abs, lstatcb_); - if (statcb) - fs.lstat(abs, statcb); - - 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); - } - } - }; - - Glob.prototype._stat2 = function (f, abs, er, stat, cb) { - if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) { - this.statCache[abs] = false; - return cb() - } - - var needDir = f.slice(-1) === '/'; - this.statCache[abs] = stat; - - if (abs.slice(-1) === '/' && stat && !stat.isDirectory()) - return cb(null, false, stat) - - var c = true; - if (stat) - c = stat.isDirectory() ? 'DIR' : 'FILE'; - this.cache[abs] = this.cache[abs] || c; - - if (needDir && c === 'FILE') - return cb() - - return cb(null, c, stat) - }; - return glob_1; -} - -var hasRequiredCommon; - -function requireCommon () { - if (hasRequiredCommon) return common$2; - hasRequiredCommon = 1; - - var os = require$$0; - var fs = require$$1; - var glob = requireGlob(); - var shell = requireShell(); - - var shellMethods = Object.create(shell); - - common$2.extend = Object.assign; - - // Check if we're running under electron - var isElectron = Boolean(process.versions.electron); - - // Module globals (assume no execPath by default) - var DEFAULT_CONFIG = { - fatal: false, - globOptions: {}, - maxdepth: 255, - noglob: false, - silent: false, - verbose: false, - execPath: null, - bufLength: 64 * 1024, // 64KB - }; - - var config = { - reset: function () { - Object.assign(this, DEFAULT_CONFIG); - if (!isElectron) { - this.execPath = process.execPath; - } - }, - resetForTesting: function () { - this.reset(); - this.silent = true; - }, - }; - - config.reset(); - common$2.config = config; - - // Note: commands should generally consider these as read-only values. - var state = { - error: null, - errorCode: 0, - currentCmd: 'shell.js', - }; - common$2.state = state; - - delete process.env.OLDPWD; // initially, there's no previous directory - - // Reliably test if something is any sort of javascript object - function isObject(a) { - return typeof a === 'object' && a !== null; - } - common$2.isObject = isObject; - - function log() { - /* istanbul ignore next */ - if (!config.silent) { - console.error.apply(console, arguments); - } - } - common$2.log = log; - - // Converts strings to be equivalent across all platforms. Primarily responsible - // for making sure we use '/' instead of '\' as path separators, but this may be - // expanded in the future if necessary - function convertErrorOutput(msg) { - if (typeof msg !== 'string') { - throw new TypeError('input must be a string'); - } - return msg.replace(/\\/g, '/'); - } - common$2.convertErrorOutput = convertErrorOutput; - - // Shows error message. Throws if config.fatal is true - function error(msg, _code, options) { - // Validate input - if (typeof msg !== 'string') throw new Error('msg must be a string'); - - var DEFAULT_OPTIONS = { - continue: false, - code: 1, - prefix: state.currentCmd + ': ', - silent: false, - }; - - if (typeof _code === 'number' && isObject(options)) { - options.code = _code; - } else if (isObject(_code)) { // no 'code' - options = _code; - } else if (typeof _code === 'number') { // no 'options' - options = { code: _code }; - } else if (typeof _code !== 'number') { // only 'msg' - options = {}; - } - options = Object.assign({}, DEFAULT_OPTIONS, options); - - if (!state.errorCode) state.errorCode = options.code; - - var logEntry = convertErrorOutput(options.prefix + msg); - state.error = state.error ? state.error + '\n' : ''; - state.error += logEntry; - - // Throw an error, or log the entry - if (config.fatal) throw new Error(logEntry); - if (msg.length > 0 && !options.silent) log(logEntry); - - if (!options.continue) { - throw { - msg: 'earlyExit', - retValue: (new ShellString('', state.error, state.errorCode)), - }; - } - } - common$2.error = error; - - //@ - //@ ### ShellString(str) - //@ - //@ Examples: - //@ - //@ ```javascript - //@ var foo = ShellString('hello world'); - //@ ``` - //@ - //@ Turns a regular string into a string-like object similar to what each - //@ command returns. This has special methods, like `.to()` and `.toEnd()`. - function ShellString(stdout, stderr, code) { - var that; - if (stdout instanceof Array) { - that = stdout; - that.stdout = stdout.join('\n'); - if (stdout.length > 0) that.stdout += '\n'; - } else { - that = new String(stdout); - that.stdout = stdout; - } - that.stderr = stderr; - that.code = code; - // A list of all commands that can appear on the right-hand side of a pipe - // (populated by calls to common.wrap()) - pipeMethods.forEach(function (cmd) { - that[cmd] = shellMethods[cmd].bind(that); - }); - return that; - } - - common$2.ShellString = ShellString; - - // Returns {'alice': true, 'bob': false} when passed a string and dictionary as follows: - // parseOptions('-a', {'a':'alice', 'b':'bob'}); - // Returns {'reference': 'string-value', 'bob': false} when passed two dictionaries of the form: - // parseOptions({'-r': 'string-value'}, {'r':'reference', 'b':'bob'}); - // Throws an error when passed a string that does not start with '-': - // parseOptions('a', {'a':'alice'}); // throws - function parseOptions(opt, map, errorOptions) { - // Validate input - if (typeof opt !== 'string' && !isObject(opt)) { - throw new Error('options must be strings or key-value pairs'); - } else if (!isObject(map)) { - throw new Error('parseOptions() internal error: map must be an object'); - } else if (errorOptions && !isObject(errorOptions)) { - throw new Error('parseOptions() internal error: errorOptions must be object'); - } - - if (opt === '--') { - // This means there are no options. - return {}; - } - - // All options are false by default - var options = {}; - Object.keys(map).forEach(function (letter) { - var optName = map[letter]; - if (optName[0] !== '!') { - options[optName] = false; - } - }); - - if (opt === '') return options; // defaults - - if (typeof opt === 'string') { - if (opt[0] !== '-') { - throw new Error("Options string must start with a '-'"); - } - - // e.g. chars = ['R', 'f'] - var chars = opt.slice(1).split(''); - - chars.forEach(function (c) { - if (c in map) { - var optionName = map[c]; - if (optionName[0] === '!') { - options[optionName.slice(1)] = false; - } else { - options[optionName] = true; - } - } else { - error('option not recognized: ' + c, errorOptions || {}); - } - }); - } else { // opt is an Object - Object.keys(opt).forEach(function (key) { - // key is a string of the form '-r', '-d', etc. - var c = key[1]; - if (c in map) { - var optionName = map[c]; - options[optionName] = opt[key]; // assign the given value - } else { - error('option not recognized: ' + c, errorOptions || {}); - } - }); - } - return options; - } - common$2.parseOptions = parseOptions; - - // Expands wildcards with matching (ie. existing) file names. - // For example: - // expand(['file*.js']) = ['file1.js', 'file2.js', ...] - // (if the files 'file1.js', 'file2.js', etc, exist in the current dir) - function expand(list) { - if (!Array.isArray(list)) { - throw new TypeError('must be an array'); - } - var expanded = []; - list.forEach(function (listEl) { - // Don't expand non-strings - if (typeof listEl !== 'string') { - expanded.push(listEl); - } else { - var ret; - try { - ret = glob.sync(listEl, config.globOptions); - // if nothing matched, interpret the string literally - ret = ret.length > 0 ? ret : [listEl]; - } catch (e) { - // if glob fails, interpret the string literally - ret = [listEl]; - } - expanded = expanded.concat(ret); - } - }); - return expanded; - } - common$2.expand = expand; - - // Normalizes Buffer creation, using Buffer.alloc if possible. - // Also provides a good default buffer length for most use cases. - var buffer = typeof Buffer.alloc === 'function' ? - function (len) { - return Buffer.alloc(len || config.bufLength); - } : - function (len) { - return new Buffer(len || config.bufLength); - }; - common$2.buffer = buffer; - - // Normalizes _unlinkSync() across platforms to match Unix behavior, i.e. - // file can be unlinked even if it's read-only, see https://github.com/joyent/node/issues/3006 - function unlinkSync(file) { - try { - fs.unlinkSync(file); - } catch (e) { - // Try to override file permission - /* istanbul ignore next */ - if (e.code === 'EPERM') { - fs.chmodSync(file, '0666'); - fs.unlinkSync(file); - } else { - throw e; - } - } - } - common$2.unlinkSync = unlinkSync; - - // wrappers around common.statFollowLinks and common.statNoFollowLinks that clarify intent - // and improve readability - function statFollowLinks() { - return fs.statSync.apply(fs, arguments); - } - common$2.statFollowLinks = statFollowLinks; - - function statNoFollowLinks() { - return fs.lstatSync.apply(fs, arguments); - } - common$2.statNoFollowLinks = statNoFollowLinks; - - // e.g. 'shelljs_a5f185d0443ca...' - function randomFileName() { - function randomHash(count) { - if (count === 1) { - return parseInt(16 * Math.random(), 10).toString(16); - } - var hash = ''; - for (var i = 0; i < count; i++) { - hash += randomHash(1); - } - return hash; - } - - return 'shelljs_' + randomHash(20); - } - common$2.randomFileName = randomFileName; - - // Common wrapper for all Unix-like commands that performs glob expansion, - // command-logging, and other nice things - function wrap(cmd, fn, options) { - options = options || {}; - return function () { - var retValue = null; - - state.currentCmd = cmd; - state.error = null; - state.errorCode = 0; - - try { - var args = [].slice.call(arguments, 0); - - // Log the command to stderr, if appropriate - if (config.verbose) { - console.error.apply(console, [cmd].concat(args)); - } - - // If this is coming from a pipe, let's set the pipedValue (otherwise, set - // it to the empty string) - state.pipedValue = (this && typeof this.stdout === 'string') ? this.stdout : ''; - - if (options.unix === false) { // this branch is for exec() - retValue = fn.apply(this, args); - } else { // and this branch is for everything else - if (isObject(args[0]) && args[0].constructor.name === 'Object') { - // a no-op, allowing the syntax `touch({'-r': file}, ...)` - } else if (args.length === 0 || typeof args[0] !== 'string' || args[0].length <= 1 || args[0][0] !== '-') { - args.unshift(''); // only add dummy option if '-option' not already present - } - - // flatten out arrays that are arguments, to make the syntax: - // `cp([file1, file2, file3], dest);` - // equivalent to: - // `cp(file1, file2, file3, dest);` - args = args.reduce(function (accum, cur) { - if (Array.isArray(cur)) { - return accum.concat(cur); - } - accum.push(cur); - return accum; - }, []); - - // Convert ShellStrings (basically just String objects) to regular strings - args = args.map(function (arg) { - if (isObject(arg) && arg.constructor.name === 'String') { - return arg.toString(); - } - return arg; - }); - - // Expand the '~' if appropriate - var homeDir = os.homedir(); - args = args.map(function (arg) { - if (typeof arg === 'string' && arg.slice(0, 2) === '~/' || arg === '~') { - return arg.replace(/^~/, homeDir); - } - return arg; - }); - - // Perform glob-expansion on all arguments after globStart, but preserve - // the arguments before it (like regexes for sed and grep) - if (!config.noglob && options.allowGlobbing === true) { - args = args.slice(0, options.globStart).concat(expand(args.slice(options.globStart))); - } - - try { - // parse options if options are provided - if (isObject(options.cmdOptions)) { - args[0] = parseOptions(args[0], options.cmdOptions); - } - - retValue = fn.apply(this, args); - } catch (e) { - /* istanbul ignore else */ - if (e.msg === 'earlyExit') { - retValue = e.retValue; - } else { - throw e; // this is probably a bug that should be thrown up the call stack - } - } - } - } catch (e) { - /* istanbul ignore next */ - if (!state.error) { - // If state.error hasn't been set it's an error thrown by Node, not us - probably a bug... - e.name = 'ShellJSInternalError'; - throw e; - } - if (config.fatal) throw e; - } - - if (options.wrapOutput && - (typeof retValue === 'string' || Array.isArray(retValue))) { - retValue = new ShellString(retValue, state.error, state.errorCode); - } - - state.currentCmd = 'shell.js'; - return retValue; - }; - } // wrap - common$2.wrap = wrap; - - // This returns all the input that is piped into the current command (or the - // empty string, if this isn't on the right-hand side of a pipe - function _readFromPipe() { - return state.pipedValue; - } - common$2.readFromPipe = _readFromPipe; - - var DEFAULT_WRAP_OPTIONS = { - allowGlobbing: true, - canReceivePipe: false, - cmdOptions: null, - globStart: 1, - pipeOnly: false, - wrapOutput: true, - unix: true, - }; - - // This is populated during plugin registration - var pipeMethods = []; - - // Register a new ShellJS command - function _register(name, implementation, wrapOptions) { - wrapOptions = wrapOptions || {}; - - // Validate options - Object.keys(wrapOptions).forEach(function (option) { - if (!DEFAULT_WRAP_OPTIONS.hasOwnProperty(option)) { - throw new Error("Unknown option '" + option + "'"); - } - if (typeof wrapOptions[option] !== typeof DEFAULT_WRAP_OPTIONS[option]) { - throw new TypeError("Unsupported type '" + typeof wrapOptions[option] + - "' for option '" + option + "'"); - } - }); - - // If an option isn't specified, use the default - wrapOptions = Object.assign({}, DEFAULT_WRAP_OPTIONS, wrapOptions); - - if (shell.hasOwnProperty(name)) { - throw new Error('Command `' + name + '` already exists'); - } - - if (wrapOptions.pipeOnly) { - wrapOptions.canReceivePipe = true; - shellMethods[name] = wrap(name, implementation, wrapOptions); - } else { - shell[name] = wrap(name, implementation, wrapOptions); - } - - if (wrapOptions.canReceivePipe) { - pipeMethods.push(name); - } - } - common$2.register = _register; - return common$2; -} - -var cat; -var hasRequiredCat; - -function requireCat () { - if (hasRequiredCat) return cat; - hasRequiredCat = 1; - var common = requireCommon(); - var fs = require$$1; - - common.register('cat', _cat, { - canReceivePipe: true, - cmdOptions: { - 'n': 'number', - }, - }); - - //@ - //@ ### cat([options,] file [, file ...]) - //@ ### cat([options,] file_array) - //@ - //@ Available options: - //@ - //@ + `-n`: number all output lines - //@ - //@ Examples: - //@ - //@ ```javascript - //@ var str = cat('file*.txt'); - //@ var str = cat('file1', 'file2'); - //@ var str = cat(['file1', 'file2']); // same as above - //@ ``` - //@ - //@ Returns a string containing the given file, or a concatenated string - //@ containing the files if more than one file is given (a new line character is - //@ introduced between each file). - function _cat(options, files) { - var cat = common.readFromPipe(); - - if (!files && !cat) common.error('no paths given'); - - files = [].slice.call(arguments, 1); - - files.forEach(function (file) { - if (!fs.existsSync(file)) { - common.error('no such file or directory: ' + file); - } else if (common.statFollowLinks(file).isDirectory()) { - common.error(file + ': Is a directory'); - } - - cat += fs.readFileSync(file, 'utf8'); - }); - - if (options.number) { - cat = addNumbers(cat); - } - - return cat; - } - cat = _cat; - - function addNumbers(cat) { - var lines = cat.split('\n'); - var lastLine = lines.pop(); - - lines = lines.map(function (line, i) { - return numberedLine(i + 1, line); - }); - - if (lastLine.length) { - lastLine = numberedLine(lines.length + 1, lastLine); - } - lines.push(lastLine); - - return lines.join('\n'); - } - - function numberedLine(n, line) { - // GNU cat use six pad start number + tab. See http://lingrok.org/xref/coreutils/src/cat.c#57 - // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/padStart - var number = (' ' + n).slice(-6) + '\t'; - return number + line; - } - return cat; -} - -var cd; -var hasRequiredCd; - -function requireCd () { - if (hasRequiredCd) return cd; - hasRequiredCd = 1; - var os = require$$0; - var common = requireCommon(); - - common.register('cd', _cd, {}); - - //@ - //@ ### cd([dir]) - //@ - //@ Changes to directory `dir` for the duration of the script. Changes to home - //@ directory if no argument is supplied. - function _cd(options, dir) { - if (!dir) dir = os.homedir(); - - if (dir === '-') { - if (!process.env.OLDPWD) { - common.error('could not find previous directory'); - } else { - dir = process.env.OLDPWD; - } - } - - try { - var curDir = process.cwd(); - process.chdir(dir); - process.env.OLDPWD = curDir; - } catch (e) { - // something went wrong, let's figure out the error - var err; - try { - common.statFollowLinks(dir); // if this succeeds, it must be some sort of file - err = 'not a directory: ' + dir; - } catch (e2) { - err = 'no such file or directory: ' + dir; - } - if (err) common.error(err); - } - return ''; - } - cd = _cd; - return cd; -} - -var chmod; -var hasRequiredChmod; - -function requireChmod () { - if (hasRequiredChmod) return chmod; - hasRequiredChmod = 1; - var common = requireCommon(); - var fs = require$$1; - var path = require$$2; - - var PERMS = (function (base) { - return { - OTHER_EXEC: base.EXEC, - OTHER_WRITE: base.WRITE, - OTHER_READ: base.READ, - - GROUP_EXEC: base.EXEC << 3, - GROUP_WRITE: base.WRITE << 3, - GROUP_READ: base.READ << 3, - - OWNER_EXEC: base.EXEC << 6, - OWNER_WRITE: base.WRITE << 6, - OWNER_READ: base.READ << 6, - - // Literal octal numbers are apparently not allowed in "strict" javascript. - STICKY: parseInt('01000', 8), - SETGID: parseInt('02000', 8), - SETUID: parseInt('04000', 8), - - TYPE_MASK: parseInt('0770000', 8), - }; - }({ - EXEC: 1, - WRITE: 2, - READ: 4, - })); - - common.register('chmod', _chmod, { - }); - - //@ - //@ ### chmod([options,] octal_mode || octal_string, file) - //@ ### chmod([options,] symbolic_mode, file) - //@ - //@ Available options: - //@ - //@ + `-v`: output a diagnostic for every file processed//@ - //@ + `-c`: like verbose, but report only when a change is made//@ - //@ + `-R`: change files and directories recursively//@ - //@ - //@ Examples: - //@ - //@ ```javascript - //@ chmod(755, '/Users/brandon'); - //@ chmod('755', '/Users/brandon'); // same as above - //@ chmod('u+x', '/Users/brandon'); - //@ chmod('-R', 'a-w', '/Users/brandon'); - //@ ``` - //@ - //@ Alters the permissions of a file or directory by either specifying the - //@ absolute permissions in octal form or expressing the changes in symbols. - //@ This command tries to mimic the POSIX behavior as much as possible. - //@ Notable exceptions: - //@ - //@ + In symbolic modes, `a-r` and `-r` are identical. No consideration is - //@ given to the `umask`. - //@ + There is no "quiet" option, since default behavior is to run silent. - function _chmod(options, mode, filePattern) { - if (!filePattern) { - if (options.length > 0 && options.charAt(0) === '-') { - // Special case where the specified file permissions started with - to subtract perms, which - // get picked up by the option parser as command flags. - // If we are down by one argument and options starts with -, shift everything over. - [].unshift.call(arguments, ''); - } else { - common.error('You must specify a file.'); - } - } - - options = common.parseOptions(options, { - 'R': 'recursive', - 'c': 'changes', - 'v': 'verbose', - }); - - filePattern = [].slice.call(arguments, 2); - - var files; - - // TODO: replace this with a call to common.expand() - if (options.recursive) { - files = []; - filePattern.forEach(function addFile(expandedFile) { - var stat = common.statNoFollowLinks(expandedFile); - - if (!stat.isSymbolicLink()) { - files.push(expandedFile); - - if (stat.isDirectory()) { // intentionally does not follow symlinks. - fs.readdirSync(expandedFile).forEach(function (child) { - addFile(expandedFile + '/' + child); - }); - } - } - }); - } else { - files = filePattern; - } - - files.forEach(function innerChmod(file) { - file = path.resolve(file); - if (!fs.existsSync(file)) { - common.error('File not found: ' + file); - } - - // When recursing, don't follow symlinks. - if (options.recursive && common.statNoFollowLinks(file).isSymbolicLink()) { - return; - } - - var stat = common.statFollowLinks(file); - var isDir = stat.isDirectory(); - var perms = stat.mode; - var type = perms & PERMS.TYPE_MASK; - - var newPerms = perms; - - if (isNaN(parseInt(mode, 8))) { - // parse options - mode.split(',').forEach(function (symbolicMode) { - var pattern = /([ugoa]*)([=\+-])([rwxXst]*)/i; - var matches = pattern.exec(symbolicMode); - - if (matches) { - var applyTo = matches[1]; - var operator = matches[2]; - var change = matches[3]; - - var changeOwner = applyTo.indexOf('u') !== -1 || applyTo === 'a' || applyTo === ''; - var changeGroup = applyTo.indexOf('g') !== -1 || applyTo === 'a' || applyTo === ''; - var changeOther = applyTo.indexOf('o') !== -1 || applyTo === 'a' || applyTo === ''; - - var changeRead = change.indexOf('r') !== -1; - var changeWrite = change.indexOf('w') !== -1; - var changeExec = change.indexOf('x') !== -1; - var changeExecDir = change.indexOf('X') !== -1; - var changeSticky = change.indexOf('t') !== -1; - var changeSetuid = change.indexOf('s') !== -1; - - if (changeExecDir && isDir) { - changeExec = true; - } - - var mask = 0; - if (changeOwner) { - mask |= (changeRead ? PERMS.OWNER_READ : 0) + (changeWrite ? PERMS.OWNER_WRITE : 0) + (changeExec ? PERMS.OWNER_EXEC : 0) + (changeSetuid ? PERMS.SETUID : 0); - } - if (changeGroup) { - mask |= (changeRead ? PERMS.GROUP_READ : 0) + (changeWrite ? PERMS.GROUP_WRITE : 0) + (changeExec ? PERMS.GROUP_EXEC : 0) + (changeSetuid ? PERMS.SETGID : 0); - } - if (changeOther) { - mask |= (changeRead ? PERMS.OTHER_READ : 0) + (changeWrite ? PERMS.OTHER_WRITE : 0) + (changeExec ? PERMS.OTHER_EXEC : 0); - } - - // Sticky bit is special - it's not tied to user, group or other. - if (changeSticky) { - mask |= PERMS.STICKY; - } - - switch (operator) { - case '+': - newPerms |= mask; - break; - - case '-': - newPerms &= ~mask; - break; - - case '=': - newPerms = type + mask; - - // According to POSIX, when using = to explicitly set the - // permissions, setuid and setgid can never be cleared. - if (common.statFollowLinks(file).isDirectory()) { - newPerms |= (PERMS.SETUID + PERMS.SETGID) & perms; - } - break; - default: - common.error('Could not recognize operator: `' + operator + '`'); - } - - if (options.verbose) { - console.log(file + ' -> ' + newPerms.toString(8)); - } - - if (perms !== newPerms) { - if (!options.verbose && options.changes) { - console.log(file + ' -> ' + newPerms.toString(8)); - } - fs.chmodSync(file, newPerms); - perms = newPerms; // for the next round of changes! - } - } else { - common.error('Invalid symbolic mode change: ' + symbolicMode); - } - }); - } else { - // they gave us a full number - newPerms = type + parseInt(mode, 8); - - // POSIX rules are that setuid and setgid can only be added using numeric - // form, but not cleared. - if (common.statFollowLinks(file).isDirectory()) { - newPerms |= (PERMS.SETUID + PERMS.SETGID) & perms; - } - - fs.chmodSync(file, newPerms); - } - }); - return ''; - } - chmod = _chmod; - return chmod; -} - -var cp; -var hasRequiredCp; - -function requireCp () { - if (hasRequiredCp) return cp; - hasRequiredCp = 1; - var fs = require$$1; - var path = require$$2; - var common = requireCommon(); - - common.register('cp', _cp, { - cmdOptions: { - 'f': '!no_force', - 'n': 'no_force', - 'u': 'update', - 'R': 'recursive', - 'r': 'recursive', - 'L': 'followsymlink', - 'P': 'noFollowsymlink', - }, - wrapOutput: false, - }); - - // Buffered file copy, synchronous - // (Using readFileSync() + writeFileSync() could easily cause a memory overflow - // with large files) - function copyFileSync(srcFile, destFile, options) { - if (!fs.existsSync(srcFile)) { - common.error('copyFileSync: no such file or directory: ' + srcFile); - } - - var isWindows = process.platform === 'win32'; - - // Check the mtimes of the files if the '-u' flag is provided - try { - if (options.update && common.statFollowLinks(srcFile).mtime < fs.statSync(destFile).mtime) { - return; - } - } catch (e) { - // If we're here, destFile probably doesn't exist, so just do a normal copy - } - - if (common.statNoFollowLinks(srcFile).isSymbolicLink() && !options.followsymlink) { - try { - common.statNoFollowLinks(destFile); - common.unlinkSync(destFile); // re-link it - } catch (e) { - // it doesn't exist, so no work needs to be done - } - - var symlinkFull = fs.readlinkSync(srcFile); - fs.symlinkSync(symlinkFull, destFile, isWindows ? 'junction' : null); - } else { - var buf = common.buffer(); - var bufLength = buf.length; - var bytesRead = bufLength; - var pos = 0; - var fdr = null; - var fdw = null; - - try { - fdr = fs.openSync(srcFile, 'r'); - } catch (e) { - /* istanbul ignore next */ - common.error('copyFileSync: could not read src file (' + srcFile + ')'); - } - - try { - fdw = fs.openSync(destFile, 'w'); - } catch (e) { - /* istanbul ignore next */ - common.error('copyFileSync: could not write to dest file (code=' + e.code + '):' + destFile); - } - - while (bytesRead === bufLength) { - bytesRead = fs.readSync(fdr, buf, 0, bufLength, pos); - fs.writeSync(fdw, buf, 0, bytesRead); - pos += bytesRead; - } - - fs.closeSync(fdr); - fs.closeSync(fdw); - - fs.chmodSync(destFile, common.statFollowLinks(srcFile).mode); - } - } - - // Recursively copies 'sourceDir' into 'destDir' - // Adapted from https://github.com/ryanmcgrath/wrench-js - // - // Copyright (c) 2010 Ryan McGrath - // Copyright (c) 2012 Artur Adib - // - // Licensed under the MIT License - // http://www.opensource.org/licenses/mit-license.php - function cpdirSyncRecursive(sourceDir, destDir, currentDepth, opts) { - if (!opts) opts = {}; - - // Ensure there is not a run away recursive copy - if (currentDepth >= common.config.maxdepth) return; - currentDepth++; - - var isWindows = process.platform === 'win32'; - - // Create the directory where all our junk is moving to; read the mode of the - // source directory and mirror it - try { - fs.mkdirSync(destDir); - } catch (e) { - // if the directory already exists, that's okay - if (e.code !== 'EEXIST') throw e; - } - - var files = fs.readdirSync(sourceDir); - - for (var i = 0; i < files.length; i++) { - var srcFile = sourceDir + '/' + files[i]; - var destFile = destDir + '/' + files[i]; - var srcFileStat = common.statNoFollowLinks(srcFile); - - var symlinkFull; - if (opts.followsymlink) { - if (cpcheckcycle(sourceDir, srcFile)) { - // Cycle link found. - console.error('Cycle link found.'); - symlinkFull = fs.readlinkSync(srcFile); - fs.symlinkSync(symlinkFull, destFile, isWindows ? 'junction' : null); - continue; - } - } - if (srcFileStat.isDirectory()) { - /* recursion this thing right on back. */ - cpdirSyncRecursive(srcFile, destFile, currentDepth, opts); - } else if (srcFileStat.isSymbolicLink() && !opts.followsymlink) { - symlinkFull = fs.readlinkSync(srcFile); - try { - common.statNoFollowLinks(destFile); - common.unlinkSync(destFile); // re-link it - } catch (e) { - // it doesn't exist, so no work needs to be done - } - fs.symlinkSync(symlinkFull, destFile, isWindows ? 'junction' : null); - } else if (srcFileStat.isSymbolicLink() && opts.followsymlink) { - srcFileStat = common.statFollowLinks(srcFile); - if (srcFileStat.isDirectory()) { - cpdirSyncRecursive(srcFile, destFile, currentDepth, opts); - } else { - copyFileSync(srcFile, destFile, opts); - } - } else { - /* At this point, we've hit a file actually worth copying... so copy it on over. */ - if (fs.existsSync(destFile) && opts.no_force) { - common.log('skipping existing file: ' + files[i]); - } else { - copyFileSync(srcFile, destFile, opts); - } - } - } // for files - - // finally change the mode for the newly created directory (otherwise, we - // couldn't add files to a read-only directory). - var checkDir = common.statFollowLinks(sourceDir); - fs.chmodSync(destDir, checkDir.mode); - } // cpdirSyncRecursive - - // Checks if cureent file was created recently - function checkRecentCreated(sources, index) { - var lookedSource = sources[index]; - return sources.slice(0, index).some(function (src) { - return path.basename(src) === path.basename(lookedSource); - }); - } - - function cpcheckcycle(sourceDir, srcFile) { - var srcFileStat = common.statNoFollowLinks(srcFile); - if (srcFileStat.isSymbolicLink()) { - // Do cycle check. For example: - // $ mkdir -p 1/2/3/4 - // $ cd 1/2/3/4 - // $ ln -s ../../3 link - // $ cd ../../../.. - // $ cp -RL 1 copy - var cyclecheck = common.statFollowLinks(srcFile); - if (cyclecheck.isDirectory()) { - var sourcerealpath = fs.realpathSync(sourceDir); - var symlinkrealpath = fs.realpathSync(srcFile); - var re = new RegExp(symlinkrealpath); - if (re.test(sourcerealpath)) { - return true; - } - } - } - return false; - } - - //@ - //@ ### cp([options,] source [, source ...], dest) - //@ ### cp([options,] source_array, dest) - //@ - //@ Available options: - //@ - //@ + `-f`: force (default behavior) - //@ + `-n`: no-clobber - //@ + `-u`: only copy if `source` is newer than `dest` - //@ + `-r`, `-R`: recursive - //@ + `-L`: follow symlinks - //@ + `-P`: don't follow symlinks - //@ - //@ Examples: - //@ - //@ ```javascript - //@ cp('file1', 'dir1'); - //@ cp('-R', 'path/to/dir/', '~/newCopy/'); - //@ cp('-Rf', '/tmp/*', '/usr/local/*', '/home/tmp'); - //@ cp('-Rf', ['/tmp/*', '/usr/local/*'], '/home/tmp'); // same as above - //@ ``` - //@ - //@ Copies files. - function _cp(options, sources, dest) { - // If we're missing -R, it actually implies -L (unless -P is explicit) - if (options.followsymlink) { - options.noFollowsymlink = false; - } - if (!options.recursive && !options.noFollowsymlink) { - options.followsymlink = true; - } - - // Get sources, dest - if (arguments.length < 3) { - common.error('missing and/or '); - } else { - sources = [].slice.call(arguments, 1, arguments.length - 1); - dest = arguments[arguments.length - 1]; - } - - var destExists = fs.existsSync(dest); - var destStat = destExists && common.statFollowLinks(dest); - - // Dest is not existing dir, but multiple sources given - if ((!destExists || !destStat.isDirectory()) && sources.length > 1) { - common.error('dest is not a directory (too many sources)'); - } - - // Dest is an existing file, but -n is given - if (destExists && destStat.isFile() && options.no_force) { - return new common.ShellString('', '', 0); - } - - sources.forEach(function (src, srcIndex) { - if (!fs.existsSync(src)) { - if (src === '') src = "''"; // if src was empty string, display empty string - common.error('no such file or directory: ' + src, { continue: true }); - return; // skip file - } - var srcStat = common.statFollowLinks(src); - if (!options.noFollowsymlink && srcStat.isDirectory()) { - if (!options.recursive) { - // Non-Recursive - common.error("omitting directory '" + src + "'", { continue: true }); - } else { - // Recursive - // 'cp /a/source dest' should create 'source' in 'dest' - var newDest = (destStat && destStat.isDirectory()) ? - path.join(dest, path.basename(src)) : - dest; - - try { - common.statFollowLinks(path.dirname(dest)); - cpdirSyncRecursive(src, newDest, 0, { no_force: options.no_force, followsymlink: options.followsymlink }); - } catch (e) { - /* istanbul ignore next */ - common.error("cannot create directory '" + dest + "': No such file or directory"); - } - } - } else { - // If here, src is a file - - // When copying to '/path/dir': - // thisDest = '/path/dir/file1' - var thisDest = dest; - if (destStat && destStat.isDirectory()) { - thisDest = path.normalize(dest + '/' + path.basename(src)); - } - - var thisDestExists = fs.existsSync(thisDest); - if (thisDestExists && checkRecentCreated(sources, srcIndex)) { - // cannot overwrite file created recently in current execution, but we want to continue copying other files - if (!options.no_force) { - common.error("will not overwrite just-created '" + thisDest + "' with '" + src + "'", { continue: true }); - } - return; - } - - if (thisDestExists && options.no_force) { - return; // skip file - } - - if (path.relative(src, thisDest) === '') { - // a file cannot be copied to itself, but we want to continue copying other files - common.error("'" + thisDest + "' and '" + src + "' are the same file", { continue: true }); - return; - } - - copyFileSync(src, thisDest, options); - } - }); // forEach(src) - - return new common.ShellString('', common.state.error, common.state.errorCode); - } - cp = _cp; - return cp; -} - -var dirs = {}; - -var hasRequiredDirs; - -function requireDirs () { - if (hasRequiredDirs) return dirs; - hasRequiredDirs = 1; - var common = requireCommon(); - var _cd = requireCd(); - var path = require$$2; - - common.register('dirs', _dirs, { - wrapOutput: false, - }); - common.register('pushd', _pushd, { - wrapOutput: false, - }); - common.register('popd', _popd, { - wrapOutput: false, - }); - - // Pushd/popd/dirs internals - var _dirStack = []; - - function _isStackIndex(index) { - return (/^[\-+]\d+$/).test(index); - } - - function _parseStackIndex(index) { - if (_isStackIndex(index)) { - if (Math.abs(index) < _dirStack.length + 1) { // +1 for pwd - return (/^-/).test(index) ? Number(index) - 1 : Number(index); - } - common.error(index + ': directory stack index out of range'); - } else { - common.error(index + ': invalid number'); - } - } - - function _actualDirStack() { - return [process.cwd()].concat(_dirStack); - } - - //@ - //@ ### pushd([options,] [dir | '-N' | '+N']) - //@ - //@ Available options: - //@ - //@ + `-n`: Suppresses the normal change of directory when adding directories to the stack, so that only the stack is manipulated. - //@ + `-q`: Supresses output to the console. - //@ - //@ Arguments: - //@ - //@ + `dir`: Sets the current working directory to the top of the stack, then executes the equivalent of `cd dir`. - //@ + `+N`: Brings the Nth directory (counting from the left of the list printed by dirs, starting with zero) to the top of the list by rotating the stack. - //@ + `-N`: Brings the Nth directory (counting from the right of the list printed by dirs, starting with zero) to the top of the list by rotating the stack. - //@ - //@ Examples: - //@ - //@ ```javascript - //@ // process.cwd() === '/usr' - //@ pushd('/etc'); // Returns /etc /usr - //@ pushd('+1'); // Returns /usr /etc - //@ ``` - //@ - //@ Save the current directory on the top of the directory stack and then `cd` to `dir`. With no arguments, `pushd` exchanges the top two directories. Returns an array of paths in the stack. - function _pushd(options, dir) { - if (_isStackIndex(options)) { - dir = options; - options = ''; - } - - options = common.parseOptions(options, { - 'n': 'no-cd', - 'q': 'quiet', - }); - - var dirs = _actualDirStack(); - - if (dir === '+0') { - return dirs; // +0 is a noop - } else if (!dir) { - if (dirs.length > 1) { - dirs = dirs.splice(1, 1).concat(dirs); - } else { - return common.error('no other directory'); - } - } else if (_isStackIndex(dir)) { - var n = _parseStackIndex(dir); - dirs = dirs.slice(n).concat(dirs.slice(0, n)); - } else { - if (options['no-cd']) { - dirs.splice(1, 0, dir); - } else { - dirs.unshift(dir); - } - } - - if (options['no-cd']) { - dirs = dirs.slice(1); - } else { - dir = path.resolve(dirs.shift()); - _cd('', dir); - } - - _dirStack = dirs; - return _dirs(options.quiet ? '-q' : ''); - } - dirs.pushd = _pushd; - - //@ - //@ - //@ ### popd([options,] ['-N' | '+N']) - //@ - //@ Available options: - //@ - //@ + `-n`: Suppress the normal directory change when removing directories from the stack, so that only the stack is manipulated. - //@ + `-q`: Supresses output to the console. - //@ - //@ Arguments: - //@ - //@ + `+N`: Removes the Nth directory (counting from the left of the list printed by dirs), starting with zero. - //@ + `-N`: Removes the Nth directory (counting from the right of the list printed by dirs), starting with zero. - //@ - //@ Examples: - //@ - //@ ```javascript - //@ echo(process.cwd()); // '/usr' - //@ pushd('/etc'); // '/etc /usr' - //@ echo(process.cwd()); // '/etc' - //@ popd(); // '/usr' - //@ echo(process.cwd()); // '/usr' - //@ ``` - //@ - //@ When no arguments are given, `popd` removes the top directory from the stack and performs a `cd` to the new top directory. The elements are numbered from 0, starting at the first directory listed with dirs (i.e., `popd` is equivalent to `popd +0`). Returns an array of paths in the stack. - function _popd(options, index) { - if (_isStackIndex(options)) { - index = options; - options = ''; - } - - options = common.parseOptions(options, { - 'n': 'no-cd', - 'q': 'quiet', - }); - - if (!_dirStack.length) { - return common.error('directory stack empty'); - } - - index = _parseStackIndex(index || '+0'); - - if (options['no-cd'] || index > 0 || _dirStack.length + index === 0) { - index = index > 0 ? index - 1 : index; - _dirStack.splice(index, 1); - } else { - var dir = path.resolve(_dirStack.shift()); - _cd('', dir); - } - - return _dirs(options.quiet ? '-q' : ''); - } - dirs.popd = _popd; - - //@ - //@ - //@ ### dirs([options | '+N' | '-N']) - //@ - //@ Available options: - //@ - //@ + `-c`: Clears the directory stack by deleting all of the elements. - //@ + `-q`: Supresses output to the console. - //@ - //@ Arguments: - //@ - //@ + `+N`: Displays the Nth directory (counting from the left of the list printed by dirs when invoked without options), starting with zero. - //@ + `-N`: Displays the Nth directory (counting from the right of the list printed by dirs when invoked without options), starting with zero. - //@ - //@ Display the list of currently remembered directories. Returns an array of paths in the stack, or a single path if `+N` or `-N` was specified. - //@ - //@ See also: `pushd`, `popd` - function _dirs(options, index) { - if (_isStackIndex(options)) { - index = options; - options = ''; - } - - options = common.parseOptions(options, { - 'c': 'clear', - 'q': 'quiet', - }); - - if (options.clear) { - _dirStack = []; - return _dirStack; - } - - var stack = _actualDirStack(); - - if (index) { - index = _parseStackIndex(index); - - if (index < 0) { - index = stack.length + index; - } - - if (!options.quiet) { - common.log(stack[index]); - } - return stack[index]; - } - - if (!options.quiet) { - common.log(stack.join(' ')); - } - - return stack; - } - dirs.dirs = _dirs; - return dirs; -} - -var echo; -var hasRequiredEcho; - -function requireEcho () { - if (hasRequiredEcho) return echo; - hasRequiredEcho = 1; - var format = require$$4$1.format; - - var common = requireCommon(); - - common.register('echo', _echo, { - allowGlobbing: false, - }); - - //@ - //@ ### echo([options,] string [, string ...]) - //@ - //@ Available options: - //@ - //@ + `-e`: interpret backslash escapes (default) - //@ + `-n`: remove trailing newline from output - //@ - //@ Examples: - //@ - //@ ```javascript - //@ echo('hello world'); - //@ var str = echo('hello world'); - //@ echo('-n', 'no newline at end'); - //@ ``` - //@ - //@ Prints `string` to stdout, and returns string with additional utility methods - //@ like `.to()`. - function _echo(opts) { - // allow strings starting with '-', see issue #20 - var messages = [].slice.call(arguments, opts ? 0 : 1); - var options = {}; - - // If the first argument starts with '-', parse it as options string. - // If parseOptions throws, it wasn't an options string. - try { - options = common.parseOptions(messages[0], { - 'e': 'escapes', - 'n': 'no_newline', - }, { - silent: true, - }); - - // Allow null to be echoed - if (messages[0]) { - messages.shift(); - } - } catch (_) { - // Clear out error if an error occurred - common.state.error = null; - } - - var output = format.apply(null, messages); - - // Add newline if -n is not passed. - if (!options.no_newline) { - output += '\n'; - } - - process.stdout.write(output); - - return output; - } - - echo = _echo; - return echo; -} - -var error_1; -var hasRequiredError; - -function requireError () { - if (hasRequiredError) return error_1; - hasRequiredError = 1; - var common = requireCommon(); - - //@ - //@ ### error() - //@ - //@ Tests if error occurred in the last command. Returns a truthy value if an - //@ error returned, or a falsy value otherwise. - //@ - //@ **Note**: do not rely on the - //@ return value to be an error message. If you need the last error message, use - //@ the `.stderr` attribute from the last command's return value instead. - function error() { - return common.state.error; - } - error_1 = error; - return error_1; -} - -var execChild = {exports: {}}; - -var hasRequiredExecChild; - -function requireExecChild () { - if (hasRequiredExecChild) return execChild.exports; - hasRequiredExecChild = 1; - (function (module) { - if (require.main !== module) { - throw new Error('This file should not be required'); - } - - var childProcess = require$$0$1; - var fs = require$$1; - - var paramFilePath = process.argv[2]; - - var serializedParams = fs.readFileSync(paramFilePath, 'utf8'); - var params = JSON.parse(serializedParams); - - var cmd = params.command; - var execOptions = params.execOptions; - var pipe = params.pipe; - var stdoutFile = params.stdoutFile; - var stderrFile = params.stderrFile; - - var c = childProcess.exec(cmd, execOptions, function (err) { - if (!err) { - process.exitCode = 0; - } else if (err.code === undefined) { - process.exitCode = 1; - } else { - process.exitCode = err.code; - } - }); - - var stdoutStream = fs.createWriteStream(stdoutFile); - var stderrStream = fs.createWriteStream(stderrFile); - - c.stdout.pipe(stdoutStream); - c.stderr.pipe(stderrStream); - c.stdout.pipe(process.stdout); - c.stderr.pipe(process.stderr); - - if (pipe) { - c.stdin.end(pipe); - } -} (execChild)); - return execChild.exports; -} - -var tempdir = {}; - -var hasRequiredTempdir; - -function requireTempdir () { - if (hasRequiredTempdir) return tempdir; - hasRequiredTempdir = 1; - var common = requireCommon(); - var os = require$$0; - var fs = require$$1; - - common.register('tempdir', _tempDir, { - allowGlobbing: false, - wrapOutput: false, - }); - - // Returns false if 'dir' is not a writeable directory, 'dir' otherwise - function writeableDir(dir) { - if (!dir || !fs.existsSync(dir)) return false; - - if (!common.statFollowLinks(dir).isDirectory()) return false; - - var testFile = dir + '/' + common.randomFileName(); - try { - fs.writeFileSync(testFile, ' '); - common.unlinkSync(testFile); - return dir; - } catch (e) { - /* istanbul ignore next */ - return false; - } - } - - // Variable to cache the tempdir value for successive lookups. - var cachedTempDir; - - //@ - //@ ### tempdir() - //@ - //@ Examples: - //@ - //@ ```javascript - //@ var tmp = tempdir(); // "/tmp" for most *nix platforms - //@ ``` - //@ - //@ Searches and returns string containing a writeable, platform-dependent temporary directory. - //@ Follows Python's [tempfile algorithm](http://docs.python.org/library/tempfile.html#tempfile.tempdir). - function _tempDir() { - if (cachedTempDir) return cachedTempDir; - - cachedTempDir = writeableDir(os.tmpdir()) || - writeableDir(process.env.TMPDIR) || - writeableDir(process.env.TEMP) || - writeableDir(process.env.TMP) || - writeableDir(process.env.Wimp$ScrapDir) || // RiscOS - writeableDir('C:\\TEMP') || // Windows - writeableDir('C:\\TMP') || // Windows - writeableDir('\\TEMP') || // Windows - writeableDir('\\TMP') || // Windows - writeableDir('/tmp') || - writeableDir('/var/tmp') || - writeableDir('/usr/tmp') || - writeableDir('.'); // last resort - - return cachedTempDir; - } - - // Indicates if the tempdir value is currently cached. This is exposed for tests - // only. The return value should only be tested for truthiness. - function isCached() { - return cachedTempDir; - } - - // Clears the cached tempDir value, if one is cached. This is exposed for tests - // only. - function clearCache() { - cachedTempDir = undefined; - } - - tempdir.tempDir = _tempDir; - tempdir.isCached = isCached; - tempdir.clearCache = clearCache; - return tempdir; -} - -var pwd; -var hasRequiredPwd; - -function requirePwd () { - if (hasRequiredPwd) return pwd; - hasRequiredPwd = 1; - var path = require$$2; - var common = requireCommon(); - - common.register('pwd', _pwd, { - allowGlobbing: false, - }); - - //@ - //@ ### pwd() - //@ - //@ Returns the current directory. - function _pwd() { - var pwd = path.resolve(process.cwd()); - return pwd; - } - pwd = _pwd; - return pwd; -} - -var exec$1; -var hasRequiredExec; - -function requireExec () { - if (hasRequiredExec) return exec$1; - hasRequiredExec = 1; - var common = requireCommon(); - var _tempDir = requireTempdir().tempDir; - var _pwd = requirePwd(); - var path = require$$2; - var fs = require$$1; - var child = require$$0$1; - - var DEFAULT_MAXBUFFER_SIZE = 20 * 1024 * 1024; - var DEFAULT_ERROR_CODE = 1; - - common.register('exec', _exec, { - unix: false, - canReceivePipe: true, - wrapOutput: false, - }); - - // We use this function to run `exec` synchronously while also providing realtime - // output. - function execSync(cmd, opts, pipe) { - if (!common.config.execPath) { - common.error('Unable to find a path to the node binary. Please manually set config.execPath'); - } - - var tempDir = _tempDir(); - var paramsFile = path.resolve(tempDir + '/' + common.randomFileName()); - var stderrFile = path.resolve(tempDir + '/' + common.randomFileName()); - var stdoutFile = path.resolve(tempDir + '/' + common.randomFileName()); - - opts = common.extend({ - silent: common.config.silent, - cwd: _pwd().toString(), - env: process.env, - maxBuffer: DEFAULT_MAXBUFFER_SIZE, - encoding: 'utf8', - }, opts); - - if (fs.existsSync(paramsFile)) common.unlinkSync(paramsFile); - if (fs.existsSync(stderrFile)) common.unlinkSync(stderrFile); - if (fs.existsSync(stdoutFile)) common.unlinkSync(stdoutFile); - - opts.cwd = path.resolve(opts.cwd); - - var paramsToSerialize = { - command: cmd, - execOptions: opts, - pipe: pipe, - stdoutFile: stdoutFile, - stderrFile: stderrFile, - }; - - // Create the files and ensure these are locked down (for read and write) to - // the current user. The main concerns here are: - // - // * If we execute a command which prints sensitive output, then - // stdoutFile/stderrFile must not be readable by other users. - // * paramsFile must not be readable by other users, or else they can read it - // to figure out the path for stdoutFile/stderrFile and create these first - // (locked down to their own access), which will crash exec() when it tries - // to write to the files. - function writeFileLockedDown(filePath, data) { - fs.writeFileSync(filePath, data, { - encoding: 'utf8', - mode: parseInt('600', 8), - }); - } - writeFileLockedDown(stdoutFile, ''); - writeFileLockedDown(stderrFile, ''); - writeFileLockedDown(paramsFile, JSON.stringify(paramsToSerialize)); - - var execArgs = [ - path.join(__dirname, 'exec-child.js'), - paramsFile, - ]; - - /* istanbul ignore else */ - if (opts.silent) { - opts.stdio = 'ignore'; - } else { - opts.stdio = [0, 1, 2]; - } - - var code = 0; - - // Welcome to the future - try { - // Bad things if we pass in a `shell` option to child_process.execFileSync, - // so we need to explicitly remove it here. - delete opts.shell; - - child.execFileSync(common.config.execPath, execArgs, opts); - } catch (e) { - // Commands with non-zero exit code raise an exception. - code = e.status || DEFAULT_ERROR_CODE; - } - - // fs.readFileSync uses buffer encoding by default, so call - // it without the encoding option if the encoding is 'buffer'. - // Also, if the exec timeout is too short for node to start up, - // the files will not be created, so these calls will throw. - var stdout = ''; - var stderr = ''; - if (opts.encoding === 'buffer') { - stdout = fs.readFileSync(stdoutFile); - stderr = fs.readFileSync(stderrFile); - } else { - stdout = fs.readFileSync(stdoutFile, opts.encoding); - stderr = fs.readFileSync(stderrFile, opts.encoding); - } - - // No biggie if we can't erase the files now -- they're in a temp dir anyway - // and we locked down permissions (see the note above). - try { common.unlinkSync(paramsFile); } catch (e) {} - try { common.unlinkSync(stderrFile); } catch (e) {} - try { common.unlinkSync(stdoutFile); } catch (e) {} - - if (code !== 0) { - // Note: `silent` should be unconditionally true to avoid double-printing - // the command's stderr, and to avoid printing any stderr when the user has - // set `shell.config.silent`. - common.error(stderr, code, { continue: true, silent: true }); - } - var obj = common.ShellString(stdout, stderr, code); - return obj; - } // execSync() - - // Wrapper around exec() to enable echoing output to console in real time - function execAsync(cmd, opts, pipe, callback) { - opts = common.extend({ - silent: common.config.silent, - cwd: _pwd().toString(), - env: process.env, - maxBuffer: DEFAULT_MAXBUFFER_SIZE, - encoding: 'utf8', - }, opts); - - var c = child.exec(cmd, opts, function (err, stdout, stderr) { - if (callback) { - if (!err) { - callback(0, stdout, stderr); - } else if (err.code === undefined) { - // See issue #536 - /* istanbul ignore next */ - callback(1, stdout, stderr); - } else { - callback(err.code, stdout, stderr); - } - } - }); - - if (pipe) c.stdin.end(pipe); - - if (!opts.silent) { - c.stdout.pipe(process.stdout); - c.stderr.pipe(process.stderr); - } - - return c; - } - - //@ - //@ ### exec(command [, options] [, callback]) - //@ - //@ Available options: - //@ - //@ + `async`: Asynchronous execution. If a callback is provided, it will be set to - //@ `true`, regardless of the passed value (default: `false`). - //@ + `silent`: Do not echo program output to console (default: `false`). - //@ + `encoding`: Character encoding to use. Affects the values returned to stdout and stderr, and - //@ what is written to stdout and stderr when not in silent mode (default: `'utf8'`). - //@ + and any option available to Node.js's - //@ [`child_process.exec()`](https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback) - //@ - //@ Examples: - //@ - //@ ```javascript - //@ var version = exec('node --version', {silent:true}).stdout; - //@ - //@ var child = exec('some_long_running_process', {async:true}); - //@ child.stdout.on('data', function(data) { - //@ /* ... do something with data ... */ - //@ }); - //@ - //@ exec('some_long_running_process', function(code, stdout, stderr) { - //@ console.log('Exit code:', code); - //@ console.log('Program output:', stdout); - //@ console.log('Program stderr:', stderr); - //@ }); - //@ ``` - //@ - //@ Executes the given `command` _synchronously_, unless otherwise specified. When in synchronous - //@ mode, this returns a `ShellString` (compatible with ShellJS v0.6.x, which returns an object - //@ of the form `{ code:..., stdout:... , stderr:... }`). Otherwise, this returns the child process - //@ object, and the `callback` receives the arguments `(code, stdout, stderr)`. - //@ - //@ Not seeing the behavior you want? `exec()` runs everything through `sh` - //@ by default (or `cmd.exe` on Windows), which differs from `bash`. If you - //@ need bash-specific behavior, try out the `{shell: 'path/to/bash'}` option. - function _exec(command, options, callback) { - options = options || {}; - if (!command) common.error('must specify command'); - - var pipe = common.readFromPipe(); - - // Callback is defined instead of options. - if (typeof options === 'function') { - callback = options; - options = { async: true }; - } - - // Callback is defined with options. - if (typeof options === 'object' && typeof callback === 'function') { - options.async = true; - } - - options = common.extend({ - silent: common.config.silent, - async: false, - }, options); - - if (options.async) { - return execAsync(command, options, pipe, callback); - } else { - return execSync(command, options, pipe); - } - } - exec$1 = _exec; - return exec$1; -} - -var ls; -var hasRequiredLs; - -function requireLs () { - if (hasRequiredLs) return ls; - hasRequiredLs = 1; - var path = require$$2; - var fs = require$$1; - var common = requireCommon(); - var glob = requireGlob(); - - var globPatternRecursive = path.sep + '**'; - - common.register('ls', _ls, { - cmdOptions: { - 'R': 'recursive', - 'A': 'all', - 'L': 'link', - 'a': 'all_deprecated', - 'd': 'directory', - 'l': 'long', - }, - }); - - //@ - //@ ### ls([options,] [path, ...]) - //@ ### ls([options,] path_array) - //@ - //@ Available options: - //@ - //@ + `-R`: recursive - //@ + `-A`: all files (include files beginning with `.`, except for `.` and `..`) - //@ + `-L`: follow symlinks - //@ + `-d`: list directories themselves, not their contents - //@ + `-l`: list objects representing each file, each with fields containing `ls - //@ -l` output fields. See - //@ [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) - //@ for more info - //@ - //@ Examples: - //@ - //@ ```javascript - //@ ls('projs/*.js'); - //@ ls('-R', '/users/me', '/tmp'); - //@ ls('-R', ['/users/me', '/tmp']); // same as above - //@ ls('-l', 'file.txt'); // { name: 'file.txt', mode: 33188, nlink: 1, ...} - //@ ``` - //@ - //@ Returns array of files in the given `path`, or files in - //@ the current directory if no `path` is provided. - function _ls(options, paths) { - if (options.all_deprecated) { - // We won't support the -a option as it's hard to image why it's useful - // (it includes '.' and '..' in addition to '.*' files) - // For backwards compatibility we'll dump a deprecated message and proceed as before - common.log('ls: Option -a is deprecated. Use -A instead'); - options.all = true; - } - - if (!paths) { - paths = ['.']; - } else { - paths = [].slice.call(arguments, 1); - } - - var list = []; - - function pushFile(abs, relName, stat) { - if (process.platform === 'win32') { - relName = relName.replace(/\\/g, '/'); - } - if (options.long) { - stat = stat || (options.link ? common.statFollowLinks(abs) : common.statNoFollowLinks(abs)); - list.push(addLsAttributes(relName, stat)); - } else { - // list.push(path.relative(rel || '.', file)); - list.push(relName); - } - } - - paths.forEach(function (p) { - var stat; - - try { - stat = options.link ? common.statFollowLinks(p) : common.statNoFollowLinks(p); - // follow links to directories by default - if (stat.isSymbolicLink()) { - /* istanbul ignore next */ - // workaround for https://github.com/shelljs/shelljs/issues/795 - // codecov seems to have a bug that miscalculate this block as uncovered. - // but according to nyc report this block does get covered. - try { - var _stat = common.statFollowLinks(p); - if (_stat.isDirectory()) { - stat = _stat; - } - } catch (_) {} // bad symlink, treat it like a file - } - } catch (e) { - common.error('no such file or directory: ' + p, 2, { continue: true }); - return; - } - - // If the stat succeeded - if (stat.isDirectory() && !options.directory) { - if (options.recursive) { - // use glob, because it's simple - glob.sync(p + globPatternRecursive, { dot: options.all, follow: options.link }) - .forEach(function (item) { - // Glob pattern returns the directory itself and needs to be filtered out. - if (path.relative(p, item)) { - pushFile(item, path.relative(p, item)); - } - }); - } else if (options.all) { - // use fs.readdirSync, because it's fast - fs.readdirSync(p).forEach(function (item) { - pushFile(path.join(p, item), item); - }); - } else { - // use fs.readdirSync and then filter out secret files - fs.readdirSync(p).forEach(function (item) { - if (item[0] !== '.') { - pushFile(path.join(p, item), item); - } - }); - } - } else { - pushFile(p, p, stat); - } - }); - - // Add methods, to make this more compatible with ShellStrings - return list; - } - - function addLsAttributes(pathName, stats) { - // Note: this object will contain more information than .toString() returns - stats.name = pathName; - stats.toString = function () { - // Return a string resembling unix's `ls -l` format - return [this.mode, this.nlink, this.uid, this.gid, this.size, this.mtime, this.name].join(' '); - }; - return stats; - } - - ls = _ls; - return ls; -} - -var find; -var hasRequiredFind; - -function requireFind () { - if (hasRequiredFind) return find; - hasRequiredFind = 1; - var path = require$$2; - var common = requireCommon(); - var _ls = requireLs(); - - common.register('find', _find, {}); - - //@ - //@ ### find(path [, path ...]) - //@ ### find(path_array) - //@ - //@ Examples: - //@ - //@ ```javascript - //@ find('src', 'lib'); - //@ find(['src', 'lib']); // same as above - //@ find('.').filter(function(file) { return file.match(/\.js$/); }); - //@ ``` - //@ - //@ Returns array of all files (however deep) in the given paths. - //@ - //@ The main difference from `ls('-R', path)` is that the resulting file names - //@ include the base directories (e.g., `lib/resources/file1` instead of just `file1`). - function _find(options, paths) { - if (!paths) { - common.error('no path specified'); - } else if (typeof paths === 'string') { - paths = [].slice.call(arguments, 1); - } - - var list = []; - - function pushFile(file) { - if (process.platform === 'win32') { - file = file.replace(/\\/g, '/'); - } - list.push(file); - } - - // why not simply do `ls('-R', paths)`? because the output wouldn't give the base dirs - // to get the base dir in the output, we need instead `ls('-R', 'dir/*')` for every directory - - paths.forEach(function (file) { - var stat; - try { - stat = common.statFollowLinks(file); - } catch (e) { - common.error('no such file or directory: ' + file); - } - - pushFile(file); - - if (stat.isDirectory()) { - _ls({ recursive: true, all: true }, file).forEach(function (subfile) { - pushFile(path.join(file, subfile)); - }); - } - }); - - return list; - } - find = _find; - return find; -} - -var grep; -var hasRequiredGrep; - -function requireGrep () { - if (hasRequiredGrep) return grep; - hasRequiredGrep = 1; - var common = requireCommon(); - var fs = require$$1; - - common.register('grep', _grep, { - globStart: 2, // don't glob-expand the regex - canReceivePipe: true, - cmdOptions: { - 'v': 'inverse', - 'l': 'nameOnly', - 'i': 'ignoreCase', - }, - }); - - //@ - //@ ### grep([options,] regex_filter, file [, file ...]) - //@ ### grep([options,] regex_filter, file_array) - //@ - //@ Available options: - //@ - //@ + `-v`: Invert `regex_filter` (only print non-matching lines). - //@ + `-l`: Print only filenames of matching files. - //@ + `-i`: Ignore case. - //@ - //@ Examples: - //@ - //@ ```javascript - //@ grep('-v', 'GLOBAL_VARIABLE', '*.js'); - //@ grep('GLOBAL_VARIABLE', '*.js'); - //@ ``` - //@ - //@ Reads input string from given files and returns a string containing all lines of the - //@ file that match the given `regex_filter`. - function _grep(options, regex, files) { - // Check if this is coming from a pipe - var pipe = common.readFromPipe(); - - if (!files && !pipe) common.error('no paths given', 2); - - files = [].slice.call(arguments, 2); - - if (pipe) { - files.unshift('-'); - } - - var grep = []; - if (options.ignoreCase) { - regex = new RegExp(regex, 'i'); - } - files.forEach(function (file) { - if (!fs.existsSync(file) && file !== '-') { - common.error('no such file or directory: ' + file, 2, { continue: true }); - return; - } - - var contents = file === '-' ? pipe : fs.readFileSync(file, 'utf8'); - if (options.nameOnly) { - if (contents.match(regex)) { - grep.push(file); - } - } else { - var lines = contents.split('\n'); - lines.forEach(function (line) { - var matched = line.match(regex); - if ((options.inverse && !matched) || (!options.inverse && matched)) { - grep.push(line); - } - }); - } - }); - - return grep.join('\n') + '\n'; - } - grep = _grep; - return grep; -} - -var head; -var hasRequiredHead; - -function requireHead () { - if (hasRequiredHead) return head; - hasRequiredHead = 1; - var common = requireCommon(); - var fs = require$$1; - - common.register('head', _head, { - canReceivePipe: true, - cmdOptions: { - 'n': 'numLines', - }, - }); - - // Reads |numLines| lines or the entire file, whichever is less. - function readSomeLines(file, numLines) { - var buf = common.buffer(); - var bufLength = buf.length; - var bytesRead = bufLength; - var pos = 0; - - var fdr = fs.openSync(file, 'r'); - var numLinesRead = 0; - var ret = ''; - while (bytesRead === bufLength && numLinesRead < numLines) { - bytesRead = fs.readSync(fdr, buf, 0, bufLength, pos); - var bufStr = buf.toString('utf8', 0, bytesRead); - numLinesRead += bufStr.split('\n').length - 1; - ret += bufStr; - pos += bytesRead; - } - - fs.closeSync(fdr); - return ret; - } - - //@ - //@ ### head([{'-n': \},] file [, file ...]) - //@ ### head([{'-n': \},] file_array) - //@ - //@ Available options: - //@ - //@ + `-n `: Show the first `` lines of the files - //@ - //@ Examples: - //@ - //@ ```javascript - //@ var str = head({'-n': 1}, 'file*.txt'); - //@ var str = head('file1', 'file2'); - //@ var str = head(['file1', 'file2']); // same as above - //@ ``` - //@ - //@ Read the start of a file. - function _head(options, files) { - var head = []; - var pipe = common.readFromPipe(); - - if (!files && !pipe) common.error('no paths given'); - - var idx = 1; - if (options.numLines === true) { - idx = 2; - options.numLines = Number(arguments[1]); - } else if (options.numLines === false) { - options.numLines = 10; - } - files = [].slice.call(arguments, idx); - - if (pipe) { - files.unshift('-'); - } - - var shouldAppendNewline = false; - files.forEach(function (file) { - if (file !== '-') { - if (!fs.existsSync(file)) { - common.error('no such file or directory: ' + file, { continue: true }); - return; - } else if (common.statFollowLinks(file).isDirectory()) { - common.error("error reading '" + file + "': Is a directory", { - continue: true, - }); - return; - } - } - - var contents; - if (file === '-') { - contents = pipe; - } else if (options.numLines < 0) { - contents = fs.readFileSync(file, 'utf8'); - } else { - contents = readSomeLines(file, options.numLines); - } - - var lines = contents.split('\n'); - var hasTrailingNewline = (lines[lines.length - 1] === ''); - if (hasTrailingNewline) { - lines.pop(); - } - shouldAppendNewline = (hasTrailingNewline || options.numLines < lines.length); - - head = head.concat(lines.slice(0, options.numLines)); - }); - - if (shouldAppendNewline) { - head.push(''); // to add a trailing newline once we join - } - return head.join('\n'); - } - head = _head; - return head; -} - -var ln; -var hasRequiredLn; - -function requireLn () { - if (hasRequiredLn) return ln; - hasRequiredLn = 1; - var fs = require$$1; - var path = require$$2; - var common = requireCommon(); - - common.register('ln', _ln, { - cmdOptions: { - 's': 'symlink', - 'f': 'force', - }, - }); - - //@ - //@ ### ln([options,] source, dest) - //@ - //@ Available options: - //@ - //@ + `-s`: symlink - //@ + `-f`: force - //@ - //@ Examples: - //@ - //@ ```javascript - //@ ln('file', 'newlink'); - //@ ln('-sf', 'file', 'existing'); - //@ ``` - //@ - //@ Links `source` to `dest`. Use `-f` to force the link, should `dest` already exist. - function _ln(options, source, dest) { - if (!source || !dest) { - common.error('Missing and/or '); - } - - source = String(source); - var sourcePath = path.normalize(source).replace(RegExp(path.sep + '$'), ''); - var isAbsolute = (path.resolve(source) === sourcePath); - dest = path.resolve(process.cwd(), String(dest)); - - if (fs.existsSync(dest)) { - if (!options.force) { - common.error('Destination file exists', { continue: true }); - } - - fs.unlinkSync(dest); - } - - if (options.symlink) { - var isWindows = process.platform === 'win32'; - var linkType = isWindows ? 'file' : null; - var resolvedSourcePath = isAbsolute ? sourcePath : path.resolve(process.cwd(), path.dirname(dest), source); - if (!fs.existsSync(resolvedSourcePath)) { - common.error('Source file does not exist', { continue: true }); - } else if (isWindows && common.statFollowLinks(resolvedSourcePath).isDirectory()) { - linkType = 'junction'; - } - - try { - fs.symlinkSync(linkType === 'junction' ? resolvedSourcePath : source, dest, linkType); - } catch (err) { - common.error(err.message); - } - } else { - if (!fs.existsSync(source)) { - common.error('Source file does not exist', { continue: true }); - } - try { - fs.linkSync(source, dest); - } catch (err) { - common.error(err.message); - } - } - return ''; - } - ln = _ln; - return ln; -} - -var mkdir; -var hasRequiredMkdir; - -function requireMkdir () { - if (hasRequiredMkdir) return mkdir; - hasRequiredMkdir = 1; - var common = requireCommon(); - var fs = require$$1; - var path = require$$2; - - common.register('mkdir', _mkdir, { - cmdOptions: { - 'p': 'fullpath', - }, - }); - - // Recursively creates `dir` - function mkdirSyncRecursive(dir) { - var baseDir = path.dirname(dir); - - // Prevents some potential problems arising from malformed UNCs or - // insufficient permissions. - /* istanbul ignore next */ - if (baseDir === dir) { - common.error('dirname() failed: [' + dir + ']'); - } - - // Base dir exists, no recursion necessary - if (fs.existsSync(baseDir)) { - fs.mkdirSync(dir, parseInt('0777', 8)); - return; - } - - // Base dir does not exist, go recursive - mkdirSyncRecursive(baseDir); - - // Base dir created, can create dir - fs.mkdirSync(dir, parseInt('0777', 8)); - } - - //@ - //@ ### mkdir([options,] dir [, dir ...]) - //@ ### mkdir([options,] dir_array) - //@ - //@ Available options: - //@ - //@ + `-p`: full path (and create intermediate directories, if necessary) - //@ - //@ Examples: - //@ - //@ ```javascript - //@ mkdir('-p', '/tmp/a/b/c/d', '/tmp/e/f/g'); - //@ mkdir('-p', ['/tmp/a/b/c/d', '/tmp/e/f/g']); // same as above - //@ ``` - //@ - //@ Creates directories. - function _mkdir(options, dirs) { - if (!dirs) common.error('no paths given'); - - if (typeof dirs === 'string') { - dirs = [].slice.call(arguments, 1); - } - // if it's array leave it as it is - - dirs.forEach(function (dir) { - try { - var stat = common.statNoFollowLinks(dir); - if (!options.fullpath) { - common.error('path already exists: ' + dir, { continue: true }); - } else if (stat.isFile()) { - common.error('cannot create directory ' + dir + ': File exists', { continue: true }); - } - return; // skip dir - } catch (e) { - // do nothing - } - - // Base dir does not exist, and no -p option given - var baseDir = path.dirname(dir); - if (!fs.existsSync(baseDir) && !options.fullpath) { - common.error('no such file or directory: ' + baseDir, { continue: true }); - return; // skip dir - } - - try { - if (options.fullpath) { - mkdirSyncRecursive(path.resolve(dir)); - } else { - fs.mkdirSync(dir, parseInt('0777', 8)); - } - } catch (e) { - var reason; - if (e.code === 'EACCES') { - reason = 'Permission denied'; - } else if (e.code === 'ENOTDIR' || e.code === 'ENOENT') { - reason = 'Not a directory'; - } else { - /* istanbul ignore next */ - throw e; - } - common.error('cannot create directory ' + dir + ': ' + reason, { continue: true }); - } - }); - return ''; - } // mkdir - mkdir = _mkdir; - return mkdir; -} - -var rm; -var hasRequiredRm; - -function requireRm () { - if (hasRequiredRm) return rm; - hasRequiredRm = 1; - var common = requireCommon(); - var fs = require$$1; - - common.register('rm', _rm, { - cmdOptions: { - 'f': 'force', - 'r': 'recursive', - 'R': 'recursive', - }, - }); - - // Recursively removes 'dir' - // Adapted from https://github.com/ryanmcgrath/wrench-js - // - // Copyright (c) 2010 Ryan McGrath - // Copyright (c) 2012 Artur Adib - // - // Licensed under the MIT License - // http://www.opensource.org/licenses/mit-license.php - function rmdirSyncRecursive(dir, force, fromSymlink) { - var files; - - files = fs.readdirSync(dir); - - // Loop through and delete everything in the sub-tree after checking it - for (var i = 0; i < files.length; i++) { - var file = dir + '/' + files[i]; - var currFile = common.statNoFollowLinks(file); - - if (currFile.isDirectory()) { // Recursive function back to the beginning - rmdirSyncRecursive(file, force); - } else { // Assume it's a file - perhaps a try/catch belongs here? - if (force || isWriteable(file)) { - try { - common.unlinkSync(file); - } catch (e) { - /* istanbul ignore next */ - common.error('could not remove file (code ' + e.code + '): ' + file, { - continue: true, - }); - } - } - } - } - - // if was directory was referenced through a symbolic link, - // the contents should be removed, but not the directory itself - if (fromSymlink) return; - - // Now that we know everything in the sub-tree has been deleted, we can delete the main directory. - // Huzzah for the shopkeep. - - var result; - try { - // Retry on windows, sometimes it takes a little time before all the files in the directory are gone - var start = Date.now(); - - // TODO: replace this with a finite loop - for (;;) { - try { - result = fs.rmdirSync(dir); - if (fs.existsSync(dir)) throw { code: 'EAGAIN' }; - break; - } catch (er) { - /* istanbul ignore next */ - // In addition to error codes, also check if the directory still exists and loop again if true - if (process.platform === 'win32' && (er.code === 'ENOTEMPTY' || er.code === 'EBUSY' || er.code === 'EPERM' || er.code === 'EAGAIN')) { - if (Date.now() - start > 1000) throw er; - } else if (er.code === 'ENOENT') { - // Directory did not exist, deletion was successful - break; - } else { - throw er; - } - } - } - } catch (e) { - common.error('could not remove directory (code ' + e.code + '): ' + dir, { continue: true }); - } - - return result; - } // rmdirSyncRecursive - - // Hack to determine if file has write permissions for current user - // Avoids having to check user, group, etc, but it's probably slow - function isWriteable(file) { - var writePermission = true; - try { - var __fd = fs.openSync(file, 'a'); - fs.closeSync(__fd); - } catch (e) { - writePermission = false; - } - - return writePermission; - } - - function handleFile(file, options) { - if (options.force || isWriteable(file)) { - // -f was passed, or file is writable, so it can be removed - common.unlinkSync(file); - } else { - common.error('permission denied: ' + file, { continue: true }); - } - } - - function handleDirectory(file, options) { - if (options.recursive) { - // -r was passed, so directory can be removed - rmdirSyncRecursive(file, options.force); - } else { - common.error('path is a directory', { continue: true }); - } - } - - function handleSymbolicLink(file, options) { - var stats; - try { - stats = common.statFollowLinks(file); - } catch (e) { - // symlink is broken, so remove the symlink itself - common.unlinkSync(file); - return; - } - - if (stats.isFile()) { - common.unlinkSync(file); - } else if (stats.isDirectory()) { - if (file[file.length - 1] === '/') { - // trailing separator, so remove the contents, not the link - if (options.recursive) { - // -r was passed, so directory can be removed - var fromSymlink = true; - rmdirSyncRecursive(file, options.force, fromSymlink); - } else { - common.error('path is a directory', { continue: true }); - } - } else { - // no trailing separator, so remove the link - common.unlinkSync(file); - } - } - } - - function handleFIFO(file) { - common.unlinkSync(file); - } - - //@ - //@ ### rm([options,] file [, file ...]) - //@ ### rm([options,] file_array) - //@ - //@ Available options: - //@ - //@ + `-f`: force - //@ + `-r, -R`: recursive - //@ - //@ Examples: - //@ - //@ ```javascript - //@ rm('-rf', '/tmp/*'); - //@ rm('some_file.txt', 'another_file.txt'); - //@ rm(['some_file.txt', 'another_file.txt']); // same as above - //@ ``` - //@ - //@ Removes files. - function _rm(options, files) { - if (!files) common.error('no paths given'); - - // Convert to array - files = [].slice.call(arguments, 1); - - files.forEach(function (file) { - var lstats; - try { - var filepath = (file[file.length - 1] === '/') - ? file.slice(0, -1) // remove the '/' so lstatSync can detect symlinks - : file; - lstats = common.statNoFollowLinks(filepath); // test for existence - } catch (e) { - // Path does not exist, no force flag given - if (!options.force) { - common.error('no such file or directory: ' + file, { continue: true }); - } - return; // skip file - } - - // If here, path exists - if (lstats.isFile()) { - handleFile(file, options); - } else if (lstats.isDirectory()) { - handleDirectory(file, options); - } else if (lstats.isSymbolicLink()) { - handleSymbolicLink(file, options); - } else if (lstats.isFIFO()) { - handleFIFO(file); - } - }); // forEach(file) - return ''; - } // rm - rm = _rm; - return rm; -} - -var mv; -var hasRequiredMv; - -function requireMv () { - if (hasRequiredMv) return mv; - hasRequiredMv = 1; - var fs = require$$1; - var path = require$$2; - var common = requireCommon(); - var cp = requireCp(); - var rm = requireRm(); - - common.register('mv', _mv, { - cmdOptions: { - 'f': '!no_force', - 'n': 'no_force', - }, - }); - - // Checks if cureent file was created recently - function checkRecentCreated(sources, index) { - var lookedSource = sources[index]; - return sources.slice(0, index).some(function (src) { - return path.basename(src) === path.basename(lookedSource); - }); - } - - //@ - //@ ### mv([options ,] source [, source ...], dest') - //@ ### mv([options ,] source_array, dest') - //@ - //@ Available options: - //@ - //@ + `-f`: force (default behavior) - //@ + `-n`: no-clobber - //@ - //@ Examples: - //@ - //@ ```javascript - //@ mv('-n', 'file', 'dir/'); - //@ mv('file1', 'file2', 'dir/'); - //@ mv(['file1', 'file2'], 'dir/'); // same as above - //@ ``` - //@ - //@ Moves `source` file(s) to `dest`. - function _mv(options, sources, dest) { - // Get sources, dest - if (arguments.length < 3) { - common.error('missing and/or '); - } else if (arguments.length > 3) { - sources = [].slice.call(arguments, 1, arguments.length - 1); - dest = arguments[arguments.length - 1]; - } else if (typeof sources === 'string') { - sources = [sources]; - } else { - // TODO(nate): figure out if we actually need this line - common.error('invalid arguments'); - } - - var exists = fs.existsSync(dest); - var stats = exists && common.statFollowLinks(dest); - - // Dest is not existing dir, but multiple sources given - if ((!exists || !stats.isDirectory()) && sources.length > 1) { - common.error('dest is not a directory (too many sources)'); - } - - // Dest is an existing file, but no -f given - if (exists && stats.isFile() && options.no_force) { - common.error('dest file already exists: ' + dest); - } - - sources.forEach(function (src, srcIndex) { - if (!fs.existsSync(src)) { - common.error('no such file or directory: ' + src, { continue: true }); - return; // skip file - } - - // If here, src exists - - // When copying to '/path/dir': - // thisDest = '/path/dir/file1' - var thisDest = dest; - if (fs.existsSync(dest) && common.statFollowLinks(dest).isDirectory()) { - thisDest = path.normalize(dest + '/' + path.basename(src)); - } - - var thisDestExists = fs.existsSync(thisDest); - - if (thisDestExists && checkRecentCreated(sources, srcIndex)) { - // cannot overwrite file created recently in current execution, but we want to continue copying other files - if (!options.no_force) { - common.error("will not overwrite just-created '" + thisDest + "' with '" + src + "'", { continue: true }); - } - return; - } - - if (fs.existsSync(thisDest) && options.no_force) { - common.error('dest file already exists: ' + thisDest, { continue: true }); - return; // skip file - } - - if (path.resolve(src) === path.dirname(path.resolve(thisDest))) { - common.error('cannot move to self: ' + src, { continue: true }); - return; // skip file - } - - try { - fs.renameSync(src, thisDest); - } catch (e) { - /* istanbul ignore next */ - if (e.code === 'EXDEV') { - // If we're trying to `mv` to an external partition, we'll actually need - // to perform a copy and then clean up the original file. If either the - // copy or the rm fails with an exception, we should allow this - // exception to pass up to the top level. - cp('-r', src, thisDest); - rm('-rf', src); - } - } - }); // forEach(src) - return ''; - } // mv - mv = _mv; - return mv; -} - -var popd = {}; - -var hasRequiredPopd; - -function requirePopd () { - if (hasRequiredPopd) return popd; - hasRequiredPopd = 1; - // see dirs.js - return popd; -} - -var pushd = {}; - -var hasRequiredPushd; - -function requirePushd () { - if (hasRequiredPushd) return pushd; - hasRequiredPushd = 1; - // see dirs.js - return pushd; -} - -var sed; -var hasRequiredSed; - -function requireSed () { - if (hasRequiredSed) return sed; - hasRequiredSed = 1; - var common = requireCommon(); - var fs = require$$1; - - common.register('sed', _sed, { - globStart: 3, // don't glob-expand regexes - canReceivePipe: true, - cmdOptions: { - 'i': 'inplace', - }, - }); - - //@ - //@ ### sed([options,] search_regex, replacement, file [, file ...]) - //@ ### sed([options,] search_regex, replacement, file_array) - //@ - //@ Available options: - //@ - //@ + `-i`: Replace contents of `file` in-place. _Note that no backups will be created!_ - //@ - //@ Examples: - //@ - //@ ```javascript - //@ sed('-i', 'PROGRAM_VERSION', 'v0.1.3', 'source.js'); - //@ sed(/.*DELETE_THIS_LINE.*\n/, '', 'source.js'); - //@ ``` - //@ - //@ Reads an input string from `file`s, and performs a JavaScript `replace()` on the input - //@ using the given `search_regex` and `replacement` string or function. Returns the new string after replacement. - //@ - //@ Note: - //@ - //@ Like unix `sed`, ShellJS `sed` supports capture groups. Capture groups are specified - //@ using the `$n` syntax: - //@ - //@ ```javascript - //@ sed(/(\w+)\s(\w+)/, '$2, $1', 'file.txt'); - //@ ``` - function _sed(options, regex, replacement, files) { - // Check if this is coming from a pipe - var pipe = common.readFromPipe(); - - if (typeof replacement !== 'string' && typeof replacement !== 'function') { - if (typeof replacement === 'number') { - replacement = replacement.toString(); // fallback - } else { - common.error('invalid replacement string'); - } - } - - // Convert all search strings to RegExp - if (typeof regex === 'string') { - regex = RegExp(regex); - } - - if (!files && !pipe) { - common.error('no files given'); - } - - files = [].slice.call(arguments, 3); - - if (pipe) { - files.unshift('-'); - } - - var sed = []; - files.forEach(function (file) { - if (!fs.existsSync(file) && file !== '-') { - common.error('no such file or directory: ' + file, 2, { continue: true }); - return; - } - - var contents = file === '-' ? pipe : fs.readFileSync(file, 'utf8'); - var lines = contents.split('\n'); - var result = lines.map(function (line) { - return line.replace(regex, replacement); - }).join('\n'); - - sed.push(result); - - if (options.inplace) { - fs.writeFileSync(file, result, 'utf8'); - } - }); - - return sed.join('\n'); - } - sed = _sed; - return sed; -} - -var set; -var hasRequiredSet; - -function requireSet () { - if (hasRequiredSet) return set; - hasRequiredSet = 1; - var common = requireCommon(); - - common.register('set', _set, { - allowGlobbing: false, - wrapOutput: false, - }); - - //@ - //@ ### set(options) - //@ - //@ Available options: - //@ - //@ + `+/-e`: exit upon error (`config.fatal`) - //@ + `+/-v`: verbose: show all commands (`config.verbose`) - //@ + `+/-f`: disable filename expansion (globbing) - //@ - //@ Examples: - //@ - //@ ```javascript - //@ set('-e'); // exit upon first error - //@ set('+e'); // this undoes a "set('-e')" - //@ ``` - //@ - //@ Sets global configuration variables. - function _set(options) { - if (!options) { - var args = [].slice.call(arguments, 0); - if (args.length < 2) common.error('must provide an argument'); - options = args[1]; - } - var negate = (options[0] === '+'); - if (negate) { - options = '-' + options.slice(1); // parseOptions needs a '-' prefix - } - options = common.parseOptions(options, { - 'e': 'fatal', - 'v': 'verbose', - 'f': 'noglob', - }); - - if (negate) { - Object.keys(options).forEach(function (key) { - options[key] = !options[key]; - }); - } - - Object.keys(options).forEach(function (key) { - // Only change the global config if `negate` is false and the option is true - // or if `negate` is true and the option is false (aka negate !== option) - if (negate !== options[key]) { - common.config[key] = options[key]; - } - }); - return; - } - set = _set; - return set; -} - -var sort; -var hasRequiredSort; - -function requireSort () { - if (hasRequiredSort) return sort; - hasRequiredSort = 1; - var common = requireCommon(); - var fs = require$$1; - - common.register('sort', _sort, { - canReceivePipe: true, - cmdOptions: { - 'r': 'reverse', - 'n': 'numerical', - }, - }); - - // parse out the number prefix of a line - function parseNumber(str) { - var match = str.match(/^\s*(\d*)\s*(.*)$/); - return { num: Number(match[1]), value: match[2] }; - } - - // compare two strings case-insensitively, but examine case for strings that are - // case-insensitive equivalent - function unixCmp(a, b) { - var aLower = a.toLowerCase(); - var bLower = b.toLowerCase(); - return (aLower === bLower ? - -1 * a.localeCompare(b) : // unix sort treats case opposite how javascript does - aLower.localeCompare(bLower)); - } - - // compare two strings in the fashion that unix sort's -n option works - function numericalCmp(a, b) { - var objA = parseNumber(a); - var objB = parseNumber(b); - if (objA.hasOwnProperty('num') && objB.hasOwnProperty('num')) { - return ((objA.num !== objB.num) ? - (objA.num - objB.num) : - unixCmp(objA.value, objB.value)); - } else { - return unixCmp(objA.value, objB.value); - } - } - - //@ - //@ ### sort([options,] file [, file ...]) - //@ ### sort([options,] file_array) - //@ - //@ Available options: - //@ - //@ + `-r`: Reverse the results - //@ + `-n`: Compare according to numerical value - //@ - //@ Examples: - //@ - //@ ```javascript - //@ sort('foo.txt', 'bar.txt'); - //@ sort('-r', 'foo.txt'); - //@ ``` - //@ - //@ Return the contents of the `file`s, sorted line-by-line. Sorting multiple - //@ files mixes their content (just as unix `sort` does). - function _sort(options, files) { - // Check if this is coming from a pipe - var pipe = common.readFromPipe(); - - if (!files && !pipe) common.error('no files given'); - - files = [].slice.call(arguments, 1); - - if (pipe) { - files.unshift('-'); - } - - var lines = files.reduce(function (accum, file) { - if (file !== '-') { - if (!fs.existsSync(file)) { - common.error('no such file or directory: ' + file, { continue: true }); - return accum; - } else if (common.statFollowLinks(file).isDirectory()) { - common.error('read failed: ' + file + ': Is a directory', { - continue: true, - }); - return accum; - } - } - - var contents = file === '-' ? pipe : fs.readFileSync(file, 'utf8'); - return accum.concat(contents.trimRight().split('\n')); - }, []); - - var sorted = lines.sort(options.numerical ? numericalCmp : unixCmp); - - if (options.reverse) { - sorted = sorted.reverse(); - } - - return sorted.join('\n') + '\n'; - } - - sort = _sort; - return sort; -} - -var tail; -var hasRequiredTail; - -function requireTail () { - if (hasRequiredTail) return tail; - hasRequiredTail = 1; - var common = requireCommon(); - var fs = require$$1; - - common.register('tail', _tail, { - canReceivePipe: true, - cmdOptions: { - 'n': 'numLines', - }, - }); - - //@ - //@ ### tail([{'-n': \},] file [, file ...]) - //@ ### tail([{'-n': \},] file_array) - //@ - //@ Available options: - //@ - //@ + `-n `: Show the last `` lines of `file`s - //@ - //@ Examples: - //@ - //@ ```javascript - //@ var str = tail({'-n': 1}, 'file*.txt'); - //@ var str = tail('file1', 'file2'); - //@ var str = tail(['file1', 'file2']); // same as above - //@ ``` - //@ - //@ Read the end of a `file`. - function _tail(options, files) { - var tail = []; - var pipe = common.readFromPipe(); - - if (!files && !pipe) common.error('no paths given'); - - var idx = 1; - if (options.numLines === true) { - idx = 2; - options.numLines = Number(arguments[1]); - } else if (options.numLines === false) { - options.numLines = 10; - } - options.numLines = -1 * Math.abs(options.numLines); - files = [].slice.call(arguments, idx); - - if (pipe) { - files.unshift('-'); - } - - var shouldAppendNewline = false; - files.forEach(function (file) { - if (file !== '-') { - if (!fs.existsSync(file)) { - common.error('no such file or directory: ' + file, { continue: true }); - return; - } else if (common.statFollowLinks(file).isDirectory()) { - common.error("error reading '" + file + "': Is a directory", { - continue: true, - }); - return; - } - } - - var contents = file === '-' ? pipe : fs.readFileSync(file, 'utf8'); - - var lines = contents.split('\n'); - if (lines[lines.length - 1] === '') { - lines.pop(); - shouldAppendNewline = true; - } else { - shouldAppendNewline = false; - } - - tail = tail.concat(lines.slice(options.numLines)); - }); - - if (shouldAppendNewline) { - tail.push(''); // to add a trailing newline once we join - } - return tail.join('\n'); - } - tail = _tail; - return tail; -} - -var test; -var hasRequiredTest; - -function requireTest () { - if (hasRequiredTest) return test; - hasRequiredTest = 1; - var common = requireCommon(); - var fs = require$$1; - - common.register('test', _test, { - cmdOptions: { - 'b': 'block', - 'c': 'character', - 'd': 'directory', - 'e': 'exists', - 'f': 'file', - 'L': 'link', - 'p': 'pipe', - 'S': 'socket', - }, - wrapOutput: false, - allowGlobbing: false, - }); - - - //@ - //@ ### test(expression) - //@ - //@ Available expression primaries: - //@ - //@ + `'-b', 'path'`: true if path is a block device - //@ + `'-c', 'path'`: true if path is a character device - //@ + `'-d', 'path'`: true if path is a directory - //@ + `'-e', 'path'`: true if path exists - //@ + `'-f', 'path'`: true if path is a regular file - //@ + `'-L', 'path'`: true if path is a symbolic link - //@ + `'-p', 'path'`: true if path is a pipe (FIFO) - //@ + `'-S', 'path'`: true if path is a socket - //@ - //@ Examples: - //@ - //@ ```javascript - //@ if (test('-d', path)) { /* do something with dir */ }; - //@ if (!test('-f', path)) continue; // skip if it's a regular file - //@ ``` - //@ - //@ Evaluates `expression` using the available primaries and returns corresponding value. - function _test(options, path) { - if (!path) common.error('no path given'); - - var canInterpret = false; - Object.keys(options).forEach(function (key) { - if (options[key] === true) { - canInterpret = true; - } - }); - - if (!canInterpret) common.error('could not interpret expression'); - - if (options.link) { - try { - return common.statNoFollowLinks(path).isSymbolicLink(); - } catch (e) { - return false; - } - } - - if (!fs.existsSync(path)) return false; - - if (options.exists) return true; - - var stats = common.statFollowLinks(path); - - if (options.block) return stats.isBlockDevice(); - - if (options.character) return stats.isCharacterDevice(); - - if (options.directory) return stats.isDirectory(); - - if (options.file) return stats.isFile(); - - /* istanbul ignore next */ - if (options.pipe) return stats.isFIFO(); - - /* istanbul ignore next */ - if (options.socket) return stats.isSocket(); - - /* istanbul ignore next */ - return false; // fallback - } // test - test = _test; - return test; -} - -var to; -var hasRequiredTo; - -function requireTo () { - if (hasRequiredTo) return to; - hasRequiredTo = 1; - var common = requireCommon(); - var fs = require$$1; - var path = require$$2; - - common.register('to', _to, { - pipeOnly: true, - wrapOutput: false, - }); - - //@ - //@ ### ShellString.prototype.to(file) - //@ - //@ Examples: - //@ - //@ ```javascript - //@ cat('input.txt').to('output.txt'); - //@ ``` - //@ - //@ Analogous to the redirection operator `>` in Unix, but works with - //@ `ShellStrings` (such as those returned by `cat`, `grep`, etc.). _Like Unix - //@ redirections, `to()` will overwrite any existing file!_ - function _to(options, file) { - if (!file) common.error('wrong arguments'); - - if (!fs.existsSync(path.dirname(file))) { - common.error('no such file or directory: ' + path.dirname(file)); - } - - try { - fs.writeFileSync(file, this.stdout || this.toString(), 'utf8'); - return this; - } catch (e) { - /* istanbul ignore next */ - common.error('could not write to file (code ' + e.code + '): ' + file, { continue: true }); - } - } - to = _to; - return to; -} - -var toEnd; -var hasRequiredToEnd; - -function requireToEnd () { - if (hasRequiredToEnd) return toEnd; - hasRequiredToEnd = 1; - var common = requireCommon(); - var fs = require$$1; - var path = require$$2; - - common.register('toEnd', _toEnd, { - pipeOnly: true, - wrapOutput: false, - }); - - //@ - //@ ### ShellString.prototype.toEnd(file) - //@ - //@ Examples: - //@ - //@ ```javascript - //@ cat('input.txt').toEnd('output.txt'); - //@ ``` - //@ - //@ Analogous to the redirect-and-append operator `>>` in Unix, but works with - //@ `ShellStrings` (such as those returned by `cat`, `grep`, etc.). - function _toEnd(options, file) { - if (!file) common.error('wrong arguments'); - - if (!fs.existsSync(path.dirname(file))) { - common.error('no such file or directory: ' + path.dirname(file)); - } - - try { - fs.appendFileSync(file, this.stdout || this.toString(), 'utf8'); - return this; - } catch (e) { - /* istanbul ignore next */ - common.error('could not append to file (code ' + e.code + '): ' + file, { continue: true }); - } - } - toEnd = _toEnd; - return toEnd; -} - -var touch; -var hasRequiredTouch; - -function requireTouch () { - if (hasRequiredTouch) return touch; - hasRequiredTouch = 1; - var common = requireCommon(); - var fs = require$$1; - - common.register('touch', _touch, { - cmdOptions: { - 'a': 'atime_only', - 'c': 'no_create', - 'd': 'date', - 'm': 'mtime_only', - 'r': 'reference', - }, - }); - - //@ - //@ ### touch([options,] file [, file ...]) - //@ ### touch([options,] file_array) - //@ - //@ Available options: - //@ - //@ + `-a`: Change only the access time - //@ + `-c`: Do not create any files - //@ + `-m`: Change only the modification time - //@ + `-d DATE`: Parse `DATE` and use it instead of current time - //@ + `-r FILE`: Use `FILE`'s times instead of current time - //@ - //@ Examples: - //@ - //@ ```javascript - //@ touch('source.js'); - //@ touch('-c', '/path/to/some/dir/source.js'); - //@ touch({ '-r': FILE }, '/path/to/some/dir/source.js'); - //@ ``` - //@ - //@ Update the access and modification times of each `FILE` to the current time. - //@ A `FILE` argument that does not exist is created empty, unless `-c` is supplied. - //@ This is a partial implementation of [`touch(1)`](http://linux.die.net/man/1/touch). - function _touch(opts, files) { - if (!files) { - common.error('no files given'); - } else if (typeof files === 'string') { - files = [].slice.call(arguments, 1); - } else { - common.error('file arg should be a string file path or an Array of string file paths'); - } - - files.forEach(function (f) { - touchFile(opts, f); - }); - return ''; - } - - function touchFile(opts, file) { - var stat = tryStatFile(file); - - if (stat && stat.isDirectory()) { - // don't error just exit - return; - } - - // if the file doesn't already exist and the user has specified --no-create then - // this script is finished - if (!stat && opts.no_create) { - return; - } - - // open the file and then close it. this will create it if it doesn't exist but will - // not truncate the file - fs.closeSync(fs.openSync(file, 'a')); - - // - // Set timestamps - // - - // setup some defaults - var now = new Date(); - var mtime = opts.date || now; - var atime = opts.date || now; - - // use reference file - if (opts.reference) { - var refStat = tryStatFile(opts.reference); - if (!refStat) { - common.error('failed to get attributess of ' + opts.reference); - } - mtime = refStat.mtime; - atime = refStat.atime; - } else if (opts.date) { - mtime = opts.date; - atime = opts.date; - } - - if (opts.atime_only && opts.mtime_only) ; else if (opts.atime_only) { - mtime = stat.mtime; - } else if (opts.mtime_only) { - atime = stat.atime; - } - - fs.utimesSync(file, atime, mtime); - } - - touch = _touch; - - function tryStatFile(filePath) { - try { - return common.statFollowLinks(filePath); - } catch (e) { - return null; - } - } - return touch; -} - -var uniq; -var hasRequiredUniq; - -function requireUniq () { - if (hasRequiredUniq) return uniq; - hasRequiredUniq = 1; - var common = requireCommon(); - var fs = require$$1; - - // add c spaces to the left of str - function lpad(c, str) { - var res = '' + str; - if (res.length < c) { - res = Array((c - res.length) + 1).join(' ') + res; - } - return res; - } - - common.register('uniq', _uniq, { - canReceivePipe: true, - cmdOptions: { - 'i': 'ignoreCase', - 'c': 'count', - 'd': 'duplicates', - }, - }); - - //@ - //@ ### uniq([options,] [input, [output]]) - //@ - //@ Available options: - //@ - //@ + `-i`: Ignore case while comparing - //@ + `-c`: Prefix lines by the number of occurrences - //@ + `-d`: Only print duplicate lines, one for each group of identical lines - //@ - //@ Examples: - //@ - //@ ```javascript - //@ uniq('foo.txt'); - //@ uniq('-i', 'foo.txt'); - //@ uniq('-cd', 'foo.txt', 'bar.txt'); - //@ ``` - //@ - //@ Filter adjacent matching lines from `input`. - function _uniq(options, input, output) { - // Check if this is coming from a pipe - var pipe = common.readFromPipe(); - - if (!pipe) { - if (!input) common.error('no input given'); - - if (!fs.existsSync(input)) { - common.error(input + ': No such file or directory'); - } else if (common.statFollowLinks(input).isDirectory()) { - common.error("error reading '" + input + "'"); - } - } - if (output && fs.existsSync(output) && common.statFollowLinks(output).isDirectory()) { - common.error(output + ': Is a directory'); - } - - var lines = (input ? fs.readFileSync(input, 'utf8') : pipe). - trimRight(). - split('\n'); - - var compare = function (a, b) { - return options.ignoreCase ? - a.toLocaleLowerCase().localeCompare(b.toLocaleLowerCase()) : - a.localeCompare(b); - }; - var uniqed = lines.reduceRight(function (res, e) { - // Perform uniq -c on the input - if (res.length === 0) { - return [{ count: 1, ln: e }]; - } else if (compare(res[0].ln, e) === 0) { - return [{ count: res[0].count + 1, ln: e }].concat(res.slice(1)); - } else { - return [{ count: 1, ln: e }].concat(res); - } - }, []).filter(function (obj) { - // Do we want only duplicated objects? - return options.duplicates ? obj.count > 1 : true; - }).map(function (obj) { - // Are we tracking the counts of each line? - return (options.count ? (lpad(7, obj.count) + ' ') : '') + obj.ln; - }).join('\n') + '\n'; - - if (output) { - (new common.ShellString(uniqed)).to(output); - // if uniq writes to output, nothing is passed to the next command in the pipeline (if any) - return ''; - } else { - return uniqed; - } - } - - uniq = _uniq; - return uniq; -} - -var which; -var hasRequiredWhich; - -function requireWhich () { - if (hasRequiredWhich) return which; - hasRequiredWhich = 1; - var common = requireCommon(); - var fs = require$$1; - var path = require$$2; - - common.register('which', _which, { - allowGlobbing: false, - cmdOptions: { - 'a': 'all', - }, - }); - - // XP's system default value for `PATHEXT` system variable, just in case it's not - // set on Windows. - var XP_DEFAULT_PATHEXT = '.com;.exe;.bat;.cmd;.vbs;.vbe;.js;.jse;.wsf;.wsh'; - - // For earlier versions of NodeJS that doesn't have a list of constants (< v6) - var FILE_EXECUTABLE_MODE = 1; - - function isWindowsPlatform() { - return process.platform === 'win32'; - } - - // Cross-platform method for splitting environment `PATH` variables - function splitPath(p) { - return p ? p.split(path.delimiter) : []; - } - - // Tests are running all cases for this func but it stays uncovered by codecov due to unknown reason - /* istanbul ignore next */ - function isExecutable(pathName) { - try { - // TODO(node-support): replace with fs.constants.X_OK once remove support for node < v6 - fs.accessSync(pathName, FILE_EXECUTABLE_MODE); - } catch (err) { - return false; - } - return true; - } - - function checkPath(pathName) { - return fs.existsSync(pathName) && !common.statFollowLinks(pathName).isDirectory() - && (isWindowsPlatform() || isExecutable(pathName)); - } - - //@ - //@ ### which(command) - //@ - //@ Examples: - //@ - //@ ```javascript - //@ var nodeExec = which('node'); - //@ ``` - //@ - //@ Searches for `command` in the system's `PATH`. On Windows, this uses the - //@ `PATHEXT` variable to append the extension if it's not already executable. - //@ Returns string containing the absolute path to `command`. - function _which(options, cmd) { - if (!cmd) common.error('must specify command'); - - var isWindows = isWindowsPlatform(); - var pathArray = splitPath(process.env.PATH); - - var queryMatches = []; - - // No relative/absolute paths provided? - if (cmd.indexOf('/') === -1) { - // Assume that there are no extensions to append to queries (this is the - // case for unix) - var pathExtArray = ['']; - if (isWindows) { - // In case the PATHEXT variable is somehow not set (e.g. - // child_process.spawn with an empty environment), use the XP default. - var pathExtEnv = process.env.PATHEXT || XP_DEFAULT_PATHEXT; - pathExtArray = splitPath(pathExtEnv.toUpperCase()); - } - - // Search for command in PATH - for (var k = 0; k < pathArray.length; k++) { - // already found it - if (queryMatches.length > 0 && !options.all) break; - - var attempt = path.resolve(pathArray[k], cmd); - - if (isWindows) { - attempt = attempt.toUpperCase(); - } - - var match = attempt.match(/\.[^<>:"/\|?*.]+$/); - if (match && pathExtArray.indexOf(match[0]) >= 0) { // this is Windows-only - // The user typed a query with the file extension, like - // `which('node.exe')` - if (checkPath(attempt)) { - queryMatches.push(attempt); - break; - } - } else { // All-platforms - // Cycle through the PATHEXT array, and check each extension - // Note: the array is always [''] on Unix - for (var i = 0; i < pathExtArray.length; i++) { - var ext = pathExtArray[i]; - var newAttempt = attempt + ext; - if (checkPath(newAttempt)) { - queryMatches.push(newAttempt); - break; - } - } - } - } - } else if (checkPath(cmd)) { // a valid absolute or relative path - queryMatches.push(path.resolve(cmd)); - } - - if (queryMatches.length > 0) { - return options.all ? queryMatches : queryMatches[0]; - } - return options.all ? [] : null; - } - which = _which; - return which; -} - -var dynamicModules; - -function getDynamicModules() { - return dynamicModules || (dynamicModules = { - "/node_modules/shelljs/src/cat.js": requireCat, - "/node_modules/shelljs/src/cd.js": requireCd, - "/node_modules/shelljs/src/chmod.js": requireChmod, - "/node_modules/shelljs/src/common.js": requireCommon, - "/node_modules/shelljs/src/cp.js": requireCp, - "/node_modules/shelljs/src/dirs.js": requireDirs, - "/node_modules/shelljs/src/echo.js": requireEcho, - "/node_modules/shelljs/src/error.js": requireError, - "/node_modules/shelljs/src/exec-child.js": requireExecChild, - "/node_modules/shelljs/src/exec.js": requireExec, - "/node_modules/shelljs/src/find.js": requireFind, - "/node_modules/shelljs/src/grep.js": requireGrep, - "/node_modules/shelljs/src/head.js": requireHead, - "/node_modules/shelljs/src/ln.js": requireLn, - "/node_modules/shelljs/src/ls.js": requireLs, - "/node_modules/shelljs/src/mkdir.js": requireMkdir, - "/node_modules/shelljs/src/mv.js": requireMv, - "/node_modules/shelljs/src/popd.js": requirePopd, - "/node_modules/shelljs/src/pushd.js": requirePushd, - "/node_modules/shelljs/src/pwd.js": requirePwd, - "/node_modules/shelljs/src/rm.js": requireRm, - "/node_modules/shelljs/src/sed.js": requireSed, - "/node_modules/shelljs/src/set.js": requireSet, - "/node_modules/shelljs/src/sort.js": requireSort, - "/node_modules/shelljs/src/tail.js": requireTail, - "/node_modules/shelljs/src/tempdir.js": requireTempdir, - "/node_modules/shelljs/src/test.js": requireTest, - "/node_modules/shelljs/src/to.js": requireTo, - "/node_modules/shelljs/src/toEnd.js": requireToEnd, - "/node_modules/shelljs/src/touch.js": requireTouch, - "/node_modules/shelljs/src/uniq.js": requireUniq, - "/node_modules/shelljs/src/which.js": requireWhich - }); -} - -function createCommonjsRequire(originalModuleDir) { - function handleRequire(path) { - var resolvedPath = commonjsResolve(path, originalModuleDir); - if (resolvedPath !== null) { - return getDynamicModules()[resolvedPath](); - } - throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); - } - handleRequire.resolve = function (path) { - var resolvedPath = commonjsResolve(path, originalModuleDir); - if (resolvedPath !== null) { - return resolvedPath; - } - return require.resolve(path); - }; - return handleRequire; -} - -function commonjsResolve (path, originalModuleDir) { - var shouldTryNodeModules = isPossibleNodeModulesPath(path); - path = normalize(path); - var relPath; - if (path[0] === '/') { - originalModuleDir = ''; - } - var modules = getDynamicModules(); - var checkedExtensions = ['', '.js', '.json']; - while (true) { - if (!shouldTryNodeModules) { - relPath = normalize(originalModuleDir + '/' + path); - } else { - relPath = normalize(originalModuleDir + '/node_modules/' + path); - } - - if (relPath.endsWith('/..')) { - break; // Travelled too far up, avoid infinite loop - } - - for (var extensionIndex = 0; extensionIndex < checkedExtensions.length; extensionIndex++) { - var resolvedPath = relPath + checkedExtensions[extensionIndex]; - if (modules[resolvedPath]) { - return resolvedPath; - } - } - if (!shouldTryNodeModules) break; - var nextDir = normalize(originalModuleDir + '/..'); - if (nextDir === originalModuleDir) break; - originalModuleDir = nextDir; - } - return null; -} - -function isPossibleNodeModulesPath (modulePath) { - var c0 = modulePath[0]; - if (c0 === '/' || c0 === '\\') return false; - var c1 = modulePath[1], c2 = modulePath[2]; - if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\')) || - (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\'))) return false; - if (c1 === ':' && (c2 === '/' || c2 === '\\')) return false; - return true; -} - -function normalize (path) { - path = path.replace(/\\/g, '/'); - var parts = path.split('/'); - var slashed = parts[0] === ''; - for (var i = 1; i < parts.length; i++) { - if (parts[i] === '.' || parts[i] === '') { - parts.splice(i--, 1); - } - } - for (var i = 1; i < parts.length; i++) { - if (parts[i] !== '..') continue; - if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') { - parts.splice(--i, 2); - i--; - } - } - path = parts.join('/'); - if (slashed && path[0] !== '/') path = '/' + path; - else if (path.length === 0) path = '.'; - return path; -} - -var shell$2 = {}; - -var commands = [ - 'cat', - 'cd', - 'chmod', - 'cp', - 'dirs', - 'echo', - 'exec', - 'find', - 'grep', - 'head', - 'ln', - 'ls', - 'mkdir', - 'mv', - 'pwd', - 'rm', - 'sed', - 'set', - 'sort', - 'tail', - 'tempdir', - 'test', - 'to', - 'toEnd', - 'touch', - 'uniq', - 'which', -]; - -var hasRequiredShell; - -function requireShell () { - if (hasRequiredShell) return shell$2; - hasRequiredShell = 1; - // - // ShellJS - // Unix shell commands on top of Node's API - // - // Copyright (c) 2012 Artur Adib - // http://github.com/shelljs/shelljs - // - - var common = requireCommon(); - - //@ - //@ All commands run synchronously, unless otherwise stated. - //@ All commands accept standard bash globbing characters (`*`, `?`, etc.), - //@ compatible with the [node `glob` module](https://github.com/isaacs/node-glob). - //@ - //@ For less-commonly used commands and features, please check out our [wiki - //@ page](https://github.com/shelljs/shelljs/wiki). - //@ - - // Include the docs for all the default commands - //@commands - - // Load all default commands - commands.forEach(function (command) { - createCommonjsRequire("/node_modules/shelljs")('./src/' + command); - }); - - //@ - //@ ### exit(code) - //@ - //@ Exits the current process with the given exit `code`. - shell$2.exit = process.exit; - - //@include ./src/error - shell$2.error = requireError(); - - //@include ./src/common - shell$2.ShellString = common.ShellString; - - //@ - //@ ### env['VAR_NAME'] - //@ - //@ Object containing environment variables (both getter and setter). Shortcut - //@ to `process.env`. - shell$2.env = process.env; - - //@ - //@ ### Pipes - //@ - //@ Examples: - //@ - //@ ```javascript - //@ grep('foo', 'file1.txt', 'file2.txt').sed(/o/g, 'a').to('output.txt'); - //@ echo('files with o\'s in the name:\n' + ls().grep('o')); - //@ cat('test.js').exec('node'); // pipe to exec() call - //@ ``` - //@ - //@ Commands can send their output to another command in a pipe-like fashion. - //@ `sed`, `grep`, `cat`, `exec`, `to`, and `toEnd` can appear on the right-hand - //@ side of a pipe. Pipes can be chained. - - //@ - //@ ## Configuration - //@ - - shell$2.config = common.config; - - //@ - //@ ### config.silent - //@ - //@ Example: - //@ - //@ ```javascript - //@ var sh = require('shelljs'); - //@ var silentState = sh.config.silent; // save old silent state - //@ sh.config.silent = true; - //@ /* ... */ - //@ sh.config.silent = silentState; // restore old silent state - //@ ``` - //@ - //@ Suppresses all command output if `true`, except for `echo()` calls. - //@ Default is `false`. - - //@ - //@ ### config.fatal - //@ - //@ Example: - //@ - //@ ```javascript - //@ require('shelljs/global'); - //@ config.fatal = true; // or set('-e'); - //@ cp('this_file_does_not_exist', '/dev/null'); // throws Error here - //@ /* more commands... */ - //@ ``` - //@ - //@ If `true`, the script will throw a Javascript error when any shell.js - //@ command encounters an error. Default is `false`. This is analogous to - //@ Bash's `set -e`. - - //@ - //@ ### config.verbose - //@ - //@ Example: - //@ - //@ ```javascript - //@ config.verbose = true; // or set('-v'); - //@ cd('dir/'); - //@ rm('-rf', 'foo.txt', 'bar.txt'); - //@ exec('echo hello'); - //@ ``` - //@ - //@ Will print each command as follows: - //@ - //@ ``` - //@ cd dir/ - //@ rm -rf foo.txt bar.txt - //@ exec echo hello - //@ ``` - - //@ - //@ ### config.globOptions - //@ - //@ Example: - //@ - //@ ```javascript - //@ config.globOptions = {nodir: true}; - //@ ``` - //@ - //@ Use this value for calls to `glob.sync()` instead of the default options. - - //@ - //@ ### config.reset() - //@ - //@ Example: - //@ - //@ ```javascript - //@ var shell = require('shelljs'); - //@ // Make changes to shell.config, and do stuff... - //@ /* ... */ - //@ shell.config.reset(); // reset to original state - //@ // Do more stuff, but with original settings - //@ /* ... */ - //@ ``` - //@ - //@ Reset `shell.config` to the defaults: - //@ - //@ ```javascript - //@ { - //@ fatal: false, - //@ globOptions: {}, - //@ maxdepth: 255, - //@ noglob: false, - //@ silent: false, - //@ verbose: false, - //@ } - //@ ``` - return shell$2; -} - -/* eslint no-extend-native: 0 */ - -var shell$1 = requireShell(); -var common = requireCommon(); -Object.keys(shell$1).forEach(function (cmd) { - commonjsGlobal[cmd] = shell$1[cmd]; -}); - -var _to = requireTo(); -String.prototype.to = common.wrap('to', _to); - -var _toEnd = requireToEnd(); -String.prototype.toEnd = common.wrap('toEnd', _toEnd); - -commonjsGlobal.config.fatal = true; -commonjsGlobal.target = {}; - -var args = process.argv.slice(2), - targetArgs, - dashesLoc = args.indexOf('--'); - -// split args, everything after -- if only for targets -if (dashesLoc > -1) { - targetArgs = args.slice(dashesLoc + 1, args.length); - args = args.slice(0, dashesLoc); -} - -// This ensures we only execute the script targets after the entire script has -// been evaluated -setTimeout(function() { - var t; - - if (args.length === 1 && args[0] === '--help') { - console.log('Available targets:'); - for (t in commonjsGlobal.target) - console.log(' ' + t); - return; - } - - // Wrap targets to prevent duplicate execution - for (t in commonjsGlobal.target) { - (function(t, oldTarget){ - - // Wrap it - commonjsGlobal.target[t] = function() { - if (!oldTarget.done){ - oldTarget.done = true; - oldTarget.result = oldTarget.apply(oldTarget, arguments); - } - return oldTarget.result; - }; - - })(t, commonjsGlobal.target[t]); - } - - // Execute desired targets - if (args.length > 0) { - args.forEach(function(arg) { - if (arg in commonjsGlobal.target) - commonjsGlobal.target[arg](targetArgs); - else { - console.log('no such target: ' + arg); - } - }); - } else if ('all' in commonjsGlobal.target) { - commonjsGlobal.target.all(targetArgs); - } - -}, 0); - -/** - * @type {import("shelljs")} - */ -const shell = global; -const target = global.target; - -const SOURCES = ["packages", "codemods", "eslint"]; - -const YARN_PATH = shell.which("yarn").stdout; -const NODE_PATH = process.execPath; // `yarn node` is so slow on Windows - -shell.config.verbose = true; - -function print(msg) { - console.log(msg); -} - -function exec(executable, args, cwd, inheritStdio = true) { - print( - `${executable.replaceAll(YARN_PATH, "yarn").replaceAll( - NODE_PATH, - "node" - )} ${args.join(" ")}` - ); - - try { - return execFileSync(executable, args, { - stdio: inheritStdio ? "inherit" : undefined, - cwd: cwd && require$$2.resolve(cwd), - env: process.env, - }); - } catch (error) { - if (inheritStdio && error.status != 0) { - console.error( - new Error( - `\ncommand: ${executable} ${args.join(" ")}\ncode: ${error.status}` - ) - ); - // eslint-disable-next-line no-process-exit - process.exit(error.status); - } - throw error; - } -} - -function yarn(args, cwd, inheritStdio) { - return exec(YARN_PATH, args, cwd, inheritStdio); -} - -function node(args, cwd, inheritStdio) { - return exec(NODE_PATH, args, cwd, inheritStdio); -} - -function env(fun, env) { - const envBak = process.env; - process.env = { ...envBak, ...env }; - fun(); - process.env = envBak; -} - -/** - * CLEAN - */ - -target["clean-all"] = function () { - ["node_modules", "package-lock.json", ".changelog"].forEach(path => { - shell.rm("-rf", path); - }); - - SOURCES.forEach(source => { - shell.rm("-rf", `${source}/*/test/tmp`); - shell.rm("-rf", `${source}/*/package-lock.json`); - }); - - target["clean"](); - target["clean-lib"](); -}; - -target["clean"] = function () { - target["test-clean"](); - - [ - ".npmrc", - "coverage", - "packages/*/npm-debug*", - "node_modules/.cache", - ].forEach(path => { - shell.rm("-rf", path); - }); -}; - -target["test-clean"] = function () { - SOURCES.forEach(source => { - shell.rm("-rf", `${source}/*/test/tmp`); - shell.rm("-rf", `${source}/*/test-fixtures.json`); - }); -}; - -target["clean-lib"] = function () { - SOURCES.forEach(source => { - shell.rm("-rf", `${source}/*/lib`); - }); -}; - -target["clean-runtime-helpers"] = function () { - [ - "packages/babel-runtime/helpers/**/*.js", - "packages/babel-runtime-corejs2/helpers/**/*.js", - "packages/babel-runtime-corejs3/helpers/**/*.js", - "packages/babel-runtime/helpers/**/*.mjs", - "packages/babel-runtime-corejs2/helpers/**/*.mjs", - "packages/babel-runtime-corejs3/helpers/**/*.mjs", - "packages/babel-runtime-corejs2/core-js", - ].forEach(path => { - shell.rm("-rf", path); - }); -}; - -/** - * BUILD - */ - -target["use-cjs"] = function () { - node(["scripts/set-module-type.js", "script"]); - - target["bootstrap"](); -}; - -target["use-esm"] = function () { - node(["scripts/set-module-type.js", "module"]); - - target["bootstrap"](); -}; - -target["bootstrap-only"] = function () { - target["clean-all"](); - - yarn(["install"]); -}; - -target["bootstrap"] = function () { - target["bootstrap-only"](); - - target["generate-tsconfig"](); - target["build"](); -}; - -target["build"] = function () { - target["build-bundle"](); - - if (process.env.BABEL_COVERAGE != "true") { - target["build-standalone"](); - } -}; - -target["build-standalone"] = function () { - yarn(["gulp", "build-babel-standalone"]); -}; - -target["build-bundle"] = function () { - node(["scripts/set-module-type.js"]); - - target["clean"](); - target["clean-lib"](); - - yarn(["gulp", "build"]); - - target["build-flow-typings"](); - target["build-dist"](); -}; - -target["build-no-bundle"] = function () { - node(["scripts/set-module-type.js"]); - - target["clean"](); - target["clean-lib"](); - - env( - () => { - yarn(["gulp", "build-dev"]); - }, - { BABEL_ENV: "development" } - ); - - target["build-flow-typings"](); - target["build-dist"](); -}; - -target["build-flow-typings"] = function () { - writeFileSync( - "packages/babel-types/lib/index.js.flow", - node(["packages/babel-types/scripts/generators/flow.js"], undefined, false) - ); -}; - -target["build-dist"] = function () { - target["build-plugin-transform-runtime-dist"](); -}; - -target["build-plugin-transform-runtime-dist"] = function () { - node(["scripts/build-dist.js"], "packages/babel-plugin-transform-runtime"); -}; - -target["prepublish-build"] = function () { - target["clean-lib"](); - target["clean-runtime-helpers"](); - - env( - () => { - target["build-bundle"](); - }, - { - NODE_ENV: "production", - BABEL_ENV: "production", - STRIP_BABEL_8_FLAG: "true", - } - ); - - env( - () => { - target["prepublish-build-standalone"](); - target["clone-license"](); - target["prepublish-prepare-dts"](); - }, - { - STRIP_BABEL_8_FLAG: "true", - } - ); -}; - -target["prepublish-build-standalone"] = function () { - env( - () => { - target["build-standalone"](); - }, - { - BABEL_ENV: "production", - IS_PUBLISH: "true", - } - ); -}; - -target["prepublish-prepare-dts"] = function () { - target["tscheck"](); - - yarn(["gulp", "bundle-dts"]); - - target["build-typescript-legacy-typings"](); -}; - -target["tscheck"] = function () { - target["generate-tsconfig"](); - - shell.rm("-rf", "dts"); - yarn(["tsc", "-b", "."]); -}; - -target["generate-tsconfig"] = function () { - node(["scripts/generators/tsconfig.js"]); - node(["scripts/generators/archived-libs-typings.js"]); -}; - -target["clone-license"] = function () { - node(["scripts/clone-license.js"]); -}; - -target["build-typescript-legacy-typings"] = function () { - writeFileSync( - "packages/babel-types/lib/index-legacy.d.ts", - node( - ["packages/babel-types/scripts/generators/typescript-legacy.js"], - undefined, - false - ) - ); -}; - -/** - * DEV - */ - -target["lint"] = function () { - env( - () => { - yarn([ - "eslint", - "scripts", - "benchmark", - ...SOURCES, - "*.{js,cjs,mjs,ts}", - "--format", - "codeframe", - "--ext", - ".js,.cjs,.mjs,.ts", - ]); - }, - { - BABEL_ENV: "test", - } - ); -}; - -target["fix"] = function () { - target["fix-json"](); - target["fix-js"](); -}; - -target["fix-js"] = function () { - yarn([ - "eslint", - "scripts", - "benchmark", - ...SOURCES, - "*.{js,cjs,mjs,ts}", - "--format", - "codeframe", - "--ext", - ".js,.cjs,.mjs,.ts", - "--fix", - ]); -}; - -target["fix-json"] = function () { - yarn([ - "prettier", - `{${SOURCES.join(",")}}/*/test/fixtures/**/options.json`, - "--write", - "--loglevel", - "warn", - ]); -}; - -target["watch"] = function () { - target["build-no-bundle"](); - - env( - () => { - yarn(["gulp", "watch"]); - }, - { - BABEL_ENV: "development", - WATCH_SKIP_BUILD: "true", - } - ); -}; - -target["test"] = function () { - target["lint"](); - target["test-only"](); -}; - -target["test-only"] = function (args = []) { - yarn(["jest", ...args]); -}; diff --git a/Makefile.source.mjs b/Makefile.source.mjs index 3ce1a2cc789d..fb3143d0c31d 100644 --- a/Makefile.source.mjs +++ b/Makefile.source.mjs @@ -16,16 +16,15 @@ const NODE_PATH = process.execPath; // `yarn node` is so slow on Windows shell.config.verbose = true; -function print(msg) { - console.log(msg); +function print(...msgs) { + console.log.apply(console, msgs); } function exec(executable, args, cwd, inheritStdio = true) { print( - `${(executable.replaceAll(YARN_PATH), "yarn").replaceAll( - NODE_PATH, - "node" - )} ${args.join(" ")}` + `${executable + .replaceAll(YARN_PATH, "yarn") + .replaceAll(NODE_PATH, "node")} ${args.join(" ")}` ); try { diff --git a/make.cmd b/make.cmd index d5e72cc85c8c..73176a8fa7ff 100644 --- a/make.cmd +++ b/make.cmd @@ -1,2 +1,2 @@ @cd /d "%~dp0" -@yarn node ./Makefile.mjs %* +@yarn node ./Makefile.js %* diff --git a/package.json b/package.json index 1bff9a8c2822..e7ab632b50f3 100644 --- a/package.json +++ b/package.json @@ -44,6 +44,7 @@ "babel-plugin-transform-charcodes": "^0.2.0", "chalk": "^5.0.0", "charcodes": "^0.2.0", + "core-js": "^3.23.4", "eslint": "^8.9.0", "eslint-formatter-codeframe": "^7.32.1", "eslint-import-resolver-node": "^0.3.6", diff --git a/scripts/pack-script.js b/scripts/pack-script.js index a1b879205c60..895d28ac2e45 100644 --- a/scripts/pack-script.js +++ b/scripts/pack-script.js @@ -3,11 +3,12 @@ import path from "path"; import { rollup } from "rollup"; import { nodeResolve } from "@rollup/plugin-node-resolve"; import commonjs from "@rollup/plugin-commonjs"; +import { babel } from "@rollup/plugin-babel"; import { writeFileSync } from "fs"; const root = fileURLToPath(path.dirname(import.meta.url)); -pack("../Makefile.source.mjs", "../Makefile.mjs", [ +pack("../Makefile.source.mjs", "../Makefile.js", [ "node_modules/shelljs/src/*.js", ]); @@ -23,10 +24,26 @@ async function pack(inputPath, outputPath, dynamicRequireTargets) { commonjs({ dynamicRequireTargets: dynamicRequireTargets, }), + babel({ + babelrc: false, + babelHelpers: "bundled", + exclude: ["node_modules/core-js/**"], + parserOpts: { sourceType: "module" }, + presets: [ + [ + "@babel/preset-env", + { + targets: { node: 6 }, + useBuiltIns: "usage", + corejs: "3.23", + }, + ], + ], + }), ], }); const result = await bundle.generate({ - format: "esm", + format: "cjs", }); const output = `/* eslint-disable */ diff --git a/yarn.lock b/yarn.lock index 3d91b87d2c77..494c193dc146 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5860,6 +5860,7 @@ __metadata: babel-plugin-transform-charcodes: ^0.2.0 chalk: ^5.0.0 charcodes: ^0.2.0 + core-js: ^3.23.4 eslint: ^8.9.0 eslint-formatter-codeframe: ^7.32.1 eslint-import-resolver-node: ^0.3.6 @@ -6956,10 +6957,10 @@ __metadata: languageName: node linkType: hard -"core-js@npm:^3.22.1": - version: 3.22.1 - resolution: "core-js@npm:3.22.1" - checksum: 04f5e97b069e8d9137cd72151d8f4e6b0e51e338c1e9fa04da1a582695bb5b789abf96b0b2bb3d716c63ca68c0e67eea6680d8ee0a206e93e97ebba8aaf40e9c +"core-js@npm:^3.22.1, core-js@npm:^3.23.4": + version: 3.23.4 + resolution: "core-js@npm:3.23.4" + checksum: 1317591dbd4a6dc357b68da324dfab52ffecc0193fe577c55bedc058af3ec96a47c7d68dff4dc914badf398ca120c0b58815fca3a162a497abf73166910d834c languageName: node linkType: hard From bfaac76f2e2db5be57cd6bc965b3c430a8d63841 Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Sat, 16 Jul 2022 21:52:57 +0800 Subject: [PATCH 11/12] fix --- Makefile | 2 +- Makefile.js | 1596 ++++++++++++++++++++++--------------------- Makefile.source.mjs | 89 ++- package.json | 2 +- 4 files changed, 869 insertions(+), 820 deletions(-) diff --git a/Makefile b/Makefile index 38501d428df8..c145efc5211a 100644 --- a/Makefile +++ b/Makefile @@ -90,7 +90,7 @@ prepublish-build: $(MAKEJS) prepublish-build prepublish: - $(MAKEJS) prepublish-build + $(MAKEJS) prepublish bootstrap-only: $(MAKEJS) bootstrap-only diff --git a/Makefile.js b/Makefile.js index 232569aaf823..6126c1f89cef 100644 --- a/Makefile.js +++ b/Makefile.js @@ -27,7 +27,7 @@ var check = function (it) { }; // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 -var global$f = +var global$g = // eslint-disable-next-line es-x/no-global-this -- safe check(typeof globalThis == 'object' && globalThis) || check(typeof window == 'object' && window) || @@ -166,7 +166,7 @@ var isObject$d = function (it) { return typeof it == 'object' ? it !== null : isCallable$l(it); }; -var global$e = global$f; +var global$f = global$g; var isCallable$k = isCallable$m; var aFunction = function (argument) { @@ -174,7 +174,7 @@ var aFunction = function (argument) { }; var getBuiltIn$8 = function (namespace, method) { - return arguments.length < 2 ? aFunction(global$e[namespace]) : global$e[namespace] && global$e[namespace][method]; + return arguments.length < 2 ? aFunction(global$f[namespace]) : global$f[namespace] && global$f[namespace][method]; }; var uncurryThis$p = functionUncurryThis; @@ -185,11 +185,11 @@ var getBuiltIn$7 = getBuiltIn$8; var engineUserAgent = getBuiltIn$7('navigator', 'userAgent') || ''; -var global$d = global$f; +var global$e = global$g; var userAgent$2 = engineUserAgent; -var process$1 = global$d.process; -var Deno = global$d.Deno; +var process$1 = global$e.process; +var Deno = global$e.Deno; var versions = process$1 && process$1.versions || Deno && Deno.version; var v8 = versions && versions.v8; var match, version; @@ -298,24 +298,24 @@ var ordinaryToPrimitive$1 = function (input, pref) { var shared$4 = {exports: {}}; -var global$c = global$f; +var global$d = global$g; // eslint-disable-next-line es-x/no-object-defineproperty -- safe var defineProperty$6 = Object.defineProperty; var defineGlobalProperty$3 = function (key, value) { try { - defineProperty$6(global$c, key, { value: value, configurable: true, writable: true }); + defineProperty$6(global$d, key, { value: value, configurable: true, writable: true }); } catch (error) { - global$c[key] = value; + global$d[key] = value; } return value; }; -var global$b = global$f; +var global$c = global$g; var defineGlobalProperty$2 = defineGlobalProperty$3; var SHARED = '__core-js_shared__'; -var store$3 = global$b[SHARED] || defineGlobalProperty$2(SHARED, {}); +var store$3 = global$c[SHARED] || defineGlobalProperty$2(SHARED, {}); var sharedStore = store$3; @@ -363,7 +363,7 @@ var uid$2 = function (key) { return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$b(++id + postfix, 36); }; -var global$a = global$f; +var global$b = global$g; var shared$3 = shared$4.exports; var hasOwn$b = hasOwnProperty_1; var uid$1 = uid$2; @@ -371,7 +371,7 @@ var NATIVE_SYMBOL$1 = nativeSymbol; var USE_SYMBOL_AS_UID = useSymbolAsUid; var WellKnownSymbolsStore = shared$3('wks'); -var Symbol$1 = global$a.Symbol; +var Symbol$1 = global$b.Symbol; var symbolFor = Symbol$1 && Symbol$1['for']; var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid$1; @@ -424,10 +424,10 @@ var toPropertyKey$3 = function (argument) { return isSymbol$1(key) ? key : key + ''; }; -var global$9 = global$f; +var global$a = global$g; var isObject$a = isObject$d; -var document$1 = global$9.document; +var document$1 = global$a.document; // typeof document.createElement is 'object' in old IE var EXISTS$1 = isObject$a(document$1) && isObject$a(document$1.createElement); @@ -586,11 +586,11 @@ if (!isCallable$g(store$1.inspectSource)) { var inspectSource$3 = store$1.inspectSource; -var global$8 = global$f; +var global$9 = global$g; var isCallable$f = isCallable$m; var inspectSource$2 = inspectSource$3; -var WeakMap$1 = global$8.WeakMap; +var WeakMap$1 = global$9.WeakMap; var nativeWeakMap = isCallable$f(WeakMap$1) && /native code/.test(inspectSource$2(WeakMap$1)); @@ -606,7 +606,7 @@ var sharedKey$3 = function (key) { var hiddenKeys$4 = {}; var NATIVE_WEAK_MAP = nativeWeakMap; -var global$7 = global$f; +var global$8 = global$g; var uncurryThis$l = functionUncurryThis; var isObject$8 = isObject$d; var createNonEnumerableProperty$6 = createNonEnumerableProperty$7; @@ -616,8 +616,8 @@ var sharedKey$2 = sharedKey$3; var hiddenKeys$3 = hiddenKeys$4; var OBJECT_ALREADY_INITIALIZED = 'Object already initialized'; -var TypeError$1 = global$7.TypeError; -var WeakMap = global$7.WeakMap; +var TypeError$1 = global$8.TypeError; +var WeakMap = global$8.WeakMap; var set$1, get, has; var enforce = function (it) { @@ -944,7 +944,7 @@ var POLYFILL = isForced$2.POLYFILL = 'P'; var isForced_1 = isForced$2; -var global$6 = global$f; +var global$7 = global$g; var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f; var createNonEnumerableProperty$5 = createNonEnumerableProperty$7; var defineBuiltIn$4 = defineBuiltIn$5; @@ -973,11 +973,11 @@ var _export = function (options, source) { var STATIC = options.stat; var FORCED, target, key, targetProperty, sourceProperty, descriptor; if (GLOBAL) { - target = global$6; + target = global$7; } else if (STATIC) { - target = global$6[TARGET] || defineGlobalProperty(TARGET, {}); + target = global$7[TARGET] || defineGlobalProperty(TARGET, {}); } else { - target = (global$6[TARGET] || {}).prototype; + target = (global$7[TARGET] || {}).prototype; } if (target) for (key in source) { sourceProperty = source[key]; @@ -999,102 +999,28 @@ var _export = function (options, source) { } }; +var defineProperty$4 = objectDefineProperty.f; +var hasOwn$4 = hasOwnProperty_1; var wellKnownSymbol$g = wellKnownSymbol$i; var TO_STRING_TAG$2 = wellKnownSymbol$g('toStringTag'); -var test$2 = {}; - -test$2[TO_STRING_TAG$2] = 'z'; - -var toStringTagSupport = String(test$2) === '[object z]'; - -var TO_STRING_TAG_SUPPORT = toStringTagSupport; -var isCallable$b = isCallable$m; -var classofRaw = classofRaw$1; -var wellKnownSymbol$f = wellKnownSymbol$i; - -var TO_STRING_TAG$1 = wellKnownSymbol$f('toStringTag'); -var $Object$1 = Object; - -// ES3 wrong here -var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments'; - -// fallback for IE11 Script Access Denied error -var tryGet = function (it, key) { - try { - return it[key]; - } catch (error) { /* empty */ } -}; - -// getting tag from ES6+ `Object.prototype.toString` -var classof$6 = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) { - var O, tag, result; - return it === undefined ? 'Undefined' : it === null ? 'Null' - // @@toStringTag case - : typeof (tag = tryGet(O = $Object$1(it), TO_STRING_TAG$1)) == 'string' ? tag - // builtinTag case - : CORRECT_ARGUMENTS ? classofRaw(O) - // ES3 arguments fallback - : (result = classofRaw(O)) == 'Object' && isCallable$b(O.callee) ? 'Arguments' : result; -}; - -var classof$5 = classof$6; - -var $String$1 = String; - -var toString$a = function (argument) { - if (classof$5(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string'); - return $String$1(argument); -}; - -var anObject$8 = anObject$b; -// `RegExp.prototype.flags` getter implementation -// https://tc39.es/ecma262/#sec-get-regexp.prototype.flags -var regexpFlags$1 = function () { - var that = anObject$8(this); - var result = ''; - if (that.hasIndices) result += 'd'; - if (that.global) result += 'g'; - if (that.ignoreCase) result += 'i'; - if (that.multiline) result += 'm'; - if (that.dotAll) result += 's'; - if (that.unicode) result += 'u'; - if (that.unicodeSets) result += 'v'; - if (that.sticky) result += 'y'; - return result; +var setToStringTag$3 = function (target, TAG, STATIC) { + if (target && !STATIC) target = target.prototype; + if (target && !hasOwn$4(target, TO_STRING_TAG$2)) { + defineProperty$4(target, TO_STRING_TAG$2, { configurable: true, value: TAG }); + } }; -var fails$g = fails$p; -var global$5 = global$f; - -// babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError -var $RegExp$2 = global$5.RegExp; - -var UNSUPPORTED_Y$3 = fails$g(function () { - var re = $RegExp$2('a', 'y'); - re.lastIndex = 2; - return re.exec('abcd') != null; -}); - -// UC Browser bug -// https://github.com/zloirock/core-js/issues/1008 -var MISSED_STICKY$1 = UNSUPPORTED_Y$3 || fails$g(function () { - return !$RegExp$2('a', 'y').sticky; -}); +var $$g = _export; +var global$6 = global$g; +var setToStringTag$2 = setToStringTag$3; -var BROKEN_CARET = UNSUPPORTED_Y$3 || fails$g(function () { - // https://bugzilla.mozilla.org/show_bug.cgi?id=773687 - var re = $RegExp$2('^r', 'gy'); - re.lastIndex = 2; - return re.exec('str') != null; -}); +$$g({ global: true }, { Reflect: {} }); -var regexpStickyHelpers = { - BROKEN_CARET: BROKEN_CARET, - MISSED_STICKY: MISSED_STICKY$1, - UNSUPPORTED_Y: UNSUPPORTED_Y$3 -}; +// Reflect[@@toStringTag] property +// https://tc39.es/ecma262/#sec-reflect-@@tostringtag +setToStringTag$2(global$6.Reflect, 'Reflect', true); var objectDefineProperties = {}; @@ -1111,7 +1037,7 @@ var objectKeys$1 = Object.keys || function keys(O) { var DESCRIPTORS$5 = descriptors; var V8_PROTOTYPE_DEFINE_BUG = v8PrototypeDefineBug; var definePropertyModule$2 = objectDefineProperty; -var anObject$7 = anObject$b; +var anObject$8 = anObject$b; var toIndexedObject$2 = toIndexedObject$6; var objectKeys = objectKeys$1; @@ -1119,7 +1045,7 @@ var objectKeys = objectKeys$1; // https://tc39.es/ecma262/#sec-object.defineproperties // eslint-disable-next-line es-x/no-object-defineproperties -- safe objectDefineProperties.f = DESCRIPTORS$5 && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) { - anObject$7(O); + anObject$8(O); var props = toIndexedObject$2(Properties); var keys = objectKeys(Properties); var length = keys.length; @@ -1135,7 +1061,7 @@ var html$1 = getBuiltIn$4('document', 'documentElement'); /* global ActiveXObject -- old IE, WSH */ -var anObject$6 = anObject$b; +var anObject$7 = anObject$b; var definePropertiesModule = objectDefineProperties; var enumBugKeys = enumBugKeys$3; var hiddenKeys = hiddenKeys$4; @@ -1209,7 +1135,7 @@ hiddenKeys[IE_PROTO$1] = true; var objectCreate = Object.create || function create(O, Properties) { var result; if (O !== null) { - EmptyConstructor[PROTOTYPE] = anObject$6(O); + EmptyConstructor[PROTOTYPE] = anObject$7(O); result = new EmptyConstructor(); EmptyConstructor[PROTOTYPE] = null; // add "__proto__" for Object.getPrototypeOf polyfill @@ -1218,135 +1144,543 @@ var objectCreate = Object.create || function create(O, Properties) { return Properties === undefined ? result : definePropertiesModule.f(result, Properties); }; -var fails$f = fails$p; -var global$4 = global$f; +var wellKnownSymbol$f = wellKnownSymbol$i; +var create$2 = objectCreate; +var defineProperty$3 = objectDefineProperty.f; -// babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError -var $RegExp$1 = global$4.RegExp; +var UNSCOPABLES = wellKnownSymbol$f('unscopables'); +var ArrayPrototype = Array.prototype; -var regexpUnsupportedDotAll = fails$f(function () { - var re = $RegExp$1('.', 's'); - return !(re.dotAll && re.exec('\n') && re.flags === 's'); -}); +// Array.prototype[@@unscopables] +// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables +if (ArrayPrototype[UNSCOPABLES] == undefined) { + defineProperty$3(ArrayPrototype, UNSCOPABLES, { + configurable: true, + value: create$2(null) + }); +} -var fails$e = fails$p; -var global$3 = global$f; +// add a key to Array.prototype[@@unscopables] +var addToUnscopables$1 = function (key) { + ArrayPrototype[UNSCOPABLES][key] = true; +}; -// babel-minify and Closure Compiler transpiles RegExp('(?b)', 'g') -> /(?b)/g and it causes SyntaxError -var $RegExp = global$3.RegExp; +var iterators = {}; -var regexpUnsupportedNcg = fails$e(function () { - var re = $RegExp('(?b)', 'g'); - return re.exec('b').groups.a !== 'b' || - 'b'.replace(re, '$c') !== 'bc'; +var fails$g = fails$p; + +var correctPrototypeGetter = !fails$g(function () { + function F() { /* empty */ } + F.prototype.constructor = null; + // eslint-disable-next-line es-x/no-object-getprototypeof -- required for testing + return Object.getPrototypeOf(new F()) !== F.prototype; }); -/* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */ -/* eslint-disable regexp/no-useless-quantifier -- testing */ -var call$a = functionCall; -var uncurryThis$i = functionUncurryThis; -var toString$9 = toString$a; -var regexpFlags = regexpFlags$1; -var stickyHelpers$2 = regexpStickyHelpers; -var shared = shared$4.exports; -var create$2 = objectCreate; -var getInternalState$2 = internalState.get; -var UNSUPPORTED_DOT_ALL$2 = regexpUnsupportedDotAll; -var UNSUPPORTED_NCG$1 = regexpUnsupportedNcg; +var hasOwn$3 = hasOwnProperty_1; +var isCallable$b = isCallable$m; +var toObject$5 = toObject$7; +var sharedKey = sharedKey$3; +var CORRECT_PROTOTYPE_GETTER = correctPrototypeGetter; -var nativeReplace = shared('native-string-replace', String.prototype.replace); -var nativeExec = RegExp.prototype.exec; -var patchedExec = nativeExec; -var charAt$5 = uncurryThis$i(''.charAt); -var indexOf$1 = uncurryThis$i(''.indexOf); -var replace$5 = uncurryThis$i(''.replace); -var stringSlice$6 = uncurryThis$i(''.slice); +var IE_PROTO = sharedKey('IE_PROTO'); +var $Object$1 = Object; +var ObjectPrototype = $Object$1.prototype; -var UPDATES_LAST_INDEX_WRONG = (function () { - var re1 = /a/; - var re2 = /b*/g; - call$a(nativeExec, re1, 'a'); - call$a(nativeExec, re2, 'a'); - return re1.lastIndex !== 0 || re2.lastIndex !== 0; -})(); +// `Object.getPrototypeOf` method +// https://tc39.es/ecma262/#sec-object.getprototypeof +// eslint-disable-next-line es-x/no-object-getprototypeof -- safe +var objectGetPrototypeOf = CORRECT_PROTOTYPE_GETTER ? $Object$1.getPrototypeOf : function (O) { + var object = toObject$5(O); + if (hasOwn$3(object, IE_PROTO)) return object[IE_PROTO]; + var constructor = object.constructor; + if (isCallable$b(constructor) && object instanceof constructor) { + return constructor.prototype; + } return object instanceof $Object$1 ? ObjectPrototype : null; +}; -var UNSUPPORTED_Y$2 = stickyHelpers$2.BROKEN_CARET; +var fails$f = fails$p; +var isCallable$a = isCallable$m; +var getPrototypeOf$1 = objectGetPrototypeOf; +var defineBuiltIn$3 = defineBuiltIn$5; +var wellKnownSymbol$e = wellKnownSymbol$i; -// nonparticipating capturing group, copied from es5-shim's String#split patch. -var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined; +var ITERATOR$1 = wellKnownSymbol$e('iterator'); +var BUGGY_SAFARI_ITERATORS$1 = false; -var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y$2 || UNSUPPORTED_DOT_ALL$2 || UNSUPPORTED_NCG$1; +// `%IteratorPrototype%` object +// https://tc39.es/ecma262/#sec-%iteratorprototype%-object +var IteratorPrototype$2, PrototypeOfArrayIteratorPrototype, arrayIterator; -if (PATCH) { - patchedExec = function exec(string) { - var re = this; - var state = getInternalState$2(re); - var str = toString$9(string); - var raw = state.raw; - var result, reCopy, lastIndex, match, i, object, group; +/* eslint-disable es-x/no-array-prototype-keys -- safe */ +if ([].keys) { + arrayIterator = [].keys(); + // Safari 8 has buggy iterators w/o `next` + if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS$1 = true; + else { + PrototypeOfArrayIteratorPrototype = getPrototypeOf$1(getPrototypeOf$1(arrayIterator)); + if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype$2 = PrototypeOfArrayIteratorPrototype; + } +} - if (raw) { - raw.lastIndex = re.lastIndex; - result = call$a(patchedExec, raw, str); - re.lastIndex = raw.lastIndex; - return result; - } +var NEW_ITERATOR_PROTOTYPE = IteratorPrototype$2 == undefined || fails$f(function () { + var test = {}; + // FF44- legacy iterators case + return IteratorPrototype$2[ITERATOR$1].call(test) !== test; +}); - var groups = state.groups; - var sticky = UNSUPPORTED_Y$2 && re.sticky; - var flags = call$a(regexpFlags, re); - var source = re.source; - var charsAdded = 0; - var strCopy = str; +if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype$2 = {}; - if (sticky) { - flags = replace$5(flags, 'y', ''); - if (indexOf$1(flags, 'g') === -1) { - flags += 'g'; - } +// `%IteratorPrototype%[@@iterator]()` method +// https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator +if (!isCallable$a(IteratorPrototype$2[ITERATOR$1])) { + defineBuiltIn$3(IteratorPrototype$2, ITERATOR$1, function () { + return this; + }); +} - strCopy = stringSlice$6(str, re.lastIndex); - // Support anchored sticky behavior. - if (re.lastIndex > 0 && (!re.multiline || re.multiline && charAt$5(str, re.lastIndex - 1) !== '\n')) { - source = '(?: ' + source + ')'; - strCopy = ' ' + strCopy; - charsAdded++; - } - // ^(? + rx + ) is needed, in combination with some str slicing, to - // simulate the 'y' flag. - reCopy = new RegExp('^(?:' + source + ')', flags); - } +var iteratorsCore = { + IteratorPrototype: IteratorPrototype$2, + BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS$1 +}; - if (NPCG_INCLUDED) { - reCopy = new RegExp('^' + source + '$(?!\\s)', flags); - } - if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex; +var IteratorPrototype$1 = iteratorsCore.IteratorPrototype; +var create$1 = objectCreate; +var createPropertyDescriptor$2 = createPropertyDescriptor$5; +var setToStringTag$1 = setToStringTag$3; +var Iterators$2 = iterators; - match = call$a(nativeExec, sticky ? reCopy : re, strCopy); +var returnThis$1 = function () { return this; }; - if (sticky) { - if (match) { - match.input = stringSlice$6(match.input, charsAdded); - match[0] = stringSlice$6(match[0], charsAdded); - match.index = re.lastIndex; - re.lastIndex += match[0].length; - } else re.lastIndex = 0; - } else if (UPDATES_LAST_INDEX_WRONG && match) { - re.lastIndex = re.global ? match.index + match[0].length : lastIndex; - } - if (NPCG_INCLUDED && match && match.length > 1) { - // Fix browsers whose `exec` methods don't consistently return `undefined` - // for NPCG, like IE8. NOTE: This doesn't work for /(.?)?/ - call$a(nativeReplace, match[0], reCopy, function () { - for (i = 1; i < arguments.length - 2; i++) { - if (arguments[i] === undefined) match[i] = undefined; - } - }); - } +var createIteratorConstructor$1 = function (IteratorConstructor, NAME, next, ENUMERABLE_NEXT) { + var TO_STRING_TAG = NAME + ' Iterator'; + IteratorConstructor.prototype = create$1(IteratorPrototype$1, { next: createPropertyDescriptor$2(+!ENUMERABLE_NEXT, next) }); + setToStringTag$1(IteratorConstructor, TO_STRING_TAG, false); + Iterators$2[TO_STRING_TAG] = returnThis$1; + return IteratorConstructor; +}; - if (match && groups) { - match.groups = object = create$2(null); - for (i = 0; i < groups.length; i++) { +var isCallable$9 = isCallable$m; + +var $String$1 = String; +var $TypeError$7 = TypeError; + +var aPossiblePrototype$1 = function (argument) { + if (typeof argument == 'object' || isCallable$9(argument)) return argument; + throw $TypeError$7("Can't set " + $String$1(argument) + ' as a prototype'); +}; + +/* eslint-disable no-proto -- safe */ + +var uncurryThis$i = functionUncurryThis; +var anObject$6 = anObject$b; +var aPossiblePrototype = aPossiblePrototype$1; + +// `Object.setPrototypeOf` method +// https://tc39.es/ecma262/#sec-object.setprototypeof +// Works with __proto__ only. Old v8 can't work with null proto objects. +// eslint-disable-next-line es-x/no-object-setprototypeof -- safe +var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () { + var CORRECT_SETTER = false; + var test = {}; + var setter; + try { + // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe + setter = uncurryThis$i(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set); + setter(test, []); + CORRECT_SETTER = test instanceof Array; + } catch (error) { /* empty */ } + return function setPrototypeOf(O, proto) { + anObject$6(O); + aPossiblePrototype(proto); + if (CORRECT_SETTER) setter(O, proto); + else O.__proto__ = proto; + return O; + }; +}() : undefined); + +var $$f = _export; +var call$a = functionCall; +var FunctionName = functionName; +var isCallable$8 = isCallable$m; +var createIteratorConstructor = createIteratorConstructor$1; +var getPrototypeOf = objectGetPrototypeOf; +var setPrototypeOf$2 = objectSetPrototypeOf; +var setToStringTag = setToStringTag$3; +var createNonEnumerableProperty$4 = createNonEnumerableProperty$7; +var defineBuiltIn$2 = defineBuiltIn$5; +var wellKnownSymbol$d = wellKnownSymbol$i; +var Iterators$1 = iterators; +var IteratorsCore = iteratorsCore; + +var PROPER_FUNCTION_NAME$1 = FunctionName.PROPER; +var CONFIGURABLE_FUNCTION_NAME = FunctionName.CONFIGURABLE; +var IteratorPrototype = IteratorsCore.IteratorPrototype; +var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS; +var ITERATOR = wellKnownSymbol$d('iterator'); +var KEYS = 'keys'; +var VALUES = 'values'; +var ENTRIES = 'entries'; + +var returnThis = function () { return this; }; + +var defineIterator$1 = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) { + createIteratorConstructor(IteratorConstructor, NAME, next); + + var getIterationMethod = function (KIND) { + if (KIND === DEFAULT && defaultIterator) return defaultIterator; + if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype) return IterablePrototype[KIND]; + switch (KIND) { + case KEYS: return function keys() { return new IteratorConstructor(this, KIND); }; + case VALUES: return function values() { return new IteratorConstructor(this, KIND); }; + case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); }; + } return function () { return new IteratorConstructor(this); }; + }; + + var TO_STRING_TAG = NAME + ' Iterator'; + var INCORRECT_VALUES_NAME = false; + var IterablePrototype = Iterable.prototype; + var nativeIterator = IterablePrototype[ITERATOR] + || IterablePrototype['@@iterator'] + || DEFAULT && IterablePrototype[DEFAULT]; + var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT); + var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator; + var CurrentIteratorPrototype, methods, KEY; + + // fix native + if (anyNativeIterator) { + CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable())); + if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) { + if (getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) { + if (setPrototypeOf$2) { + setPrototypeOf$2(CurrentIteratorPrototype, IteratorPrototype); + } else if (!isCallable$8(CurrentIteratorPrototype[ITERATOR])) { + defineBuiltIn$2(CurrentIteratorPrototype, ITERATOR, returnThis); + } + } + // Set @@toStringTag to native iterators + setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true); + } + } + + // fix Array.prototype.{ values, @@iterator }.name in V8 / FF + if (PROPER_FUNCTION_NAME$1 && DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) { + if (CONFIGURABLE_FUNCTION_NAME) { + createNonEnumerableProperty$4(IterablePrototype, 'name', VALUES); + } else { + INCORRECT_VALUES_NAME = true; + defaultIterator = function values() { return call$a(nativeIterator, this); }; + } + } + + // export additional methods + if (DEFAULT) { + methods = { + values: getIterationMethod(VALUES), + keys: IS_SET ? defaultIterator : getIterationMethod(KEYS), + entries: getIterationMethod(ENTRIES) + }; + if (FORCED) for (KEY in methods) { + if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) { + defineBuiltIn$2(IterablePrototype, KEY, methods[KEY]); + } + } else $$f({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods); + } + + // define iterator + if (IterablePrototype[ITERATOR] !== defaultIterator) { + defineBuiltIn$2(IterablePrototype, ITERATOR, defaultIterator, { name: DEFAULT }); + } + Iterators$1[NAME] = defaultIterator; + + return methods; +}; + +var toIndexedObject$1 = toIndexedObject$6; +var addToUnscopables = addToUnscopables$1; +var Iterators = iterators; +var InternalStateModule = internalState; +var defineProperty$2 = objectDefineProperty.f; +var defineIterator = defineIterator$1; +var DESCRIPTORS$4 = descriptors; + +var ARRAY_ITERATOR = 'Array Iterator'; +var setInternalState = InternalStateModule.set; +var getInternalState$2 = InternalStateModule.getterFor(ARRAY_ITERATOR); + +// `Array.prototype.entries` method +// https://tc39.es/ecma262/#sec-array.prototype.entries +// `Array.prototype.keys` method +// https://tc39.es/ecma262/#sec-array.prototype.keys +// `Array.prototype.values` method +// https://tc39.es/ecma262/#sec-array.prototype.values +// `Array.prototype[@@iterator]` method +// https://tc39.es/ecma262/#sec-array.prototype-@@iterator +// `CreateArrayIterator` internal method +// https://tc39.es/ecma262/#sec-createarrayiterator +defineIterator(Array, 'Array', function (iterated, kind) { + setInternalState(this, { + type: ARRAY_ITERATOR, + target: toIndexedObject$1(iterated), // target + index: 0, // next index + kind: kind // kind + }); +// `%ArrayIteratorPrototype%.next` method +// https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next +}, function () { + var state = getInternalState$2(this); + var target = state.target; + var kind = state.kind; + var index = state.index++; + if (!target || index >= target.length) { + state.target = undefined; + return { value: undefined, done: true }; + } + if (kind == 'keys') return { value: index, done: false }; + if (kind == 'values') return { value: target[index], done: false }; + return { value: [index, target[index]], done: false }; +}, 'values'); + +// argumentsList[@@iterator] is %ArrayProto_values% +// https://tc39.es/ecma262/#sec-createunmappedargumentsobject +// https://tc39.es/ecma262/#sec-createmappedargumentsobject +var values = Iterators.Arguments = Iterators.Array; + +// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables +addToUnscopables('keys'); +addToUnscopables('values'); +addToUnscopables('entries'); + +// V8 ~ Chrome 45- bug +if (DESCRIPTORS$4 && values.name !== 'values') try { + defineProperty$2(values, 'name', { value: 'values' }); +} catch (error) { /* empty */ } + +var wellKnownSymbol$c = wellKnownSymbol$i; + +var TO_STRING_TAG$1 = wellKnownSymbol$c('toStringTag'); +var test$2 = {}; + +test$2[TO_STRING_TAG$1] = 'z'; + +var toStringTagSupport = String(test$2) === '[object z]'; + +var TO_STRING_TAG_SUPPORT = toStringTagSupport; +var isCallable$7 = isCallable$m; +var classofRaw = classofRaw$1; +var wellKnownSymbol$b = wellKnownSymbol$i; + +var TO_STRING_TAG = wellKnownSymbol$b('toStringTag'); +var $Object = Object; + +// ES3 wrong here +var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments'; + +// fallback for IE11 Script Access Denied error +var tryGet = function (it, key) { + try { + return it[key]; + } catch (error) { /* empty */ } +}; + +// getting tag from ES6+ `Object.prototype.toString` +var classof$6 = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) { + var O, tag, result; + return it === undefined ? 'Undefined' : it === null ? 'Null' + // @@toStringTag case + : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == 'string' ? tag + // builtinTag case + : CORRECT_ARGUMENTS ? classofRaw(O) + // ES3 arguments fallback + : (result = classofRaw(O)) == 'Object' && isCallable$7(O.callee) ? 'Arguments' : result; +}; + +var classof$5 = classof$6; + +var $String = String; + +var toString$a = function (argument) { + if (classof$5(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string'); + return $String(argument); +}; + +var anObject$5 = anObject$b; + +// `RegExp.prototype.flags` getter implementation +// https://tc39.es/ecma262/#sec-get-regexp.prototype.flags +var regexpFlags$1 = function () { + var that = anObject$5(this); + var result = ''; + if (that.hasIndices) result += 'd'; + if (that.global) result += 'g'; + if (that.ignoreCase) result += 'i'; + if (that.multiline) result += 'm'; + if (that.dotAll) result += 's'; + if (that.unicode) result += 'u'; + if (that.unicodeSets) result += 'v'; + if (that.sticky) result += 'y'; + return result; +}; + +var fails$e = fails$p; +var global$5 = global$g; + +// babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError +var $RegExp$2 = global$5.RegExp; + +var UNSUPPORTED_Y$3 = fails$e(function () { + var re = $RegExp$2('a', 'y'); + re.lastIndex = 2; + return re.exec('abcd') != null; +}); + +// UC Browser bug +// https://github.com/zloirock/core-js/issues/1008 +var MISSED_STICKY$1 = UNSUPPORTED_Y$3 || fails$e(function () { + return !$RegExp$2('a', 'y').sticky; +}); + +var BROKEN_CARET = UNSUPPORTED_Y$3 || fails$e(function () { + // https://bugzilla.mozilla.org/show_bug.cgi?id=773687 + var re = $RegExp$2('^r', 'gy'); + re.lastIndex = 2; + return re.exec('str') != null; +}); + +var regexpStickyHelpers = { + BROKEN_CARET: BROKEN_CARET, + MISSED_STICKY: MISSED_STICKY$1, + UNSUPPORTED_Y: UNSUPPORTED_Y$3 +}; + +var fails$d = fails$p; +var global$4 = global$g; + +// babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError +var $RegExp$1 = global$4.RegExp; + +var regexpUnsupportedDotAll = fails$d(function () { + var re = $RegExp$1('.', 's'); + return !(re.dotAll && re.exec('\n') && re.flags === 's'); +}); + +var fails$c = fails$p; +var global$3 = global$g; + +// babel-minify and Closure Compiler transpiles RegExp('(?b)', 'g') -> /(?b)/g and it causes SyntaxError +var $RegExp = global$3.RegExp; + +var regexpUnsupportedNcg = fails$c(function () { + var re = $RegExp('(?b)', 'g'); + return re.exec('b').groups.a !== 'b' || + 'b'.replace(re, '$c') !== 'bc'; +}); + +/* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */ +/* eslint-disable regexp/no-useless-quantifier -- testing */ +var call$9 = functionCall; +var uncurryThis$h = functionUncurryThis; +var toString$9 = toString$a; +var regexpFlags = regexpFlags$1; +var stickyHelpers$2 = regexpStickyHelpers; +var shared = shared$4.exports; +var create = objectCreate; +var getInternalState$1 = internalState.get; +var UNSUPPORTED_DOT_ALL$2 = regexpUnsupportedDotAll; +var UNSUPPORTED_NCG$1 = regexpUnsupportedNcg; + +var nativeReplace = shared('native-string-replace', String.prototype.replace); +var nativeExec = RegExp.prototype.exec; +var patchedExec = nativeExec; +var charAt$5 = uncurryThis$h(''.charAt); +var indexOf$1 = uncurryThis$h(''.indexOf); +var replace$5 = uncurryThis$h(''.replace); +var stringSlice$6 = uncurryThis$h(''.slice); + +var UPDATES_LAST_INDEX_WRONG = (function () { + var re1 = /a/; + var re2 = /b*/g; + call$9(nativeExec, re1, 'a'); + call$9(nativeExec, re2, 'a'); + return re1.lastIndex !== 0 || re2.lastIndex !== 0; +})(); + +var UNSUPPORTED_Y$2 = stickyHelpers$2.BROKEN_CARET; + +// nonparticipating capturing group, copied from es5-shim's String#split patch. +var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined; + +var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y$2 || UNSUPPORTED_DOT_ALL$2 || UNSUPPORTED_NCG$1; + +if (PATCH) { + patchedExec = function exec(string) { + var re = this; + var state = getInternalState$1(re); + var str = toString$9(string); + var raw = state.raw; + var result, reCopy, lastIndex, match, i, object, group; + + if (raw) { + raw.lastIndex = re.lastIndex; + result = call$9(patchedExec, raw, str); + re.lastIndex = raw.lastIndex; + return result; + } + + var groups = state.groups; + var sticky = UNSUPPORTED_Y$2 && re.sticky; + var flags = call$9(regexpFlags, re); + var source = re.source; + var charsAdded = 0; + var strCopy = str; + + if (sticky) { + flags = replace$5(flags, 'y', ''); + if (indexOf$1(flags, 'g') === -1) { + flags += 'g'; + } + + strCopy = stringSlice$6(str, re.lastIndex); + // Support anchored sticky behavior. + if (re.lastIndex > 0 && (!re.multiline || re.multiline && charAt$5(str, re.lastIndex - 1) !== '\n')) { + source = '(?: ' + source + ')'; + strCopy = ' ' + strCopy; + charsAdded++; + } + // ^(? + rx + ) is needed, in combination with some str slicing, to + // simulate the 'y' flag. + reCopy = new RegExp('^(?:' + source + ')', flags); + } + + if (NPCG_INCLUDED) { + reCopy = new RegExp('^' + source + '$(?!\\s)', flags); + } + if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex; + + match = call$9(nativeExec, sticky ? reCopy : re, strCopy); + + if (sticky) { + if (match) { + match.input = stringSlice$6(match.input, charsAdded); + match[0] = stringSlice$6(match[0], charsAdded); + match.index = re.lastIndex; + re.lastIndex += match[0].length; + } else re.lastIndex = 0; + } else if (UPDATES_LAST_INDEX_WRONG && match) { + re.lastIndex = re.global ? match.index + match[0].length : lastIndex; + } + if (NPCG_INCLUDED && match && match.length > 1) { + // Fix browsers whose `exec` methods don't consistently return `undefined` + // for NPCG, like IE8. NOTE: This doesn't work for /(.?)?/ + call$9(nativeReplace, match[0], reCopy, function () { + for (i = 1; i < arguments.length - 2; i++) { + if (arguments[i] === undefined) match[i] = undefined; + } + }); + } + + if (match && groups) { + match.groups = object = create(null); + for (i = 0; i < groups.length; i++) { group = groups[i]; object[group[0]] = match[group[1]]; } @@ -1358,12 +1692,12 @@ if (PATCH) { var regexpExec$3 = patchedExec; -var $$f = _export; +var $$e = _export; var exec$6 = regexpExec$3; // `RegExp.prototype.exec` method // https://tc39.es/ecma262/#sec-regexp.prototype.exec -$$f({ target: 'RegExp', proto: true, forced: /./.exec !== exec$6 }, { +$$e({ target: 'RegExp', proto: true, forced: /./.exec !== exec$6 }, { exec: exec$6 }); @@ -1371,36 +1705,36 @@ var NATIVE_BIND$1 = functionBindNative; var FunctionPrototype = Function.prototype; var apply$4 = FunctionPrototype.apply; -var call$9 = FunctionPrototype.call; +var call$8 = FunctionPrototype.call; // eslint-disable-next-line es-x/no-reflect -- safe -var functionApply = typeof Reflect == 'object' && Reflect.apply || (NATIVE_BIND$1 ? call$9.bind(apply$4) : function () { - return call$9.apply(apply$4, arguments); +var functionApply = typeof Reflect == 'object' && Reflect.apply || (NATIVE_BIND$1 ? call$8.bind(apply$4) : function () { + return call$8.apply(apply$4, arguments); }); // TODO: Remove from `core-js@4` since it's moved to entry points -var uncurryThis$h = functionUncurryThis; -var defineBuiltIn$3 = defineBuiltIn$5; +var uncurryThis$g = functionUncurryThis; +var defineBuiltIn$1 = defineBuiltIn$5; var regexpExec$2 = regexpExec$3; -var fails$d = fails$p; -var wellKnownSymbol$e = wellKnownSymbol$i; -var createNonEnumerableProperty$4 = createNonEnumerableProperty$7; +var fails$b = fails$p; +var wellKnownSymbol$a = wellKnownSymbol$i; +var createNonEnumerableProperty$3 = createNonEnumerableProperty$7; -var SPECIES$5 = wellKnownSymbol$e('species'); +var SPECIES$5 = wellKnownSymbol$a('species'); var RegExpPrototype$3 = RegExp.prototype; var fixRegexpWellKnownSymbolLogic = function (KEY, exec, FORCED, SHAM) { - var SYMBOL = wellKnownSymbol$e(KEY); + var SYMBOL = wellKnownSymbol$a(KEY); - var DELEGATES_TO_SYMBOL = !fails$d(function () { + var DELEGATES_TO_SYMBOL = !fails$b(function () { // String methods call symbol-named RegEp methods var O = {}; O[SYMBOL] = function () { return 7; }; return ''[KEY](O) != 7; }); - var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails$d(function () { + var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails$b(function () { // Symbol-named RegExp methods call .exec var execCalled = false; var re = /a/; @@ -1429,9 +1763,9 @@ var fixRegexpWellKnownSymbolLogic = function (KEY, exec, FORCED, SHAM) { !DELEGATES_TO_EXEC || FORCED ) { - var uncurriedNativeRegExpMethod = uncurryThis$h(/./[SYMBOL]); + var uncurriedNativeRegExpMethod = uncurryThis$g(/./[SYMBOL]); var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) { - var uncurriedNativeMethod = uncurryThis$h(nativeMethod); + var uncurriedNativeMethod = uncurryThis$g(nativeMethod); var $exec = regexp.exec; if ($exec === regexpExec$2 || $exec === RegExpPrototype$3.exec) { if (DELEGATES_TO_SYMBOL && !forceStringMethod) { @@ -1445,21 +1779,21 @@ var fixRegexpWellKnownSymbolLogic = function (KEY, exec, FORCED, SHAM) { return { done: false }; }); - defineBuiltIn$3(String.prototype, KEY, methods[0]); - defineBuiltIn$3(RegExpPrototype$3, SYMBOL, methods[1]); + defineBuiltIn$1(String.prototype, KEY, methods[0]); + defineBuiltIn$1(RegExpPrototype$3, SYMBOL, methods[1]); } - if (SHAM) createNonEnumerableProperty$4(RegExpPrototype$3[SYMBOL], 'sham', true); + if (SHAM) createNonEnumerableProperty$3(RegExpPrototype$3[SYMBOL], 'sham', true); }; -var uncurryThis$g = functionUncurryThis; +var uncurryThis$f = functionUncurryThis; var toIntegerOrInfinity$2 = toIntegerOrInfinity$5; var toString$8 = toString$a; var requireObjectCoercible$5 = requireObjectCoercible$8; -var charAt$4 = uncurryThis$g(''.charAt); -var charCodeAt$1 = uncurryThis$g(''.charCodeAt); -var stringSlice$5 = uncurryThis$g(''.slice); +var charAt$4 = uncurryThis$f(''.charAt); +var charCodeAt$1 = uncurryThis$f(''.charCodeAt); +var stringSlice$5 = uncurryThis$f(''.slice); var createMethod$2 = function (CONVERT_TO_STRING) { return function ($this, pos) { @@ -1497,13 +1831,13 @@ var advanceStringIndex$3 = function (S, index, unicode) { return index + (unicode ? charAt$3(S, index).length : 1); }; -var uncurryThis$f = functionUncurryThis; -var toObject$5 = toObject$7; +var uncurryThis$e = functionUncurryThis; +var toObject$4 = toObject$7; var floor$1 = Math.floor; -var charAt$2 = uncurryThis$f(''.charAt); -var replace$4 = uncurryThis$f(''.replace); -var stringSlice$4 = uncurryThis$f(''.slice); +var charAt$2 = uncurryThis$e(''.charAt); +var replace$4 = uncurryThis$e(''.replace); +var stringSlice$4 = uncurryThis$e(''.slice); var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d{1,2}|<[^>]*>)/g; var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d{1,2})/g; @@ -1514,7 +1848,7 @@ var getSubstitution$2 = function (matched, str, position, captures, namedCapture var m = captures.length; var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED; if (namedCaptures !== undefined) { - namedCaptures = toObject$5(namedCaptures); + namedCaptures = toObject$4(namedCaptures); symbols = SUBSTITUTION_SYMBOLS; } return replace$4(replacement, symbols, function (match, ch) { @@ -1542,34 +1876,34 @@ var getSubstitution$2 = function (matched, str, position, captures, namedCapture }); }; -var call$8 = functionCall; -var anObject$5 = anObject$b; -var isCallable$a = isCallable$m; +var call$7 = functionCall; +var anObject$4 = anObject$b; +var isCallable$6 = isCallable$m; var classof$4 = classofRaw$1; var regexpExec$1 = regexpExec$3; -var $TypeError$7 = TypeError; +var $TypeError$6 = TypeError; // `RegExpExec` abstract operation // https://tc39.es/ecma262/#sec-regexpexec var regexpExecAbstract = function (R, S) { var exec = R.exec; - if (isCallable$a(exec)) { - var result = call$8(exec, R, S); - if (result !== null) anObject$5(result); + if (isCallable$6(exec)) { + var result = call$7(exec, R, S); + if (result !== null) anObject$4(result); return result; } - if (classof$4(R) === 'RegExp') return call$8(regexpExec$1, R, S); - throw $TypeError$7('RegExp#exec called on incompatible receiver'); + if (classof$4(R) === 'RegExp') return call$7(regexpExec$1, R, S); + throw $TypeError$6('RegExp#exec called on incompatible receiver'); }; var apply$3 = functionApply; -var call$7 = functionCall; -var uncurryThis$e = functionUncurryThis; +var call$6 = functionCall; +var uncurryThis$d = functionUncurryThis; var fixRegExpWellKnownSymbolLogic$2 = fixRegexpWellKnownSymbolLogic; -var fails$c = fails$p; -var anObject$4 = anObject$b; -var isCallable$9 = isCallable$m; +var fails$a = fails$p; +var anObject$3 = anObject$b; +var isCallable$5 = isCallable$m; var toIntegerOrInfinity$1 = toIntegerOrInfinity$5; var toLength$2 = toLength$4; var toString$7 = toString$a; @@ -1578,15 +1912,15 @@ var advanceStringIndex$2 = advanceStringIndex$3; var getMethod$3 = getMethod$5; var getSubstitution$1 = getSubstitution$2; var regExpExec$1 = regexpExecAbstract; -var wellKnownSymbol$d = wellKnownSymbol$i; +var wellKnownSymbol$9 = wellKnownSymbol$i; -var REPLACE$1 = wellKnownSymbol$d('replace'); +var REPLACE$1 = wellKnownSymbol$9('replace'); var max$4 = Math.max; var min$2 = Math.min; -var concat = uncurryThis$e([].concat); -var push$3 = uncurryThis$e([].push); -var stringIndexOf$2 = uncurryThis$e(''.indexOf); -var stringSlice$3 = uncurryThis$e(''.slice); +var concat = uncurryThis$d([].concat); +var push$3 = uncurryThis$d([].push); +var stringIndexOf$2 = uncurryThis$d(''.indexOf); +var stringSlice$3 = uncurryThis$d(''.slice); var maybeToString = function (it) { return it === undefined ? it : String(it); @@ -1607,7 +1941,7 @@ var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = (function () { return false; })(); -var REPLACE_SUPPORTS_NAMED_GROUPS = !fails$c(function () { +var REPLACE_SUPPORTS_NAMED_GROUPS = !fails$a(function () { var re = /./; re.exec = function () { var result = []; @@ -1629,13 +1963,13 @@ fixRegExpWellKnownSymbolLogic$2('replace', function (_, nativeReplace, maybeCall var O = requireObjectCoercible$4(this); var replacer = searchValue == undefined ? undefined : getMethod$3(searchValue, REPLACE$1); return replacer - ? call$7(replacer, searchValue, O, replaceValue) - : call$7(nativeReplace, toString$7(O), searchValue, replaceValue); + ? call$6(replacer, searchValue, O, replaceValue) + : call$6(nativeReplace, toString$7(O), searchValue, replaceValue); }, // `RegExp.prototype[@@replace]` method // https://tc39.es/ecma262/#sec-regexp.prototype-@@replace function (string, replaceValue) { - var rx = anObject$4(this); + var rx = anObject$3(this); var S = toString$7(string); if ( @@ -1647,7 +1981,7 @@ fixRegExpWellKnownSymbolLogic$2('replace', function (_, nativeReplace, maybeCall if (res.done) return res.value; } - var functionalReplace = isCallable$9(replaceValue); + var functionalReplace = isCallable$5(replaceValue); if (!functionalReplace) replaceValue = toString$7(replaceValue); var global = rx.global; @@ -1701,9 +2035,9 @@ fixRegExpWellKnownSymbolLogic$2('replace', function (_, nativeReplace, maybeCall var isObject$7 = isObject$d; var classof$3 = classofRaw$1; -var wellKnownSymbol$c = wellKnownSymbol$i; +var wellKnownSymbol$8 = wellKnownSymbol$i; -var MATCH$1 = wellKnownSymbol$c('match'); +var MATCH$1 = wellKnownSymbol$8('match'); // `IsRegExp` abstract operation // https://tc39.es/ecma262/#sec-isregexp @@ -1712,8 +2046,8 @@ var isRegexp = function (it) { return isObject$7(it) && ((isRegExp = it[MATCH$1]) !== undefined ? !!isRegExp : classof$3(it) == 'RegExp'); }; -var call$6 = functionCall; -var hasOwn$4 = hasOwnProperty_1; +var call$5 = functionCall; +var hasOwn$2 = hasOwnProperty_1; var isPrototypeOf$2 = objectIsPrototypeOf; var regExpFlags = regexpFlags$1; @@ -1721,27 +2055,27 @@ var RegExpPrototype$2 = RegExp.prototype; var regexpGetFlags = function (R) { var flags = R.flags; - return flags === undefined && !('flags' in RegExpPrototype$2) && !hasOwn$4(R, 'flags') && isPrototypeOf$2(RegExpPrototype$2, R) - ? call$6(regExpFlags, R) : flags; + return flags === undefined && !('flags' in RegExpPrototype$2) && !hasOwn$2(R, 'flags') && isPrototypeOf$2(RegExpPrototype$2, R) + ? call$5(regExpFlags, R) : flags; }; -var $$e = _export; -var call$5 = functionCall; -var uncurryThis$d = functionUncurryThis; +var $$d = _export; +var call$4 = functionCall; +var uncurryThis$c = functionUncurryThis; var requireObjectCoercible$3 = requireObjectCoercible$8; -var isCallable$8 = isCallable$m; +var isCallable$4 = isCallable$m; var isRegExp$2 = isRegexp; var toString$6 = toString$a; var getMethod$2 = getMethod$5; var getRegExpFlags$1 = regexpGetFlags; var getSubstitution = getSubstitution$2; -var wellKnownSymbol$b = wellKnownSymbol$i; +var wellKnownSymbol$7 = wellKnownSymbol$i; -var REPLACE = wellKnownSymbol$b('replace'); -var $TypeError$6 = TypeError; -var indexOf = uncurryThis$d(''.indexOf); -uncurryThis$d(''.replace); -var stringSlice$2 = uncurryThis$d(''.slice); +var REPLACE = wellKnownSymbol$7('replace'); +var $TypeError$5 = TypeError; +var indexOf = uncurryThis$c(''.indexOf); +uncurryThis$c(''.replace); +var stringSlice$2 = uncurryThis$c(''.slice); var max$3 = Math.max; var stringIndexOf$1 = function (string, searchValue, fromIndex) { @@ -1752,111 +2086,72 @@ var stringIndexOf$1 = function (string, searchValue, fromIndex) { // `String.prototype.replaceAll` method // https://tc39.es/ecma262/#sec-string.prototype.replaceall -$$e({ target: 'String', proto: true }, { +$$d({ target: 'String', proto: true }, { replaceAll: function replaceAll(searchValue, replaceValue) { var O = requireObjectCoercible$3(this); var IS_REG_EXP, flags, replacer, string, searchString, functionalReplace, searchLength, advanceBy, replacement; var position = 0; var endOfLastMatch = 0; var result = ''; - if (searchValue != null) { - IS_REG_EXP = isRegExp$2(searchValue); - if (IS_REG_EXP) { - flags = toString$6(requireObjectCoercible$3(getRegExpFlags$1(searchValue))); - if (!~indexOf(flags, 'g')) throw $TypeError$6('`.replaceAll` does not allow non-global regexes'); - } - replacer = getMethod$2(searchValue, REPLACE); - if (replacer) { - return call$5(replacer, searchValue, O, replaceValue); - } - } - string = toString$6(O); - searchString = toString$6(searchValue); - functionalReplace = isCallable$8(replaceValue); - if (!functionalReplace) replaceValue = toString$6(replaceValue); - searchLength = searchString.length; - advanceBy = max$3(1, searchLength); - position = stringIndexOf$1(string, searchString, 0); - while (position !== -1) { - replacement = functionalReplace - ? toString$6(replaceValue(searchString, position, string)) - : getSubstitution(searchString, string, position, [], undefined, replaceValue); - result += stringSlice$2(string, endOfLastMatch, position) + replacement; - endOfLastMatch = position + searchLength; - position = stringIndexOf$1(string, searchString, position + advanceBy); - } - if (endOfLastMatch < string.length) { - result += stringSlice$2(string, endOfLastMatch); - } - return result; - } -}); - -var isCallable$7 = isCallable$m; - -var $String = String; -var $TypeError$5 = TypeError; - -var aPossiblePrototype$1 = function (argument) { - if (typeof argument == 'object' || isCallable$7(argument)) return argument; - throw $TypeError$5("Can't set " + $String(argument) + ' as a prototype'); -}; - -/* eslint-disable no-proto -- safe */ - -var uncurryThis$c = functionUncurryThis; -var anObject$3 = anObject$b; -var aPossiblePrototype = aPossiblePrototype$1; - -// `Object.setPrototypeOf` method -// https://tc39.es/ecma262/#sec-object.setprototypeof -// Works with __proto__ only. Old v8 can't work with null proto objects. -// eslint-disable-next-line es-x/no-object-setprototypeof -- safe -var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () { - var CORRECT_SETTER = false; - var test = {}; - var setter; - try { - // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe - setter = uncurryThis$c(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set); - setter(test, []); - CORRECT_SETTER = test instanceof Array; - } catch (error) { /* empty */ } - return function setPrototypeOf(O, proto) { - anObject$3(O); - aPossiblePrototype(proto); - if (CORRECT_SETTER) setter(O, proto); - else O.__proto__ = proto; - return O; - }; -}() : undefined); + if (searchValue != null) { + IS_REG_EXP = isRegExp$2(searchValue); + if (IS_REG_EXP) { + flags = toString$6(requireObjectCoercible$3(getRegExpFlags$1(searchValue))); + if (!~indexOf(flags, 'g')) throw $TypeError$5('`.replaceAll` does not allow non-global regexes'); + } + replacer = getMethod$2(searchValue, REPLACE); + if (replacer) { + return call$4(replacer, searchValue, O, replaceValue); + } + } + string = toString$6(O); + searchString = toString$6(searchValue); + functionalReplace = isCallable$4(replaceValue); + if (!functionalReplace) replaceValue = toString$6(replaceValue); + searchLength = searchString.length; + advanceBy = max$3(1, searchLength); + position = stringIndexOf$1(string, searchString, 0); + while (position !== -1) { + replacement = functionalReplace + ? toString$6(replaceValue(searchString, position, string)) + : getSubstitution(searchString, string, position, [], undefined, replaceValue); + result += stringSlice$2(string, endOfLastMatch, position) + replacement; + endOfLastMatch = position + searchLength; + position = stringIndexOf$1(string, searchString, position + advanceBy); + } + if (endOfLastMatch < string.length) { + result += stringSlice$2(string, endOfLastMatch); + } + return result; + } +}); -var defineProperty$4 = objectDefineProperty.f; +var defineProperty$1 = objectDefineProperty.f; var proxyAccessor$2 = function (Target, Source, key) { - key in Target || defineProperty$4(Target, key, { + key in Target || defineProperty$1(Target, key, { configurable: true, get: function () { return Source[key]; }, set: function (it) { Source[key] = it; } }); }; -var isCallable$6 = isCallable$m; +var isCallable$3 = isCallable$m; var isObject$6 = isObject$d; -var setPrototypeOf$2 = objectSetPrototypeOf; +var setPrototypeOf$1 = objectSetPrototypeOf; // makes subclassing work correct for wrapped built-ins var inheritIfRequired$2 = function ($this, dummy, Wrapper) { var NewTarget, NewTargetPrototype; if ( // it can work only with native `setPrototypeOf` - setPrototypeOf$2 && + setPrototypeOf$1 && // we haven't completely correct pre-ES6 way for getting `new.target`, so use this - isCallable$6(NewTarget = dummy.constructor) && + isCallable$3(NewTarget = dummy.constructor) && NewTarget !== Wrapper && isObject$6(NewTargetPrototype = NewTarget.prototype) && NewTargetPrototype !== Wrapper.prototype - ) setPrototypeOf$2($this, NewTargetPrototype); + ) setPrototypeOf$1($this, NewTargetPrototype); return $this; }; @@ -1867,13 +2162,13 @@ var normalizeStringArgument$1 = function (argument, $default) { }; var isObject$5 = isObject$d; -var createNonEnumerableProperty$3 = createNonEnumerableProperty$7; +var createNonEnumerableProperty$2 = createNonEnumerableProperty$7; // `InstallErrorCause` abstract operation // https://tc39.es/proposal-error-cause/#sec-errorobjects-install-error-cause var installErrorCause$1 = function (O, options) { if (isObject$5(options) && 'cause' in options) { - createNonEnumerableProperty$3(O, 'cause', options.cause); + createNonEnumerableProperty$2(O, 'cause', options.cause); } }; @@ -1889,427 +2184,142 @@ var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST); var clearErrorStack$1 = function (stack, dropEntries) { if (IS_V8_OR_CHAKRA_STACK && typeof stack == 'string' && !$Error.prepareStackTrace) { while (dropEntries--) stack = replace$3(stack, V8_OR_CHAKRA_STACK_ENTRY, ''); - } return stack; -}; - -var fails$b = fails$p; -var createPropertyDescriptor$2 = createPropertyDescriptor$5; - -var errorStackInstallable = !fails$b(function () { - var error = Error('a'); - if (!('stack' in error)) return true; - // eslint-disable-next-line es-x/no-object-defineproperty -- safe - Object.defineProperty(error, 'stack', createPropertyDescriptor$2(1, 7)); - return error.stack !== 7; -}); - -var getBuiltIn$3 = getBuiltIn$8; -var hasOwn$3 = hasOwnProperty_1; -var createNonEnumerableProperty$2 = createNonEnumerableProperty$7; -var isPrototypeOf$1 = objectIsPrototypeOf; -var setPrototypeOf$1 = objectSetPrototypeOf; -var copyConstructorProperties = copyConstructorProperties$2; -var proxyAccessor$1 = proxyAccessor$2; -var inheritIfRequired$1 = inheritIfRequired$2; -var normalizeStringArgument = normalizeStringArgument$1; -var installErrorCause = installErrorCause$1; -var clearErrorStack = clearErrorStack$1; -var ERROR_STACK_INSTALLABLE = errorStackInstallable; -var DESCRIPTORS$4 = descriptors; - -var wrapErrorConstructorWithCause$1 = function (FULL_NAME, wrapper, FORCED, IS_AGGREGATE_ERROR) { - var STACK_TRACE_LIMIT = 'stackTraceLimit'; - var OPTIONS_POSITION = IS_AGGREGATE_ERROR ? 2 : 1; - var path = FULL_NAME.split('.'); - var ERROR_NAME = path[path.length - 1]; - var OriginalError = getBuiltIn$3.apply(null, path); - - if (!OriginalError) return; - - var OriginalErrorPrototype = OriginalError.prototype; - - // V8 9.3- bug https://bugs.chromium.org/p/v8/issues/detail?id=12006 - if (hasOwn$3(OriginalErrorPrototype, 'cause')) delete OriginalErrorPrototype.cause; - - if (!FORCED) return OriginalError; - - var BaseError = getBuiltIn$3('Error'); - - var WrappedError = wrapper(function (a, b) { - var message = normalizeStringArgument(IS_AGGREGATE_ERROR ? b : a, undefined); - var result = IS_AGGREGATE_ERROR ? new OriginalError(a) : new OriginalError(); - if (message !== undefined) createNonEnumerableProperty$2(result, 'message', message); - if (ERROR_STACK_INSTALLABLE) createNonEnumerableProperty$2(result, 'stack', clearErrorStack(result.stack, 2)); - if (this && isPrototypeOf$1(OriginalErrorPrototype, this)) inheritIfRequired$1(result, this, WrappedError); - if (arguments.length > OPTIONS_POSITION) installErrorCause(result, arguments[OPTIONS_POSITION]); - return result; - }); - - WrappedError.prototype = OriginalErrorPrototype; - - if (ERROR_NAME !== 'Error') { - if (setPrototypeOf$1) setPrototypeOf$1(WrappedError, BaseError); - else copyConstructorProperties(WrappedError, BaseError, { name: true }); - } else if (DESCRIPTORS$4 && STACK_TRACE_LIMIT in OriginalError) { - proxyAccessor$1(WrappedError, OriginalError, STACK_TRACE_LIMIT); - proxyAccessor$1(WrappedError, OriginalError, 'prepareStackTrace'); - } - - copyConstructorProperties(WrappedError, OriginalError); - - try { - // Safari 13- bug: WebAssembly errors does not have a proper `.name` - if (OriginalErrorPrototype.name !== ERROR_NAME) { - createNonEnumerableProperty$2(OriginalErrorPrototype, 'name', ERROR_NAME); - } - OriginalErrorPrototype.constructor = WrappedError; - } catch (error) { /* empty */ } - - return WrappedError; -}; - -/* eslint-disable no-unused-vars -- required for functions `.length` */ - -var $$d = _export; -var global$2 = global$f; -var apply$2 = functionApply; -var wrapErrorConstructorWithCause = wrapErrorConstructorWithCause$1; - -var WEB_ASSEMBLY = 'WebAssembly'; -var WebAssembly = global$2[WEB_ASSEMBLY]; - -var FORCED$2 = Error('e', { cause: 7 }).cause !== 7; - -var exportGlobalErrorCauseWrapper = function (ERROR_NAME, wrapper) { - var O = {}; - O[ERROR_NAME] = wrapErrorConstructorWithCause(ERROR_NAME, wrapper, FORCED$2); - $$d({ global: true, constructor: true, arity: 1, forced: FORCED$2 }, O); -}; - -var exportWebAssemblyErrorCauseWrapper = function (ERROR_NAME, wrapper) { - if (WebAssembly && WebAssembly[ERROR_NAME]) { - var O = {}; - O[ERROR_NAME] = wrapErrorConstructorWithCause(WEB_ASSEMBLY + '.' + ERROR_NAME, wrapper, FORCED$2); - $$d({ target: WEB_ASSEMBLY, stat: true, constructor: true, arity: 1, forced: FORCED$2 }, O); - } -}; - -// https://github.com/tc39/proposal-error-cause -exportGlobalErrorCauseWrapper('Error', function (init) { - return function Error(message) { return apply$2(init, this, arguments); }; -}); -exportGlobalErrorCauseWrapper('EvalError', function (init) { - return function EvalError(message) { return apply$2(init, this, arguments); }; -}); -exportGlobalErrorCauseWrapper('RangeError', function (init) { - return function RangeError(message) { return apply$2(init, this, arguments); }; -}); -exportGlobalErrorCauseWrapper('ReferenceError', function (init) { - return function ReferenceError(message) { return apply$2(init, this, arguments); }; -}); -exportGlobalErrorCauseWrapper('SyntaxError', function (init) { - return function SyntaxError(message) { return apply$2(init, this, arguments); }; -}); -exportGlobalErrorCauseWrapper('TypeError', function (init) { - return function TypeError(message) { return apply$2(init, this, arguments); }; -}); -exportGlobalErrorCauseWrapper('URIError', function (init) { - return function URIError(message) { return apply$2(init, this, arguments); }; -}); -exportWebAssemblyErrorCauseWrapper('CompileError', function (init) { - return function CompileError(message) { return apply$2(init, this, arguments); }; -}); -exportWebAssemblyErrorCauseWrapper('LinkError', function (init) { - return function LinkError(message) { return apply$2(init, this, arguments); }; -}); -exportWebAssemblyErrorCauseWrapper('RuntimeError', function (init) { - return function RuntimeError(message) { return apply$2(init, this, arguments); }; -}); - -var wellKnownSymbol$a = wellKnownSymbol$i; -var create$1 = objectCreate; -var defineProperty$3 = objectDefineProperty.f; - -var UNSCOPABLES = wellKnownSymbol$a('unscopables'); -var ArrayPrototype = Array.prototype; - -// Array.prototype[@@unscopables] -// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables -if (ArrayPrototype[UNSCOPABLES] == undefined) { - defineProperty$3(ArrayPrototype, UNSCOPABLES, { - configurable: true, - value: create$1(null) - }); -} - -// add a key to Array.prototype[@@unscopables] -var addToUnscopables$1 = function (key) { - ArrayPrototype[UNSCOPABLES][key] = true; -}; - -var iterators = {}; - -var fails$a = fails$p; - -var correctPrototypeGetter = !fails$a(function () { - function F() { /* empty */ } - F.prototype.constructor = null; - // eslint-disable-next-line es-x/no-object-getprototypeof -- required for testing - return Object.getPrototypeOf(new F()) !== F.prototype; -}); - -var hasOwn$2 = hasOwnProperty_1; -var isCallable$5 = isCallable$m; -var toObject$4 = toObject$7; -var sharedKey = sharedKey$3; -var CORRECT_PROTOTYPE_GETTER = correctPrototypeGetter; - -var IE_PROTO = sharedKey('IE_PROTO'); -var $Object = Object; -var ObjectPrototype = $Object.prototype; - -// `Object.getPrototypeOf` method -// https://tc39.es/ecma262/#sec-object.getprototypeof -// eslint-disable-next-line es-x/no-object-getprototypeof -- safe -var objectGetPrototypeOf = CORRECT_PROTOTYPE_GETTER ? $Object.getPrototypeOf : function (O) { - var object = toObject$4(O); - if (hasOwn$2(object, IE_PROTO)) return object[IE_PROTO]; - var constructor = object.constructor; - if (isCallable$5(constructor) && object instanceof constructor) { - return constructor.prototype; - } return object instanceof $Object ? ObjectPrototype : null; -}; - -var fails$9 = fails$p; -var isCallable$4 = isCallable$m; -var getPrototypeOf$1 = objectGetPrototypeOf; -var defineBuiltIn$2 = defineBuiltIn$5; -var wellKnownSymbol$9 = wellKnownSymbol$i; - -var ITERATOR$1 = wellKnownSymbol$9('iterator'); -var BUGGY_SAFARI_ITERATORS$1 = false; - -// `%IteratorPrototype%` object -// https://tc39.es/ecma262/#sec-%iteratorprototype%-object -var IteratorPrototype$2, PrototypeOfArrayIteratorPrototype, arrayIterator; - -/* eslint-disable es-x/no-array-prototype-keys -- safe */ -if ([].keys) { - arrayIterator = [].keys(); - // Safari 8 has buggy iterators w/o `next` - if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS$1 = true; - else { - PrototypeOfArrayIteratorPrototype = getPrototypeOf$1(getPrototypeOf$1(arrayIterator)); - if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype$2 = PrototypeOfArrayIteratorPrototype; - } -} - -var NEW_ITERATOR_PROTOTYPE = IteratorPrototype$2 == undefined || fails$9(function () { - var test = {}; - // FF44- legacy iterators case - return IteratorPrototype$2[ITERATOR$1].call(test) !== test; -}); - -if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype$2 = {}; - -// `%IteratorPrototype%[@@iterator]()` method -// https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator -if (!isCallable$4(IteratorPrototype$2[ITERATOR$1])) { - defineBuiltIn$2(IteratorPrototype$2, ITERATOR$1, function () { - return this; - }); -} - -var iteratorsCore = { - IteratorPrototype: IteratorPrototype$2, - BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS$1 -}; - -var defineProperty$2 = objectDefineProperty.f; -var hasOwn$1 = hasOwnProperty_1; -var wellKnownSymbol$8 = wellKnownSymbol$i; - -var TO_STRING_TAG = wellKnownSymbol$8('toStringTag'); - -var setToStringTag$2 = function (target, TAG, STATIC) { - if (target && !STATIC) target = target.prototype; - if (target && !hasOwn$1(target, TO_STRING_TAG)) { - defineProperty$2(target, TO_STRING_TAG, { configurable: true, value: TAG }); - } + } return stack; }; -var IteratorPrototype$1 = iteratorsCore.IteratorPrototype; -var create = objectCreate; +var fails$9 = fails$p; var createPropertyDescriptor$1 = createPropertyDescriptor$5; -var setToStringTag$1 = setToStringTag$2; -var Iterators$2 = iterators; - -var returnThis$1 = function () { return this; }; -var createIteratorConstructor$1 = function (IteratorConstructor, NAME, next, ENUMERABLE_NEXT) { - var TO_STRING_TAG = NAME + ' Iterator'; - IteratorConstructor.prototype = create(IteratorPrototype$1, { next: createPropertyDescriptor$1(+!ENUMERABLE_NEXT, next) }); - setToStringTag$1(IteratorConstructor, TO_STRING_TAG, false); - Iterators$2[TO_STRING_TAG] = returnThis$1; - return IteratorConstructor; -}; +var errorStackInstallable = !fails$9(function () { + var error = Error('a'); + if (!('stack' in error)) return true; + // eslint-disable-next-line es-x/no-object-defineproperty -- safe + Object.defineProperty(error, 'stack', createPropertyDescriptor$1(1, 7)); + return error.stack !== 7; +}); -var $$c = _export; -var call$4 = functionCall; -var FunctionName = functionName; -var isCallable$3 = isCallable$m; -var createIteratorConstructor = createIteratorConstructor$1; -var getPrototypeOf = objectGetPrototypeOf; -var setPrototypeOf = objectSetPrototypeOf; -var setToStringTag = setToStringTag$2; +var getBuiltIn$3 = getBuiltIn$8; +var hasOwn$1 = hasOwnProperty_1; var createNonEnumerableProperty$1 = createNonEnumerableProperty$7; -var defineBuiltIn$1 = defineBuiltIn$5; -var wellKnownSymbol$7 = wellKnownSymbol$i; -var Iterators$1 = iterators; -var IteratorsCore = iteratorsCore; +var isPrototypeOf$1 = objectIsPrototypeOf; +var setPrototypeOf = objectSetPrototypeOf; +var copyConstructorProperties = copyConstructorProperties$2; +var proxyAccessor$1 = proxyAccessor$2; +var inheritIfRequired$1 = inheritIfRequired$2; +var normalizeStringArgument = normalizeStringArgument$1; +var installErrorCause = installErrorCause$1; +var clearErrorStack = clearErrorStack$1; +var ERROR_STACK_INSTALLABLE = errorStackInstallable; +var DESCRIPTORS$3 = descriptors; -var PROPER_FUNCTION_NAME$1 = FunctionName.PROPER; -var CONFIGURABLE_FUNCTION_NAME = FunctionName.CONFIGURABLE; -var IteratorPrototype = IteratorsCore.IteratorPrototype; -var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS; -var ITERATOR = wellKnownSymbol$7('iterator'); -var KEYS = 'keys'; -var VALUES = 'values'; -var ENTRIES = 'entries'; +var wrapErrorConstructorWithCause$1 = function (FULL_NAME, wrapper, FORCED, IS_AGGREGATE_ERROR) { + var STACK_TRACE_LIMIT = 'stackTraceLimit'; + var OPTIONS_POSITION = IS_AGGREGATE_ERROR ? 2 : 1; + var path = FULL_NAME.split('.'); + var ERROR_NAME = path[path.length - 1]; + var OriginalError = getBuiltIn$3.apply(null, path); -var returnThis = function () { return this; }; + if (!OriginalError) return; -var defineIterator$1 = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) { - createIteratorConstructor(IteratorConstructor, NAME, next); + var OriginalErrorPrototype = OriginalError.prototype; - var getIterationMethod = function (KIND) { - if (KIND === DEFAULT && defaultIterator) return defaultIterator; - if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype) return IterablePrototype[KIND]; - switch (KIND) { - case KEYS: return function keys() { return new IteratorConstructor(this, KIND); }; - case VALUES: return function values() { return new IteratorConstructor(this, KIND); }; - case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); }; - } return function () { return new IteratorConstructor(this); }; - }; + // V8 9.3- bug https://bugs.chromium.org/p/v8/issues/detail?id=12006 + if (hasOwn$1(OriginalErrorPrototype, 'cause')) delete OriginalErrorPrototype.cause; - var TO_STRING_TAG = NAME + ' Iterator'; - var INCORRECT_VALUES_NAME = false; - var IterablePrototype = Iterable.prototype; - var nativeIterator = IterablePrototype[ITERATOR] - || IterablePrototype['@@iterator'] - || DEFAULT && IterablePrototype[DEFAULT]; - var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT); - var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator; - var CurrentIteratorPrototype, methods, KEY; + if (!FORCED) return OriginalError; - // fix native - if (anyNativeIterator) { - CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable())); - if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) { - if (getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) { - if (setPrototypeOf) { - setPrototypeOf(CurrentIteratorPrototype, IteratorPrototype); - } else if (!isCallable$3(CurrentIteratorPrototype[ITERATOR])) { - defineBuiltIn$1(CurrentIteratorPrototype, ITERATOR, returnThis); - } - } - // Set @@toStringTag to native iterators - setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true); - } - } + var BaseError = getBuiltIn$3('Error'); - // fix Array.prototype.{ values, @@iterator }.name in V8 / FF - if (PROPER_FUNCTION_NAME$1 && DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) { - if (CONFIGURABLE_FUNCTION_NAME) { - createNonEnumerableProperty$1(IterablePrototype, 'name', VALUES); - } else { - INCORRECT_VALUES_NAME = true; - defaultIterator = function values() { return call$4(nativeIterator, this); }; - } - } + var WrappedError = wrapper(function (a, b) { + var message = normalizeStringArgument(IS_AGGREGATE_ERROR ? b : a, undefined); + var result = IS_AGGREGATE_ERROR ? new OriginalError(a) : new OriginalError(); + if (message !== undefined) createNonEnumerableProperty$1(result, 'message', message); + if (ERROR_STACK_INSTALLABLE) createNonEnumerableProperty$1(result, 'stack', clearErrorStack(result.stack, 2)); + if (this && isPrototypeOf$1(OriginalErrorPrototype, this)) inheritIfRequired$1(result, this, WrappedError); + if (arguments.length > OPTIONS_POSITION) installErrorCause(result, arguments[OPTIONS_POSITION]); + return result; + }); - // export additional methods - if (DEFAULT) { - methods = { - values: getIterationMethod(VALUES), - keys: IS_SET ? defaultIterator : getIterationMethod(KEYS), - entries: getIterationMethod(ENTRIES) - }; - if (FORCED) for (KEY in methods) { - if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) { - defineBuiltIn$1(IterablePrototype, KEY, methods[KEY]); - } - } else $$c({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods); - } + WrappedError.prototype = OriginalErrorPrototype; - // define iterator - if (IterablePrototype[ITERATOR] !== defaultIterator) { - defineBuiltIn$1(IterablePrototype, ITERATOR, defaultIterator, { name: DEFAULT }); + if (ERROR_NAME !== 'Error') { + if (setPrototypeOf) setPrototypeOf(WrappedError, BaseError); + else copyConstructorProperties(WrappedError, BaseError, { name: true }); + } else if (DESCRIPTORS$3 && STACK_TRACE_LIMIT in OriginalError) { + proxyAccessor$1(WrappedError, OriginalError, STACK_TRACE_LIMIT); + proxyAccessor$1(WrappedError, OriginalError, 'prepareStackTrace'); } - Iterators$1[NAME] = defaultIterator; - return methods; + copyConstructorProperties(WrappedError, OriginalError); + + try { + // Safari 13- bug: WebAssembly errors does not have a proper `.name` + if (OriginalErrorPrototype.name !== ERROR_NAME) { + createNonEnumerableProperty$1(OriginalErrorPrototype, 'name', ERROR_NAME); + } + OriginalErrorPrototype.constructor = WrappedError; + } catch (error) { /* empty */ } + + return WrappedError; }; -var toIndexedObject$1 = toIndexedObject$6; -var addToUnscopables = addToUnscopables$1; -var Iterators = iterators; -var InternalStateModule = internalState; -var defineProperty$1 = objectDefineProperty.f; -var defineIterator = defineIterator$1; -var DESCRIPTORS$3 = descriptors; +/* eslint-disable no-unused-vars -- required for functions `.length` */ -var ARRAY_ITERATOR = 'Array Iterator'; -var setInternalState = InternalStateModule.set; -var getInternalState$1 = InternalStateModule.getterFor(ARRAY_ITERATOR); +var $$c = _export; +var global$2 = global$g; +var apply$2 = functionApply; +var wrapErrorConstructorWithCause = wrapErrorConstructorWithCause$1; -// `Array.prototype.entries` method -// https://tc39.es/ecma262/#sec-array.prototype.entries -// `Array.prototype.keys` method -// https://tc39.es/ecma262/#sec-array.prototype.keys -// `Array.prototype.values` method -// https://tc39.es/ecma262/#sec-array.prototype.values -// `Array.prototype[@@iterator]` method -// https://tc39.es/ecma262/#sec-array.prototype-@@iterator -// `CreateArrayIterator` internal method -// https://tc39.es/ecma262/#sec-createarrayiterator -defineIterator(Array, 'Array', function (iterated, kind) { - setInternalState(this, { - type: ARRAY_ITERATOR, - target: toIndexedObject$1(iterated), // target - index: 0, // next index - kind: kind // kind - }); -// `%ArrayIteratorPrototype%.next` method -// https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next -}, function () { - var state = getInternalState$1(this); - var target = state.target; - var kind = state.kind; - var index = state.index++; - if (!target || index >= target.length) { - state.target = undefined; - return { value: undefined, done: true }; - } - if (kind == 'keys') return { value: index, done: false }; - if (kind == 'values') return { value: target[index], done: false }; - return { value: [index, target[index]], done: false }; -}, 'values'); +var WEB_ASSEMBLY = 'WebAssembly'; +var WebAssembly = global$2[WEB_ASSEMBLY]; -// argumentsList[@@iterator] is %ArrayProto_values% -// https://tc39.es/ecma262/#sec-createunmappedargumentsobject -// https://tc39.es/ecma262/#sec-createmappedargumentsobject -var values = Iterators.Arguments = Iterators.Array; +var FORCED$2 = Error('e', { cause: 7 }).cause !== 7; -// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables -addToUnscopables('keys'); -addToUnscopables('values'); -addToUnscopables('entries'); +var exportGlobalErrorCauseWrapper = function (ERROR_NAME, wrapper) { + var O = {}; + O[ERROR_NAME] = wrapErrorConstructorWithCause(ERROR_NAME, wrapper, FORCED$2); + $$c({ global: true, constructor: true, arity: 1, forced: FORCED$2 }, O); +}; -// V8 ~ Chrome 45- bug -if (DESCRIPTORS$3 && values.name !== 'values') try { - defineProperty$1(values, 'name', { value: 'values' }); -} catch (error) { /* empty */ } +var exportWebAssemblyErrorCauseWrapper = function (ERROR_NAME, wrapper) { + if (WebAssembly && WebAssembly[ERROR_NAME]) { + var O = {}; + O[ERROR_NAME] = wrapErrorConstructorWithCause(WEB_ASSEMBLY + '.' + ERROR_NAME, wrapper, FORCED$2); + $$c({ target: WEB_ASSEMBLY, stat: true, constructor: true, arity: 1, forced: FORCED$2 }, O); + } +}; + +// https://github.com/tc39/proposal-error-cause +exportGlobalErrorCauseWrapper('Error', function (init) { + return function Error(message) { return apply$2(init, this, arguments); }; +}); +exportGlobalErrorCauseWrapper('EvalError', function (init) { + return function EvalError(message) { return apply$2(init, this, arguments); }; +}); +exportGlobalErrorCauseWrapper('RangeError', function (init) { + return function RangeError(message) { return apply$2(init, this, arguments); }; +}); +exportGlobalErrorCauseWrapper('ReferenceError', function (init) { + return function ReferenceError(message) { return apply$2(init, this, arguments); }; +}); +exportGlobalErrorCauseWrapper('SyntaxError', function (init) { + return function SyntaxError(message) { return apply$2(init, this, arguments); }; +}); +exportGlobalErrorCauseWrapper('TypeError', function (init) { + return function TypeError(message) { return apply$2(init, this, arguments); }; +}); +exportGlobalErrorCauseWrapper('URIError', function (init) { + return function URIError(message) { return apply$2(init, this, arguments); }; +}); +exportWebAssemblyErrorCauseWrapper('CompileError', function (init) { + return function CompileError(message) { return apply$2(init, this, arguments); }; +}); +exportWebAssemblyErrorCauseWrapper('LinkError', function (init) { + return function LinkError(message) { return apply$2(init, this, arguments); }; +}); +exportWebAssemblyErrorCauseWrapper('RuntimeError', function (init) { + return function RuntimeError(message) { return apply$2(init, this, arguments); }; +}); // TODO: Remove from `core-js@4` since it's moved to entry points @@ -3388,7 +3398,7 @@ var setSpecies$1 = function (CONSTRUCTOR_NAME) { }; var DESCRIPTORS$1 = descriptors; -var global$1 = global$f; +var global$1 = global$g; var uncurryThis$2 = functionUncurryThis; var isForced = isForced_1; var inheritIfRequired = inheritIfRequired$2; @@ -9466,8 +9476,17 @@ setTimeout(function () { }, 0); const shell = global; -const target = global.target; +const target = new Proxy(global.target, { + set: function set(obj, prop, value) { + return Reflect.set(...arguments); + }, + get: function get(obj, prop, receiver) { + print(`make ${prop}`); + return Reflect.get(...arguments); + } +}); const SOURCES = ["packages", "codemods", "eslint"]; +const EslintArgs = ["eslint", "scripts", "benchmark", ...SOURCES, "*.{js,cjs,mjs,ts}", "--format", "codeframe", "--ext", ".js,.cjs,.mjs,.ts"]; const YARN_PATH = shell.which("yarn").stdout; const NODE_PATH = process.execPath; shell.config.verbose = true; @@ -9570,7 +9589,7 @@ target["bootstrap"] = function () { }; target["build"] = function () { - target["build-bundle"](); + target["build-no-bundle"](); if (process.env.BABEL_COVERAGE != "true") { target["build-standalone"](); @@ -9582,18 +9601,18 @@ target["build-standalone"] = function () { }; target["build-bundle"] = function () { - node(["scripts/set-module-type.js"]); target["clean"](); target["clean-lib"](); + node(["scripts/set-module-type.js"]); yarn(["gulp", "build"]); target["build-flow-typings"](); target["build-dist"](); }; target["build-no-bundle"] = function () { - node(["scripts/set-module-type.js"]); target["clean"](); target["clean-lib"](); + node(["scripts/set-module-type.js"]); env(() => { yarn(["gulp", "build-dev"]); }, { @@ -9615,6 +9634,17 @@ target["build-plugin-transform-runtime-dist"] = function () { node(["scripts/build-dist.js"], "packages/babel-plugin-transform-runtime"); }; +target["prepublish"] = function () { + target["bootstrap-only"](); + target["prepublish-build"](); + env(() => { + target["test"](); + }, { + IS_PUBLISH: "true" + }); + node(["scripts/set-module-type.js", "clean"]); +}; + target["prepublish-build"] = function () { target["clean-lib"](); target["clean-runtime-helpers"](); @@ -9664,17 +9694,17 @@ target["generate-type-helpers"] = function () { yarn(["gulp", "generate-type-helpers"]); }; -target["clone-license"] = function () { - node(["scripts/clone-license.js"]); -}; - target["build-typescript-legacy-typings"] = function () { require$$1.writeFileSync("packages/babel-types/lib/index-legacy.d.ts", node(["packages/babel-types/scripts/generators/typescript-legacy.js"], undefined, false)); }; +target["clone-license"] = function () { + node(["scripts/clone-license.js"]); +}; + target["lint"] = function () { env(() => { - yarn(["eslint", "scripts", "benchmark", ...SOURCES, "*.{js,cjs,mjs,ts}", "--format", "codeframe", "--ext", ".js,.cjs,.mjs,.ts"]); + yarn(EslintArgs); }, { BABEL_ENV: "test" }); @@ -9686,7 +9716,7 @@ target["fix"] = function () { }; target["fix-js"] = function () { - yarn(["eslint", "scripts", "benchmark", ...SOURCES, "*.{js,cjs,mjs,ts}", "--format", "codeframe", "--ext", ".js,.cjs,.mjs,.ts", "--fix"]); + yarn([...EslintArgs, "--fix"]); }; target["fix-json"] = function () { diff --git a/Makefile.source.mjs b/Makefile.source.mjs index fb3143d0c31d..d91f320785f6 100644 --- a/Makefile.source.mjs +++ b/Makefile.source.mjs @@ -7,10 +7,31 @@ import { writeFileSync } from "fs"; * @type {import("shelljs")} */ const shell = global; -const target = global.target; - +const target = new Proxy(global.target, { + // eslint-disable-next-line no-unused-vars + set: function (obj, prop, value) { + return Reflect.set(...arguments); + }, + // eslint-disable-next-line no-unused-vars + get: function (obj, prop, receiver) { + print(`make ${prop}`); + return Reflect.get(...arguments); + }, +}); const SOURCES = ["packages", "codemods", "eslint"]; +const EslintArgs = [ + "eslint", + "scripts", + "benchmark", + ...SOURCES, + "*.{js,cjs,mjs,ts}", + "--format", + "codeframe", + "--ext", + ".js,.cjs,.mjs,.ts", +]; + const YARN_PATH = shell.which("yarn").stdout; const NODE_PATH = process.execPath; // `yarn node` is so slow on Windows @@ -150,7 +171,7 @@ target["bootstrap"] = function () { }; target["build"] = function () { - target["build-bundle"](); + target["build-no-bundle"](); if (process.env.BABEL_COVERAGE != "true") { target["build-standalone"](); @@ -162,11 +183,11 @@ target["build-standalone"] = function () { }; target["build-bundle"] = function () { - node(["scripts/set-module-type.js"]); - target["clean"](); target["clean-lib"](); + node(["scripts/set-module-type.js"]); + yarn(["gulp", "build"]); target["build-flow-typings"](); @@ -174,11 +195,11 @@ target["build-bundle"] = function () { }; target["build-no-bundle"] = function () { - node(["scripts/set-module-type.js"]); - target["clean"](); target["clean-lib"](); + node(["scripts/set-module-type.js"]); + env( () => { yarn(["gulp", "build-dev"]); @@ -205,6 +226,22 @@ target["build-plugin-transform-runtime-dist"] = function () { node(["scripts/build-dist.js"], "packages/babel-plugin-transform-runtime"); }; +target["prepublish"] = function () { + target["bootstrap-only"](); + target["prepublish-build"](); + + env( + () => { + target["test"](); + }, + { + IS_PUBLISH: "true", + } + ); + + node(["scripts/set-module-type.js", "clean"]); +}; + target["prepublish-build"] = function () { target["clean-lib"](); target["clean-runtime-helpers"](); @@ -268,10 +305,6 @@ target["generate-type-helpers"] = function () { yarn(["gulp", "generate-type-helpers"]); }; -target["clone-license"] = function () { - node(["scripts/clone-license.js"]); -}; - target["build-typescript-legacy-typings"] = function () { writeFileSync( "packages/babel-types/lib/index-legacy.d.ts", @@ -283,6 +316,10 @@ target["build-typescript-legacy-typings"] = function () { ); }; +target["clone-license"] = function () { + node(["scripts/clone-license.js"]); +}; + /** * DEV */ @@ -290,17 +327,7 @@ target["build-typescript-legacy-typings"] = function () { target["lint"] = function () { env( () => { - yarn([ - "eslint", - "scripts", - "benchmark", - ...SOURCES, - "*.{js,cjs,mjs,ts}", - "--format", - "codeframe", - "--ext", - ".js,.cjs,.mjs,.ts", - ]); + yarn(EslintArgs); }, { BABEL_ENV: "test", @@ -314,18 +341,7 @@ target["fix"] = function () { }; target["fix-js"] = function () { - yarn([ - "eslint", - "scripts", - "benchmark", - ...SOURCES, - "*.{js,cjs,mjs,ts}", - "--format", - "codeframe", - "--ext", - ".js,.cjs,.mjs,.ts", - "--fix", - ]); + yarn([...EslintArgs, "--fix"]); }; target["fix-json"] = function () { @@ -366,8 +382,9 @@ target["test-only"] = function (args = []) { */ target["new-version-checklist"] = function () { + // eslint-disable-next-line no-constant-condition if (0) { - throw new Error( + console.log( ` !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -379,6 +396,8 @@ target["new-version-checklist"] = function () { !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! `.trim() ); + // eslint-disable-next-line no-process-exit + process.exit(1); } }; diff --git a/package.json b/package.json index e7ab632b50f3..c65b464164ae 100644 --- a/package.json +++ b/package.json @@ -98,7 +98,7 @@ "yarn": ">=1.4.0" }, "lint-staged": { - "*.{js,ts}": [ + "*.{js,cjs,mjs,ts}": [ "eslint --format=codeframe" ] }, From 565cad0049a3ea648249e108cd95f6fd6c24c564 Mon Sep 17 00:00:00 2001 From: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> Date: Tue, 26 Jul 2022 01:30:45 +0800 Subject: [PATCH 12/12] terser --- Makefile.js | 9757 +--------------------------------------- scripts/pack-script.js | 4 +- 2 files changed, 4 insertions(+), 9757 deletions(-) diff --git a/Makefile.js b/Makefile.js index 6126c1f89cef..c6c778fbb1f8 100644 --- a/Makefile.js +++ b/Makefile.js @@ -1,9758 +1,3 @@ /* eslint-disable */ //prettier-ignore - 'use strict'; - -var require$$0 = require('os'); -var require$$1 = require('fs'); -var require$$2 = require('path'); -var require$$4 = require('events'); -var require$$6 = require('assert'); -var require$$4$1 = require('util'); -var require$$0$1 = require('child_process'); - -function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } - -var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0); -var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1); -var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2); -var require$$4__default = /*#__PURE__*/_interopDefaultLegacy(require$$4); -var require$$6__default = /*#__PURE__*/_interopDefaultLegacy(require$$6); -var require$$4__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$4$1); -var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1); - -var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; - -var check = function (it) { - return it && it.Math == Math && it; -}; - -// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 -var global$g = - // eslint-disable-next-line es-x/no-global-this -- safe - check(typeof globalThis == 'object' && globalThis) || - check(typeof window == 'object' && window) || - // eslint-disable-next-line no-restricted-globals -- safe - check(typeof self == 'object' && self) || - check(typeof commonjsGlobal == 'object' && commonjsGlobal) || - // eslint-disable-next-line no-new-func -- fallback - (function () { return this; })() || Function('return this')(); - -var objectGetOwnPropertyDescriptor = {}; - -var fails$p = function (exec) { - try { - return !!exec(); - } catch (error) { - return true; - } -}; - -var fails$o = fails$p; - -// Detect IE8's incomplete defineProperty implementation -var descriptors = !fails$o(function () { - // eslint-disable-next-line es-x/no-object-defineproperty -- required for testing - return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7; -}); - -var fails$n = fails$p; - -var functionBindNative = !fails$n(function () { - // eslint-disable-next-line es-x/no-function-prototype-bind -- safe - var test = (function () { /* empty */ }).bind(); - // eslint-disable-next-line no-prototype-builtins -- safe - return typeof test != 'function' || test.hasOwnProperty('prototype'); -}); - -var NATIVE_BIND$3 = functionBindNative; - -var call$f = Function.prototype.call; - -var functionCall = NATIVE_BIND$3 ? call$f.bind(call$f) : function () { - return call$f.apply(call$f, arguments); -}; - -var objectPropertyIsEnumerable = {}; - -var $propertyIsEnumerable = {}.propertyIsEnumerable; -// eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe -var getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor; - -// Nashorn ~ JDK8 bug -var NASHORN_BUG = getOwnPropertyDescriptor$1 && !$propertyIsEnumerable.call({ 1: 2 }, 1); - -// `Object.prototype.propertyIsEnumerable` method implementation -// https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable -objectPropertyIsEnumerable.f = NASHORN_BUG ? function propertyIsEnumerable(V) { - var descriptor = getOwnPropertyDescriptor$1(this, V); - return !!descriptor && descriptor.enumerable; -} : $propertyIsEnumerable; - -var createPropertyDescriptor$5 = function (bitmap, value) { - return { - enumerable: !(bitmap & 1), - configurable: !(bitmap & 2), - writable: !(bitmap & 4), - value: value - }; -}; - -var NATIVE_BIND$2 = functionBindNative; - -var FunctionPrototype$2 = Function.prototype; -var bind$2 = FunctionPrototype$2.bind; -var call$e = FunctionPrototype$2.call; -var uncurryThis$s = NATIVE_BIND$2 && bind$2.bind(call$e, call$e); - -var functionUncurryThis = NATIVE_BIND$2 ? function (fn) { - return fn && uncurryThis$s(fn); -} : function (fn) { - return fn && function () { - return call$e.apply(fn, arguments); - }; -}; - -var uncurryThis$r = functionUncurryThis; - -var toString$c = uncurryThis$r({}.toString); -var stringSlice$7 = uncurryThis$r(''.slice); - -var classofRaw$1 = function (it) { - return stringSlice$7(toString$c(it), 8, -1); -}; - -var uncurryThis$q = functionUncurryThis; -var fails$m = fails$p; -var classof$7 = classofRaw$1; - -var $Object$4 = Object; -var split = uncurryThis$q(''.split); - -// fallback for non-array-like ES3 and non-enumerable old V8 strings -var indexedObject = fails$m(function () { - // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346 - // eslint-disable-next-line no-prototype-builtins -- safe - return !$Object$4('z').propertyIsEnumerable(0); -}) ? function (it) { - return classof$7(it) == 'String' ? split(it, '') : $Object$4(it); -} : $Object$4; - -var $TypeError$d = TypeError; - -// `RequireObjectCoercible` abstract operation -// https://tc39.es/ecma262/#sec-requireobjectcoercible -var requireObjectCoercible$8 = function (it) { - if (it == undefined) throw $TypeError$d("Can't call method on " + it); - return it; -}; - -// toObject with fallback for non-array-like ES3 strings -var IndexedObject$1 = indexedObject; -var requireObjectCoercible$7 = requireObjectCoercible$8; - -var toIndexedObject$6 = function (it) { - return IndexedObject$1(requireObjectCoercible$7(it)); -}; - -// `IsCallable` abstract operation -// https://tc39.es/ecma262/#sec-iscallable -var isCallable$m = function (argument) { - return typeof argument == 'function'; -}; - -var isCallable$l = isCallable$m; - -var isObject$d = function (it) { - return typeof it == 'object' ? it !== null : isCallable$l(it); -}; - -var global$f = global$g; -var isCallable$k = isCallable$m; - -var aFunction = function (argument) { - return isCallable$k(argument) ? argument : undefined; -}; - -var getBuiltIn$8 = function (namespace, method) { - return arguments.length < 2 ? aFunction(global$f[namespace]) : global$f[namespace] && global$f[namespace][method]; -}; - -var uncurryThis$p = functionUncurryThis; - -var objectIsPrototypeOf = uncurryThis$p({}.isPrototypeOf); - -var getBuiltIn$7 = getBuiltIn$8; - -var engineUserAgent = getBuiltIn$7('navigator', 'userAgent') || ''; - -var global$e = global$g; -var userAgent$2 = engineUserAgent; - -var process$1 = global$e.process; -var Deno = global$e.Deno; -var versions = process$1 && process$1.versions || Deno && Deno.version; -var v8 = versions && versions.v8; -var match, version; - -if (v8) { - match = v8.split('.'); - // in old Chrome, versions of V8 isn't V8 = Chrome / 10 - // but their correct versions are not interesting for us - version = match[0] > 0 && match[0] < 4 ? 1 : +(match[0] + match[1]); -} - -// BrowserFS NodeJS `process` polyfill incorrectly set `.v8` to `0.0` -// so check `userAgent` even if `.v8` exists, but 0 -if (!version && userAgent$2) { - match = userAgent$2.match(/Edge\/(\d+)/); - if (!match || match[1] >= 74) { - match = userAgent$2.match(/Chrome\/(\d+)/); - if (match) version = +match[1]; - } -} - -var engineV8Version = version; - -/* eslint-disable es-x/no-symbol -- required for testing */ - -var V8_VERSION$2 = engineV8Version; -var fails$l = fails$p; - -// eslint-disable-next-line es-x/no-object-getownpropertysymbols -- required for testing -var nativeSymbol = !!Object.getOwnPropertySymbols && !fails$l(function () { - var symbol = Symbol(); - // Chrome 38 Symbol has incorrect toString conversion - // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances - return !String(symbol) || !(Object(symbol) instanceof Symbol) || - // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances - !Symbol.sham && V8_VERSION$2 && V8_VERSION$2 < 41; -}); - -/* eslint-disable es-x/no-symbol -- required for testing */ - -var NATIVE_SYMBOL$2 = nativeSymbol; - -var useSymbolAsUid = NATIVE_SYMBOL$2 - && !Symbol.sham - && typeof Symbol.iterator == 'symbol'; - -var getBuiltIn$6 = getBuiltIn$8; -var isCallable$j = isCallable$m; -var isPrototypeOf$3 = objectIsPrototypeOf; -var USE_SYMBOL_AS_UID$1 = useSymbolAsUid; - -var $Object$3 = Object; - -var isSymbol$3 = USE_SYMBOL_AS_UID$1 ? function (it) { - return typeof it == 'symbol'; -} : function (it) { - var $Symbol = getBuiltIn$6('Symbol'); - return isCallable$j($Symbol) && isPrototypeOf$3($Symbol.prototype, $Object$3(it)); -}; - -var $String$3 = String; - -var tryToString$3 = function (argument) { - try { - return $String$3(argument); - } catch (error) { - return 'Object'; - } -}; - -var isCallable$i = isCallable$m; -var tryToString$2 = tryToString$3; - -var $TypeError$c = TypeError; - -// `Assert: IsCallable(argument) is true` -var aCallable$3 = function (argument) { - if (isCallable$i(argument)) return argument; - throw $TypeError$c(tryToString$2(argument) + ' is not a function'); -}; - -var aCallable$2 = aCallable$3; - -// `GetMethod` abstract operation -// https://tc39.es/ecma262/#sec-getmethod -var getMethod$5 = function (V, P) { - var func = V[P]; - return func == null ? undefined : aCallable$2(func); -}; - -var call$d = functionCall; -var isCallable$h = isCallable$m; -var isObject$c = isObject$d; - -var $TypeError$b = TypeError; - -// `OrdinaryToPrimitive` abstract operation -// https://tc39.es/ecma262/#sec-ordinarytoprimitive -var ordinaryToPrimitive$1 = function (input, pref) { - var fn, val; - if (pref === 'string' && isCallable$h(fn = input.toString) && !isObject$c(val = call$d(fn, input))) return val; - if (isCallable$h(fn = input.valueOf) && !isObject$c(val = call$d(fn, input))) return val; - if (pref !== 'string' && isCallable$h(fn = input.toString) && !isObject$c(val = call$d(fn, input))) return val; - throw $TypeError$b("Can't convert object to primitive value"); -}; - -var shared$4 = {exports: {}}; - -var global$d = global$g; - -// eslint-disable-next-line es-x/no-object-defineproperty -- safe -var defineProperty$6 = Object.defineProperty; - -var defineGlobalProperty$3 = function (key, value) { - try { - defineProperty$6(global$d, key, { value: value, configurable: true, writable: true }); - } catch (error) { - global$d[key] = value; - } return value; -}; - -var global$c = global$g; -var defineGlobalProperty$2 = defineGlobalProperty$3; - -var SHARED = '__core-js_shared__'; -var store$3 = global$c[SHARED] || defineGlobalProperty$2(SHARED, {}); - -var sharedStore = store$3; - -var store$2 = sharedStore; - -(shared$4.exports = function (key, value) { - return store$2[key] || (store$2[key] = value !== undefined ? value : {}); -})('versions', []).push({ - version: '3.23.4', - mode: 'global', - copyright: '© 2014-2022 Denis Pushkarev (zloirock.ru)', - license: 'https://github.com/zloirock/core-js/blob/v3.23.4/LICENSE', - source: 'https://github.com/zloirock/core-js' -}); - -var requireObjectCoercible$6 = requireObjectCoercible$8; - -var $Object$2 = Object; - -// `ToObject` abstract operation -// https://tc39.es/ecma262/#sec-toobject -var toObject$7 = function (argument) { - return $Object$2(requireObjectCoercible$6(argument)); -}; - -var uncurryThis$o = functionUncurryThis; -var toObject$6 = toObject$7; - -var hasOwnProperty = uncurryThis$o({}.hasOwnProperty); - -// `HasOwnProperty` abstract operation -// https://tc39.es/ecma262/#sec-hasownproperty -// eslint-disable-next-line es-x/no-object-hasown -- safe -var hasOwnProperty_1 = Object.hasOwn || function hasOwn(it, key) { - return hasOwnProperty(toObject$6(it), key); -}; - -var uncurryThis$n = functionUncurryThis; - -var id = 0; -var postfix = Math.random(); -var toString$b = uncurryThis$n(1.0.toString); - -var uid$2 = function (key) { - return 'Symbol(' + (key === undefined ? '' : key) + ')_' + toString$b(++id + postfix, 36); -}; - -var global$b = global$g; -var shared$3 = shared$4.exports; -var hasOwn$b = hasOwnProperty_1; -var uid$1 = uid$2; -var NATIVE_SYMBOL$1 = nativeSymbol; -var USE_SYMBOL_AS_UID = useSymbolAsUid; - -var WellKnownSymbolsStore = shared$3('wks'); -var Symbol$1 = global$b.Symbol; -var symbolFor = Symbol$1 && Symbol$1['for']; -var createWellKnownSymbol = USE_SYMBOL_AS_UID ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid$1; - -var wellKnownSymbol$i = function (name) { - if (!hasOwn$b(WellKnownSymbolsStore, name) || !(NATIVE_SYMBOL$1 || typeof WellKnownSymbolsStore[name] == 'string')) { - var description = 'Symbol.' + name; - if (NATIVE_SYMBOL$1 && hasOwn$b(Symbol$1, name)) { - WellKnownSymbolsStore[name] = Symbol$1[name]; - } else if (USE_SYMBOL_AS_UID && symbolFor) { - WellKnownSymbolsStore[name] = symbolFor(description); - } else { - WellKnownSymbolsStore[name] = createWellKnownSymbol(description); - } - } return WellKnownSymbolsStore[name]; -}; - -var call$c = functionCall; -var isObject$b = isObject$d; -var isSymbol$2 = isSymbol$3; -var getMethod$4 = getMethod$5; -var ordinaryToPrimitive = ordinaryToPrimitive$1; -var wellKnownSymbol$h = wellKnownSymbol$i; - -var $TypeError$a = TypeError; -var TO_PRIMITIVE = wellKnownSymbol$h('toPrimitive'); - -// `ToPrimitive` abstract operation -// https://tc39.es/ecma262/#sec-toprimitive -var toPrimitive$1 = function (input, pref) { - if (!isObject$b(input) || isSymbol$2(input)) return input; - var exoticToPrim = getMethod$4(input, TO_PRIMITIVE); - var result; - if (exoticToPrim) { - if (pref === undefined) pref = 'default'; - result = call$c(exoticToPrim, input, pref); - if (!isObject$b(result) || isSymbol$2(result)) return result; - throw $TypeError$a("Can't convert object to primitive value"); - } - if (pref === undefined) pref = 'number'; - return ordinaryToPrimitive(input, pref); -}; - -var toPrimitive = toPrimitive$1; -var isSymbol$1 = isSymbol$3; - -// `ToPropertyKey` abstract operation -// https://tc39.es/ecma262/#sec-topropertykey -var toPropertyKey$3 = function (argument) { - var key = toPrimitive(argument, 'string'); - return isSymbol$1(key) ? key : key + ''; -}; - -var global$a = global$g; -var isObject$a = isObject$d; - -var document$1 = global$a.document; -// typeof document.createElement is 'object' in old IE -var EXISTS$1 = isObject$a(document$1) && isObject$a(document$1.createElement); - -var documentCreateElement$1 = function (it) { - return EXISTS$1 ? document$1.createElement(it) : {}; -}; - -var DESCRIPTORS$c = descriptors; -var fails$k = fails$p; -var createElement = documentCreateElement$1; - -// Thanks to IE8 for its funny defineProperty -var ie8DomDefine = !DESCRIPTORS$c && !fails$k(function () { - // eslint-disable-next-line es-x/no-object-defineproperty -- required for testing - return Object.defineProperty(createElement('div'), 'a', { - get: function () { return 7; } - }).a != 7; -}); - -var DESCRIPTORS$b = descriptors; -var call$b = functionCall; -var propertyIsEnumerableModule = objectPropertyIsEnumerable; -var createPropertyDescriptor$4 = createPropertyDescriptor$5; -var toIndexedObject$5 = toIndexedObject$6; -var toPropertyKey$2 = toPropertyKey$3; -var hasOwn$a = hasOwnProperty_1; -var IE8_DOM_DEFINE$1 = ie8DomDefine; - -// eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe -var $getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor; - -// `Object.getOwnPropertyDescriptor` method -// https://tc39.es/ecma262/#sec-object.getownpropertydescriptor -objectGetOwnPropertyDescriptor.f = DESCRIPTORS$b ? $getOwnPropertyDescriptor$1 : function getOwnPropertyDescriptor(O, P) { - O = toIndexedObject$5(O); - P = toPropertyKey$2(P); - if (IE8_DOM_DEFINE$1) try { - return $getOwnPropertyDescriptor$1(O, P); - } catch (error) { /* empty */ } - if (hasOwn$a(O, P)) return createPropertyDescriptor$4(!call$b(propertyIsEnumerableModule.f, O, P), O[P]); -}; - -var objectDefineProperty = {}; - -var DESCRIPTORS$a = descriptors; -var fails$j = fails$p; - -// V8 ~ Chrome 36- -// https://bugs.chromium.org/p/v8/issues/detail?id=3334 -var v8PrototypeDefineBug = DESCRIPTORS$a && fails$j(function () { - // eslint-disable-next-line es-x/no-object-defineproperty -- required for testing - return Object.defineProperty(function () { /* empty */ }, 'prototype', { - value: 42, - writable: false - }).prototype != 42; -}); - -var isObject$9 = isObject$d; - -var $String$2 = String; -var $TypeError$9 = TypeError; - -// `Assert: Type(argument) is Object` -var anObject$b = function (argument) { - if (isObject$9(argument)) return argument; - throw $TypeError$9($String$2(argument) + ' is not an object'); -}; - -var DESCRIPTORS$9 = descriptors; -var IE8_DOM_DEFINE = ie8DomDefine; -var V8_PROTOTYPE_DEFINE_BUG$1 = v8PrototypeDefineBug; -var anObject$a = anObject$b; -var toPropertyKey$1 = toPropertyKey$3; - -var $TypeError$8 = TypeError; -// eslint-disable-next-line es-x/no-object-defineproperty -- safe -var $defineProperty = Object.defineProperty; -// eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe -var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; -var ENUMERABLE = 'enumerable'; -var CONFIGURABLE$1 = 'configurable'; -var WRITABLE = 'writable'; - -// `Object.defineProperty` method -// https://tc39.es/ecma262/#sec-object.defineproperty -objectDefineProperty.f = DESCRIPTORS$9 ? V8_PROTOTYPE_DEFINE_BUG$1 ? function defineProperty(O, P, Attributes) { - anObject$a(O); - P = toPropertyKey$1(P); - anObject$a(Attributes); - if (typeof O === 'function' && P === 'prototype' && 'value' in Attributes && WRITABLE in Attributes && !Attributes[WRITABLE]) { - var current = $getOwnPropertyDescriptor(O, P); - if (current && current[WRITABLE]) { - O[P] = Attributes.value; - Attributes = { - configurable: CONFIGURABLE$1 in Attributes ? Attributes[CONFIGURABLE$1] : current[CONFIGURABLE$1], - enumerable: ENUMERABLE in Attributes ? Attributes[ENUMERABLE] : current[ENUMERABLE], - writable: false - }; - } - } return $defineProperty(O, P, Attributes); -} : $defineProperty : function defineProperty(O, P, Attributes) { - anObject$a(O); - P = toPropertyKey$1(P); - anObject$a(Attributes); - if (IE8_DOM_DEFINE) try { - return $defineProperty(O, P, Attributes); - } catch (error) { /* empty */ } - if ('get' in Attributes || 'set' in Attributes) throw $TypeError$8('Accessors not supported'); - if ('value' in Attributes) O[P] = Attributes.value; - return O; -}; - -var DESCRIPTORS$8 = descriptors; -var definePropertyModule$5 = objectDefineProperty; -var createPropertyDescriptor$3 = createPropertyDescriptor$5; - -var createNonEnumerableProperty$7 = DESCRIPTORS$8 ? function (object, key, value) { - return definePropertyModule$5.f(object, key, createPropertyDescriptor$3(1, value)); -} : function (object, key, value) { - object[key] = value; - return object; -}; - -var makeBuiltIn$3 = {exports: {}}; - -var DESCRIPTORS$7 = descriptors; -var hasOwn$9 = hasOwnProperty_1; - -var FunctionPrototype$1 = Function.prototype; -// eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe -var getDescriptor = DESCRIPTORS$7 && Object.getOwnPropertyDescriptor; - -var EXISTS = hasOwn$9(FunctionPrototype$1, 'name'); -// additional protection from minified / mangled / dropped function names -var PROPER = EXISTS && (function something() { /* empty */ }).name === 'something'; -var CONFIGURABLE = EXISTS && (!DESCRIPTORS$7 || (DESCRIPTORS$7 && getDescriptor(FunctionPrototype$1, 'name').configurable)); - -var functionName = { - EXISTS: EXISTS, - PROPER: PROPER, - CONFIGURABLE: CONFIGURABLE -}; - -var uncurryThis$m = functionUncurryThis; -var isCallable$g = isCallable$m; -var store$1 = sharedStore; - -var functionToString = uncurryThis$m(Function.toString); - -// this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper -if (!isCallable$g(store$1.inspectSource)) { - store$1.inspectSource = function (it) { - return functionToString(it); - }; -} - -var inspectSource$3 = store$1.inspectSource; - -var global$9 = global$g; -var isCallable$f = isCallable$m; -var inspectSource$2 = inspectSource$3; - -var WeakMap$1 = global$9.WeakMap; - -var nativeWeakMap = isCallable$f(WeakMap$1) && /native code/.test(inspectSource$2(WeakMap$1)); - -var shared$2 = shared$4.exports; -var uid = uid$2; - -var keys$1 = shared$2('keys'); - -var sharedKey$3 = function (key) { - return keys$1[key] || (keys$1[key] = uid(key)); -}; - -var hiddenKeys$4 = {}; - -var NATIVE_WEAK_MAP = nativeWeakMap; -var global$8 = global$g; -var uncurryThis$l = functionUncurryThis; -var isObject$8 = isObject$d; -var createNonEnumerableProperty$6 = createNonEnumerableProperty$7; -var hasOwn$8 = hasOwnProperty_1; -var shared$1 = sharedStore; -var sharedKey$2 = sharedKey$3; -var hiddenKeys$3 = hiddenKeys$4; - -var OBJECT_ALREADY_INITIALIZED = 'Object already initialized'; -var TypeError$1 = global$8.TypeError; -var WeakMap = global$8.WeakMap; -var set$1, get, has; - -var enforce = function (it) { - return has(it) ? get(it) : set$1(it, {}); -}; - -var getterFor = function (TYPE) { - return function (it) { - var state; - if (!isObject$8(it) || (state = get(it)).type !== TYPE) { - throw TypeError$1('Incompatible receiver, ' + TYPE + ' required'); - } return state; - }; -}; - -if (NATIVE_WEAK_MAP || shared$1.state) { - var store = shared$1.state || (shared$1.state = new WeakMap()); - var wmget = uncurryThis$l(store.get); - var wmhas = uncurryThis$l(store.has); - var wmset = uncurryThis$l(store.set); - set$1 = function (it, metadata) { - if (wmhas(store, it)) throw new TypeError$1(OBJECT_ALREADY_INITIALIZED); - metadata.facade = it; - wmset(store, it, metadata); - return metadata; - }; - get = function (it) { - return wmget(store, it) || {}; - }; - has = function (it) { - return wmhas(store, it); - }; -} else { - var STATE = sharedKey$2('state'); - hiddenKeys$3[STATE] = true; - set$1 = function (it, metadata) { - if (hasOwn$8(it, STATE)) throw new TypeError$1(OBJECT_ALREADY_INITIALIZED); - metadata.facade = it; - createNonEnumerableProperty$6(it, STATE, metadata); - return metadata; - }; - get = function (it) { - return hasOwn$8(it, STATE) ? it[STATE] : {}; - }; - has = function (it) { - return hasOwn$8(it, STATE); - }; -} - -var internalState = { - set: set$1, - get: get, - has: has, - enforce: enforce, - getterFor: getterFor -}; - -var fails$i = fails$p; -var isCallable$e = isCallable$m; -var hasOwn$7 = hasOwnProperty_1; -var DESCRIPTORS$6 = descriptors; -var CONFIGURABLE_FUNCTION_NAME$1 = functionName.CONFIGURABLE; -var inspectSource$1 = inspectSource$3; -var InternalStateModule$1 = internalState; - -var enforceInternalState$1 = InternalStateModule$1.enforce; -var getInternalState$3 = InternalStateModule$1.get; -// eslint-disable-next-line es-x/no-object-defineproperty -- safe -var defineProperty$5 = Object.defineProperty; - -var CONFIGURABLE_LENGTH = DESCRIPTORS$6 && !fails$i(function () { - return defineProperty$5(function () { /* empty */ }, 'length', { value: 8 }).length !== 8; -}); - -var TEMPLATE = String(String).split('String'); - -var makeBuiltIn$2 = makeBuiltIn$3.exports = function (value, name, options) { - if (String(name).slice(0, 7) === 'Symbol(') { - name = '[' + String(name).replace(/^Symbol\(([^)]*)\)/, '$1') + ']'; - } - if (options && options.getter) name = 'get ' + name; - if (options && options.setter) name = 'set ' + name; - if (!hasOwn$7(value, 'name') || (CONFIGURABLE_FUNCTION_NAME$1 && value.name !== name)) { - if (DESCRIPTORS$6) defineProperty$5(value, 'name', { value: name, configurable: true }); - else value.name = name; - } - if (CONFIGURABLE_LENGTH && options && hasOwn$7(options, 'arity') && value.length !== options.arity) { - defineProperty$5(value, 'length', { value: options.arity }); - } - try { - if (options && hasOwn$7(options, 'constructor') && options.constructor) { - if (DESCRIPTORS$6) defineProperty$5(value, 'prototype', { writable: false }); - // in V8 ~ Chrome 53, prototypes of some methods, like `Array.prototype.values`, are non-writable - } else if (value.prototype) value.prototype = undefined; - } catch (error) { /* empty */ } - var state = enforceInternalState$1(value); - if (!hasOwn$7(state, 'source')) { - state.source = TEMPLATE.join(typeof name == 'string' ? name : ''); - } return value; -}; - -// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative -// eslint-disable-next-line no-extend-native -- required -Function.prototype.toString = makeBuiltIn$2(function toString() { - return isCallable$e(this) && getInternalState$3(this).source || inspectSource$1(this); -}, 'toString'); - -var isCallable$d = isCallable$m; -var definePropertyModule$4 = objectDefineProperty; -var makeBuiltIn$1 = makeBuiltIn$3.exports; -var defineGlobalProperty$1 = defineGlobalProperty$3; - -var defineBuiltIn$5 = function (O, key, value, options) { - if (!options) options = {}; - var simple = options.enumerable; - var name = options.name !== undefined ? options.name : key; - if (isCallable$d(value)) makeBuiltIn$1(value, name, options); - if (options.global) { - if (simple) O[key] = value; - else defineGlobalProperty$1(key, value); - } else { - try { - if (!options.unsafe) delete O[key]; - else if (O[key]) simple = true; - } catch (error) { /* empty */ } - if (simple) O[key] = value; - else definePropertyModule$4.f(O, key, { - value: value, - enumerable: false, - configurable: !options.nonConfigurable, - writable: !options.nonWritable - }); - } return O; -}; - -var objectGetOwnPropertyNames = {}; - -var ceil = Math.ceil; -var floor$2 = Math.floor; - -// `Math.trunc` method -// https://tc39.es/ecma262/#sec-math.trunc -// eslint-disable-next-line es-x/no-math-trunc -- safe -var mathTrunc = Math.trunc || function trunc(x) { - var n = +x; - return (n > 0 ? floor$2 : ceil)(n); -}; - -var trunc = mathTrunc; - -// `ToIntegerOrInfinity` abstract operation -// https://tc39.es/ecma262/#sec-tointegerorinfinity -var toIntegerOrInfinity$5 = function (argument) { - var number = +argument; - // eslint-disable-next-line no-self-compare -- NaN check - return number !== number || number === 0 ? 0 : trunc(number); -}; - -var toIntegerOrInfinity$4 = toIntegerOrInfinity$5; - -var max$5 = Math.max; -var min$4 = Math.min; - -// Helper for a popular repeating case of the spec: -// Let integer be ? ToInteger(index). -// If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length). -var toAbsoluteIndex$4 = function (index, length) { - var integer = toIntegerOrInfinity$4(index); - return integer < 0 ? max$5(integer + length, 0) : min$4(integer, length); -}; - -var toIntegerOrInfinity$3 = toIntegerOrInfinity$5; - -var min$3 = Math.min; - -// `ToLength` abstract operation -// https://tc39.es/ecma262/#sec-tolength -var toLength$4 = function (argument) { - return argument > 0 ? min$3(toIntegerOrInfinity$3(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991 -}; - -var toLength$3 = toLength$4; - -// `LengthOfArrayLike` abstract operation -// https://tc39.es/ecma262/#sec-lengthofarraylike -var lengthOfArrayLike$7 = function (obj) { - return toLength$3(obj.length); -}; - -var toIndexedObject$4 = toIndexedObject$6; -var toAbsoluteIndex$3 = toAbsoluteIndex$4; -var lengthOfArrayLike$6 = lengthOfArrayLike$7; - -// `Array.prototype.{ indexOf, includes }` methods implementation -var createMethod$3 = function (IS_INCLUDES) { - return function ($this, el, fromIndex) { - var O = toIndexedObject$4($this); - var length = lengthOfArrayLike$6(O); - var index = toAbsoluteIndex$3(fromIndex, length); - var value; - // Array#includes uses SameValueZero equality algorithm - // eslint-disable-next-line no-self-compare -- NaN check - if (IS_INCLUDES && el != el) while (length > index) { - value = O[index++]; - // eslint-disable-next-line no-self-compare -- NaN check - if (value != value) return true; - // Array#indexOf ignores holes, Array#includes - not - } else for (;length > index; index++) { - if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0; - } return !IS_INCLUDES && -1; - }; -}; - -var arrayIncludes = { - // `Array.prototype.includes` method - // https://tc39.es/ecma262/#sec-array.prototype.includes - includes: createMethod$3(true), - // `Array.prototype.indexOf` method - // https://tc39.es/ecma262/#sec-array.prototype.indexof - indexOf: createMethod$3(false) -}; - -var uncurryThis$k = functionUncurryThis; -var hasOwn$6 = hasOwnProperty_1; -var toIndexedObject$3 = toIndexedObject$6; -var indexOf$2 = arrayIncludes.indexOf; -var hiddenKeys$2 = hiddenKeys$4; - -var push$4 = uncurryThis$k([].push); - -var objectKeysInternal = function (object, names) { - var O = toIndexedObject$3(object); - var i = 0; - var result = []; - var key; - for (key in O) !hasOwn$6(hiddenKeys$2, key) && hasOwn$6(O, key) && push$4(result, key); - // Don't enum bug & hidden keys - while (names.length > i) if (hasOwn$6(O, key = names[i++])) { - ~indexOf$2(result, key) || push$4(result, key); - } - return result; -}; - -// IE8- don't enum bug keys -var enumBugKeys$3 = [ - 'constructor', - 'hasOwnProperty', - 'isPrototypeOf', - 'propertyIsEnumerable', - 'toLocaleString', - 'toString', - 'valueOf' -]; - -var internalObjectKeys$1 = objectKeysInternal; -var enumBugKeys$2 = enumBugKeys$3; - -var hiddenKeys$1 = enumBugKeys$2.concat('length', 'prototype'); - -// `Object.getOwnPropertyNames` method -// https://tc39.es/ecma262/#sec-object.getownpropertynames -// eslint-disable-next-line es-x/no-object-getownpropertynames -- safe -objectGetOwnPropertyNames.f = Object.getOwnPropertyNames || function getOwnPropertyNames(O) { - return internalObjectKeys$1(O, hiddenKeys$1); -}; - -var objectGetOwnPropertySymbols = {}; - -// eslint-disable-next-line es-x/no-object-getownpropertysymbols -- safe -objectGetOwnPropertySymbols.f = Object.getOwnPropertySymbols; - -var getBuiltIn$5 = getBuiltIn$8; -var uncurryThis$j = functionUncurryThis; -var getOwnPropertyNamesModule = objectGetOwnPropertyNames; -var getOwnPropertySymbolsModule = objectGetOwnPropertySymbols; -var anObject$9 = anObject$b; - -var concat$1 = uncurryThis$j([].concat); - -// all object keys, includes non-enumerable and symbols -var ownKeys$1 = getBuiltIn$5('Reflect', 'ownKeys') || function ownKeys(it) { - var keys = getOwnPropertyNamesModule.f(anObject$9(it)); - var getOwnPropertySymbols = getOwnPropertySymbolsModule.f; - return getOwnPropertySymbols ? concat$1(keys, getOwnPropertySymbols(it)) : keys; -}; - -var hasOwn$5 = hasOwnProperty_1; -var ownKeys = ownKeys$1; -var getOwnPropertyDescriptorModule = objectGetOwnPropertyDescriptor; -var definePropertyModule$3 = objectDefineProperty; - -var copyConstructorProperties$2 = function (target, source, exceptions) { - var keys = ownKeys(source); - var defineProperty = definePropertyModule$3.f; - var getOwnPropertyDescriptor = getOwnPropertyDescriptorModule.f; - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; - if (!hasOwn$5(target, key) && !(exceptions && hasOwn$5(exceptions, key))) { - defineProperty(target, key, getOwnPropertyDescriptor(source, key)); - } - } -}; - -var fails$h = fails$p; -var isCallable$c = isCallable$m; - -var replacement = /#|\.prototype\./; - -var isForced$2 = function (feature, detection) { - var value = data[normalize$1(feature)]; - return value == POLYFILL ? true - : value == NATIVE ? false - : isCallable$c(detection) ? fails$h(detection) - : !!detection; -}; - -var normalize$1 = isForced$2.normalize = function (string) { - return String(string).replace(replacement, '.').toLowerCase(); -}; - -var data = isForced$2.data = {}; -var NATIVE = isForced$2.NATIVE = 'N'; -var POLYFILL = isForced$2.POLYFILL = 'P'; - -var isForced_1 = isForced$2; - -var global$7 = global$g; -var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f; -var createNonEnumerableProperty$5 = createNonEnumerableProperty$7; -var defineBuiltIn$4 = defineBuiltIn$5; -var defineGlobalProperty = defineGlobalProperty$3; -var copyConstructorProperties$1 = copyConstructorProperties$2; -var isForced$1 = isForced_1; - -/* - options.target - name of the target object - options.global - target is the global object - options.stat - export as static methods of target - options.proto - export as prototype methods of target - options.real - real prototype method for the `pure` version - options.forced - export even if the native feature is available - options.bind - bind methods to the target, required for the `pure` version - options.wrap - wrap constructors to preventing global pollution, required for the `pure` version - options.unsafe - use the simple assignment of property instead of delete + defineProperty - options.sham - add a flag to not completely full polyfills - options.enumerable - export as enumerable property - options.dontCallGetSet - prevent calling a getter on target - options.name - the .name of the function if it does not match the key -*/ -var _export = function (options, source) { - var TARGET = options.target; - var GLOBAL = options.global; - var STATIC = options.stat; - var FORCED, target, key, targetProperty, sourceProperty, descriptor; - if (GLOBAL) { - target = global$7; - } else if (STATIC) { - target = global$7[TARGET] || defineGlobalProperty(TARGET, {}); - } else { - target = (global$7[TARGET] || {}).prototype; - } - if (target) for (key in source) { - sourceProperty = source[key]; - if (options.dontCallGetSet) { - descriptor = getOwnPropertyDescriptor(target, key); - targetProperty = descriptor && descriptor.value; - } else targetProperty = target[key]; - FORCED = isForced$1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced); - // contained in target - if (!FORCED && targetProperty !== undefined) { - if (typeof sourceProperty == typeof targetProperty) continue; - copyConstructorProperties$1(sourceProperty, targetProperty); - } - // add a flag to not completely full polyfills - if (options.sham || (targetProperty && targetProperty.sham)) { - createNonEnumerableProperty$5(sourceProperty, 'sham', true); - } - defineBuiltIn$4(target, key, sourceProperty, options); - } -}; - -var defineProperty$4 = objectDefineProperty.f; -var hasOwn$4 = hasOwnProperty_1; -var wellKnownSymbol$g = wellKnownSymbol$i; - -var TO_STRING_TAG$2 = wellKnownSymbol$g('toStringTag'); - -var setToStringTag$3 = function (target, TAG, STATIC) { - if (target && !STATIC) target = target.prototype; - if (target && !hasOwn$4(target, TO_STRING_TAG$2)) { - defineProperty$4(target, TO_STRING_TAG$2, { configurable: true, value: TAG }); - } -}; - -var $$g = _export; -var global$6 = global$g; -var setToStringTag$2 = setToStringTag$3; - -$$g({ global: true }, { Reflect: {} }); - -// Reflect[@@toStringTag] property -// https://tc39.es/ecma262/#sec-reflect-@@tostringtag -setToStringTag$2(global$6.Reflect, 'Reflect', true); - -var objectDefineProperties = {}; - -var internalObjectKeys = objectKeysInternal; -var enumBugKeys$1 = enumBugKeys$3; - -// `Object.keys` method -// https://tc39.es/ecma262/#sec-object.keys -// eslint-disable-next-line es-x/no-object-keys -- safe -var objectKeys$1 = Object.keys || function keys(O) { - return internalObjectKeys(O, enumBugKeys$1); -}; - -var DESCRIPTORS$5 = descriptors; -var V8_PROTOTYPE_DEFINE_BUG = v8PrototypeDefineBug; -var definePropertyModule$2 = objectDefineProperty; -var anObject$8 = anObject$b; -var toIndexedObject$2 = toIndexedObject$6; -var objectKeys = objectKeys$1; - -// `Object.defineProperties` method -// https://tc39.es/ecma262/#sec-object.defineproperties -// eslint-disable-next-line es-x/no-object-defineproperties -- safe -objectDefineProperties.f = DESCRIPTORS$5 && !V8_PROTOTYPE_DEFINE_BUG ? Object.defineProperties : function defineProperties(O, Properties) { - anObject$8(O); - var props = toIndexedObject$2(Properties); - var keys = objectKeys(Properties); - var length = keys.length; - var index = 0; - var key; - while (length > index) definePropertyModule$2.f(O, key = keys[index++], props[key]); - return O; -}; - -var getBuiltIn$4 = getBuiltIn$8; - -var html$1 = getBuiltIn$4('document', 'documentElement'); - -/* global ActiveXObject -- old IE, WSH */ - -var anObject$7 = anObject$b; -var definePropertiesModule = objectDefineProperties; -var enumBugKeys = enumBugKeys$3; -var hiddenKeys = hiddenKeys$4; -var html = html$1; -var documentCreateElement = documentCreateElement$1; -var sharedKey$1 = sharedKey$3; - -var GT = '>'; -var LT = '<'; -var PROTOTYPE = 'prototype'; -var SCRIPT = 'script'; -var IE_PROTO$1 = sharedKey$1('IE_PROTO'); - -var EmptyConstructor = function () { /* empty */ }; - -var scriptTag = function (content) { - return LT + SCRIPT + GT + content + LT + '/' + SCRIPT + GT; -}; - -// Create object with fake `null` prototype: use ActiveX Object with cleared prototype -var NullProtoObjectViaActiveX = function (activeXDocument) { - activeXDocument.write(scriptTag('')); - activeXDocument.close(); - var temp = activeXDocument.parentWindow.Object; - activeXDocument = null; // avoid memory leak - return temp; -}; - -// Create object with fake `null` prototype: use iframe Object with cleared prototype -var NullProtoObjectViaIFrame = function () { - // Thrash, waste and sodomy: IE GC bug - var iframe = documentCreateElement('iframe'); - var JS = 'java' + SCRIPT + ':'; - var iframeDocument; - iframe.style.display = 'none'; - html.appendChild(iframe); - // https://github.com/zloirock/core-js/issues/475 - iframe.src = String(JS); - iframeDocument = iframe.contentWindow.document; - iframeDocument.open(); - iframeDocument.write(scriptTag('document.F=Object')); - iframeDocument.close(); - return iframeDocument.F; -}; - -// Check for document.domain and active x support -// No need to use active x approach when document.domain is not set -// see https://github.com/es-shims/es5-shim/issues/150 -// variation of https://github.com/kitcambridge/es5-shim/commit/4f738ac066346 -// avoid IE GC bug -var activeXDocument; -var NullProtoObject = function () { - try { - activeXDocument = new ActiveXObject('htmlfile'); - } catch (error) { /* ignore */ } - NullProtoObject = typeof document != 'undefined' - ? document.domain && activeXDocument - ? NullProtoObjectViaActiveX(activeXDocument) // old IE - : NullProtoObjectViaIFrame() - : NullProtoObjectViaActiveX(activeXDocument); // WSH - var length = enumBugKeys.length; - while (length--) delete NullProtoObject[PROTOTYPE][enumBugKeys[length]]; - return NullProtoObject(); -}; - -hiddenKeys[IE_PROTO$1] = true; - -// `Object.create` method -// https://tc39.es/ecma262/#sec-object.create -// eslint-disable-next-line es-x/no-object-create -- safe -var objectCreate = Object.create || function create(O, Properties) { - var result; - if (O !== null) { - EmptyConstructor[PROTOTYPE] = anObject$7(O); - result = new EmptyConstructor(); - EmptyConstructor[PROTOTYPE] = null; - // add "__proto__" for Object.getPrototypeOf polyfill - result[IE_PROTO$1] = O; - } else result = NullProtoObject(); - return Properties === undefined ? result : definePropertiesModule.f(result, Properties); -}; - -var wellKnownSymbol$f = wellKnownSymbol$i; -var create$2 = objectCreate; -var defineProperty$3 = objectDefineProperty.f; - -var UNSCOPABLES = wellKnownSymbol$f('unscopables'); -var ArrayPrototype = Array.prototype; - -// Array.prototype[@@unscopables] -// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables -if (ArrayPrototype[UNSCOPABLES] == undefined) { - defineProperty$3(ArrayPrototype, UNSCOPABLES, { - configurable: true, - value: create$2(null) - }); -} - -// add a key to Array.prototype[@@unscopables] -var addToUnscopables$1 = function (key) { - ArrayPrototype[UNSCOPABLES][key] = true; -}; - -var iterators = {}; - -var fails$g = fails$p; - -var correctPrototypeGetter = !fails$g(function () { - function F() { /* empty */ } - F.prototype.constructor = null; - // eslint-disable-next-line es-x/no-object-getprototypeof -- required for testing - return Object.getPrototypeOf(new F()) !== F.prototype; -}); - -var hasOwn$3 = hasOwnProperty_1; -var isCallable$b = isCallable$m; -var toObject$5 = toObject$7; -var sharedKey = sharedKey$3; -var CORRECT_PROTOTYPE_GETTER = correctPrototypeGetter; - -var IE_PROTO = sharedKey('IE_PROTO'); -var $Object$1 = Object; -var ObjectPrototype = $Object$1.prototype; - -// `Object.getPrototypeOf` method -// https://tc39.es/ecma262/#sec-object.getprototypeof -// eslint-disable-next-line es-x/no-object-getprototypeof -- safe -var objectGetPrototypeOf = CORRECT_PROTOTYPE_GETTER ? $Object$1.getPrototypeOf : function (O) { - var object = toObject$5(O); - if (hasOwn$3(object, IE_PROTO)) return object[IE_PROTO]; - var constructor = object.constructor; - if (isCallable$b(constructor) && object instanceof constructor) { - return constructor.prototype; - } return object instanceof $Object$1 ? ObjectPrototype : null; -}; - -var fails$f = fails$p; -var isCallable$a = isCallable$m; -var getPrototypeOf$1 = objectGetPrototypeOf; -var defineBuiltIn$3 = defineBuiltIn$5; -var wellKnownSymbol$e = wellKnownSymbol$i; - -var ITERATOR$1 = wellKnownSymbol$e('iterator'); -var BUGGY_SAFARI_ITERATORS$1 = false; - -// `%IteratorPrototype%` object -// https://tc39.es/ecma262/#sec-%iteratorprototype%-object -var IteratorPrototype$2, PrototypeOfArrayIteratorPrototype, arrayIterator; - -/* eslint-disable es-x/no-array-prototype-keys -- safe */ -if ([].keys) { - arrayIterator = [].keys(); - // Safari 8 has buggy iterators w/o `next` - if (!('next' in arrayIterator)) BUGGY_SAFARI_ITERATORS$1 = true; - else { - PrototypeOfArrayIteratorPrototype = getPrototypeOf$1(getPrototypeOf$1(arrayIterator)); - if (PrototypeOfArrayIteratorPrototype !== Object.prototype) IteratorPrototype$2 = PrototypeOfArrayIteratorPrototype; - } -} - -var NEW_ITERATOR_PROTOTYPE = IteratorPrototype$2 == undefined || fails$f(function () { - var test = {}; - // FF44- legacy iterators case - return IteratorPrototype$2[ITERATOR$1].call(test) !== test; -}); - -if (NEW_ITERATOR_PROTOTYPE) IteratorPrototype$2 = {}; - -// `%IteratorPrototype%[@@iterator]()` method -// https://tc39.es/ecma262/#sec-%iteratorprototype%-@@iterator -if (!isCallable$a(IteratorPrototype$2[ITERATOR$1])) { - defineBuiltIn$3(IteratorPrototype$2, ITERATOR$1, function () { - return this; - }); -} - -var iteratorsCore = { - IteratorPrototype: IteratorPrototype$2, - BUGGY_SAFARI_ITERATORS: BUGGY_SAFARI_ITERATORS$1 -}; - -var IteratorPrototype$1 = iteratorsCore.IteratorPrototype; -var create$1 = objectCreate; -var createPropertyDescriptor$2 = createPropertyDescriptor$5; -var setToStringTag$1 = setToStringTag$3; -var Iterators$2 = iterators; - -var returnThis$1 = function () { return this; }; - -var createIteratorConstructor$1 = function (IteratorConstructor, NAME, next, ENUMERABLE_NEXT) { - var TO_STRING_TAG = NAME + ' Iterator'; - IteratorConstructor.prototype = create$1(IteratorPrototype$1, { next: createPropertyDescriptor$2(+!ENUMERABLE_NEXT, next) }); - setToStringTag$1(IteratorConstructor, TO_STRING_TAG, false); - Iterators$2[TO_STRING_TAG] = returnThis$1; - return IteratorConstructor; -}; - -var isCallable$9 = isCallable$m; - -var $String$1 = String; -var $TypeError$7 = TypeError; - -var aPossiblePrototype$1 = function (argument) { - if (typeof argument == 'object' || isCallable$9(argument)) return argument; - throw $TypeError$7("Can't set " + $String$1(argument) + ' as a prototype'); -}; - -/* eslint-disable no-proto -- safe */ - -var uncurryThis$i = functionUncurryThis; -var anObject$6 = anObject$b; -var aPossiblePrototype = aPossiblePrototype$1; - -// `Object.setPrototypeOf` method -// https://tc39.es/ecma262/#sec-object.setprototypeof -// Works with __proto__ only. Old v8 can't work with null proto objects. -// eslint-disable-next-line es-x/no-object-setprototypeof -- safe -var objectSetPrototypeOf = Object.setPrototypeOf || ('__proto__' in {} ? function () { - var CORRECT_SETTER = false; - var test = {}; - var setter; - try { - // eslint-disable-next-line es-x/no-object-getownpropertydescriptor -- safe - setter = uncurryThis$i(Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set); - setter(test, []); - CORRECT_SETTER = test instanceof Array; - } catch (error) { /* empty */ } - return function setPrototypeOf(O, proto) { - anObject$6(O); - aPossiblePrototype(proto); - if (CORRECT_SETTER) setter(O, proto); - else O.__proto__ = proto; - return O; - }; -}() : undefined); - -var $$f = _export; -var call$a = functionCall; -var FunctionName = functionName; -var isCallable$8 = isCallable$m; -var createIteratorConstructor = createIteratorConstructor$1; -var getPrototypeOf = objectGetPrototypeOf; -var setPrototypeOf$2 = objectSetPrototypeOf; -var setToStringTag = setToStringTag$3; -var createNonEnumerableProperty$4 = createNonEnumerableProperty$7; -var defineBuiltIn$2 = defineBuiltIn$5; -var wellKnownSymbol$d = wellKnownSymbol$i; -var Iterators$1 = iterators; -var IteratorsCore = iteratorsCore; - -var PROPER_FUNCTION_NAME$1 = FunctionName.PROPER; -var CONFIGURABLE_FUNCTION_NAME = FunctionName.CONFIGURABLE; -var IteratorPrototype = IteratorsCore.IteratorPrototype; -var BUGGY_SAFARI_ITERATORS = IteratorsCore.BUGGY_SAFARI_ITERATORS; -var ITERATOR = wellKnownSymbol$d('iterator'); -var KEYS = 'keys'; -var VALUES = 'values'; -var ENTRIES = 'entries'; - -var returnThis = function () { return this; }; - -var defineIterator$1 = function (Iterable, NAME, IteratorConstructor, next, DEFAULT, IS_SET, FORCED) { - createIteratorConstructor(IteratorConstructor, NAME, next); - - var getIterationMethod = function (KIND) { - if (KIND === DEFAULT && defaultIterator) return defaultIterator; - if (!BUGGY_SAFARI_ITERATORS && KIND in IterablePrototype) return IterablePrototype[KIND]; - switch (KIND) { - case KEYS: return function keys() { return new IteratorConstructor(this, KIND); }; - case VALUES: return function values() { return new IteratorConstructor(this, KIND); }; - case ENTRIES: return function entries() { return new IteratorConstructor(this, KIND); }; - } return function () { return new IteratorConstructor(this); }; - }; - - var TO_STRING_TAG = NAME + ' Iterator'; - var INCORRECT_VALUES_NAME = false; - var IterablePrototype = Iterable.prototype; - var nativeIterator = IterablePrototype[ITERATOR] - || IterablePrototype['@@iterator'] - || DEFAULT && IterablePrototype[DEFAULT]; - var defaultIterator = !BUGGY_SAFARI_ITERATORS && nativeIterator || getIterationMethod(DEFAULT); - var anyNativeIterator = NAME == 'Array' ? IterablePrototype.entries || nativeIterator : nativeIterator; - var CurrentIteratorPrototype, methods, KEY; - - // fix native - if (anyNativeIterator) { - CurrentIteratorPrototype = getPrototypeOf(anyNativeIterator.call(new Iterable())); - if (CurrentIteratorPrototype !== Object.prototype && CurrentIteratorPrototype.next) { - if (getPrototypeOf(CurrentIteratorPrototype) !== IteratorPrototype) { - if (setPrototypeOf$2) { - setPrototypeOf$2(CurrentIteratorPrototype, IteratorPrototype); - } else if (!isCallable$8(CurrentIteratorPrototype[ITERATOR])) { - defineBuiltIn$2(CurrentIteratorPrototype, ITERATOR, returnThis); - } - } - // Set @@toStringTag to native iterators - setToStringTag(CurrentIteratorPrototype, TO_STRING_TAG, true); - } - } - - // fix Array.prototype.{ values, @@iterator }.name in V8 / FF - if (PROPER_FUNCTION_NAME$1 && DEFAULT == VALUES && nativeIterator && nativeIterator.name !== VALUES) { - if (CONFIGURABLE_FUNCTION_NAME) { - createNonEnumerableProperty$4(IterablePrototype, 'name', VALUES); - } else { - INCORRECT_VALUES_NAME = true; - defaultIterator = function values() { return call$a(nativeIterator, this); }; - } - } - - // export additional methods - if (DEFAULT) { - methods = { - values: getIterationMethod(VALUES), - keys: IS_SET ? defaultIterator : getIterationMethod(KEYS), - entries: getIterationMethod(ENTRIES) - }; - if (FORCED) for (KEY in methods) { - if (BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME || !(KEY in IterablePrototype)) { - defineBuiltIn$2(IterablePrototype, KEY, methods[KEY]); - } - } else $$f({ target: NAME, proto: true, forced: BUGGY_SAFARI_ITERATORS || INCORRECT_VALUES_NAME }, methods); - } - - // define iterator - if (IterablePrototype[ITERATOR] !== defaultIterator) { - defineBuiltIn$2(IterablePrototype, ITERATOR, defaultIterator, { name: DEFAULT }); - } - Iterators$1[NAME] = defaultIterator; - - return methods; -}; - -var toIndexedObject$1 = toIndexedObject$6; -var addToUnscopables = addToUnscopables$1; -var Iterators = iterators; -var InternalStateModule = internalState; -var defineProperty$2 = objectDefineProperty.f; -var defineIterator = defineIterator$1; -var DESCRIPTORS$4 = descriptors; - -var ARRAY_ITERATOR = 'Array Iterator'; -var setInternalState = InternalStateModule.set; -var getInternalState$2 = InternalStateModule.getterFor(ARRAY_ITERATOR); - -// `Array.prototype.entries` method -// https://tc39.es/ecma262/#sec-array.prototype.entries -// `Array.prototype.keys` method -// https://tc39.es/ecma262/#sec-array.prototype.keys -// `Array.prototype.values` method -// https://tc39.es/ecma262/#sec-array.prototype.values -// `Array.prototype[@@iterator]` method -// https://tc39.es/ecma262/#sec-array.prototype-@@iterator -// `CreateArrayIterator` internal method -// https://tc39.es/ecma262/#sec-createarrayiterator -defineIterator(Array, 'Array', function (iterated, kind) { - setInternalState(this, { - type: ARRAY_ITERATOR, - target: toIndexedObject$1(iterated), // target - index: 0, // next index - kind: kind // kind - }); -// `%ArrayIteratorPrototype%.next` method -// https://tc39.es/ecma262/#sec-%arrayiteratorprototype%.next -}, function () { - var state = getInternalState$2(this); - var target = state.target; - var kind = state.kind; - var index = state.index++; - if (!target || index >= target.length) { - state.target = undefined; - return { value: undefined, done: true }; - } - if (kind == 'keys') return { value: index, done: false }; - if (kind == 'values') return { value: target[index], done: false }; - return { value: [index, target[index]], done: false }; -}, 'values'); - -// argumentsList[@@iterator] is %ArrayProto_values% -// https://tc39.es/ecma262/#sec-createunmappedargumentsobject -// https://tc39.es/ecma262/#sec-createmappedargumentsobject -var values = Iterators.Arguments = Iterators.Array; - -// https://tc39.es/ecma262/#sec-array.prototype-@@unscopables -addToUnscopables('keys'); -addToUnscopables('values'); -addToUnscopables('entries'); - -// V8 ~ Chrome 45- bug -if (DESCRIPTORS$4 && values.name !== 'values') try { - defineProperty$2(values, 'name', { value: 'values' }); -} catch (error) { /* empty */ } - -var wellKnownSymbol$c = wellKnownSymbol$i; - -var TO_STRING_TAG$1 = wellKnownSymbol$c('toStringTag'); -var test$2 = {}; - -test$2[TO_STRING_TAG$1] = 'z'; - -var toStringTagSupport = String(test$2) === '[object z]'; - -var TO_STRING_TAG_SUPPORT = toStringTagSupport; -var isCallable$7 = isCallable$m; -var classofRaw = classofRaw$1; -var wellKnownSymbol$b = wellKnownSymbol$i; - -var TO_STRING_TAG = wellKnownSymbol$b('toStringTag'); -var $Object = Object; - -// ES3 wrong here -var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments'; - -// fallback for IE11 Script Access Denied error -var tryGet = function (it, key) { - try { - return it[key]; - } catch (error) { /* empty */ } -}; - -// getting tag from ES6+ `Object.prototype.toString` -var classof$6 = TO_STRING_TAG_SUPPORT ? classofRaw : function (it) { - var O, tag, result; - return it === undefined ? 'Undefined' : it === null ? 'Null' - // @@toStringTag case - : typeof (tag = tryGet(O = $Object(it), TO_STRING_TAG)) == 'string' ? tag - // builtinTag case - : CORRECT_ARGUMENTS ? classofRaw(O) - // ES3 arguments fallback - : (result = classofRaw(O)) == 'Object' && isCallable$7(O.callee) ? 'Arguments' : result; -}; - -var classof$5 = classof$6; - -var $String = String; - -var toString$a = function (argument) { - if (classof$5(argument) === 'Symbol') throw TypeError('Cannot convert a Symbol value to a string'); - return $String(argument); -}; - -var anObject$5 = anObject$b; - -// `RegExp.prototype.flags` getter implementation -// https://tc39.es/ecma262/#sec-get-regexp.prototype.flags -var regexpFlags$1 = function () { - var that = anObject$5(this); - var result = ''; - if (that.hasIndices) result += 'd'; - if (that.global) result += 'g'; - if (that.ignoreCase) result += 'i'; - if (that.multiline) result += 'm'; - if (that.dotAll) result += 's'; - if (that.unicode) result += 'u'; - if (that.unicodeSets) result += 'v'; - if (that.sticky) result += 'y'; - return result; -}; - -var fails$e = fails$p; -var global$5 = global$g; - -// babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError -var $RegExp$2 = global$5.RegExp; - -var UNSUPPORTED_Y$3 = fails$e(function () { - var re = $RegExp$2('a', 'y'); - re.lastIndex = 2; - return re.exec('abcd') != null; -}); - -// UC Browser bug -// https://github.com/zloirock/core-js/issues/1008 -var MISSED_STICKY$1 = UNSUPPORTED_Y$3 || fails$e(function () { - return !$RegExp$2('a', 'y').sticky; -}); - -var BROKEN_CARET = UNSUPPORTED_Y$3 || fails$e(function () { - // https://bugzilla.mozilla.org/show_bug.cgi?id=773687 - var re = $RegExp$2('^r', 'gy'); - re.lastIndex = 2; - return re.exec('str') != null; -}); - -var regexpStickyHelpers = { - BROKEN_CARET: BROKEN_CARET, - MISSED_STICKY: MISSED_STICKY$1, - UNSUPPORTED_Y: UNSUPPORTED_Y$3 -}; - -var fails$d = fails$p; -var global$4 = global$g; - -// babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError -var $RegExp$1 = global$4.RegExp; - -var regexpUnsupportedDotAll = fails$d(function () { - var re = $RegExp$1('.', 's'); - return !(re.dotAll && re.exec('\n') && re.flags === 's'); -}); - -var fails$c = fails$p; -var global$3 = global$g; - -// babel-minify and Closure Compiler transpiles RegExp('(?b)', 'g') -> /(?b)/g and it causes SyntaxError -var $RegExp = global$3.RegExp; - -var regexpUnsupportedNcg = fails$c(function () { - var re = $RegExp('(?b)', 'g'); - return re.exec('b').groups.a !== 'b' || - 'b'.replace(re, '$c') !== 'bc'; -}); - -/* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */ -/* eslint-disable regexp/no-useless-quantifier -- testing */ -var call$9 = functionCall; -var uncurryThis$h = functionUncurryThis; -var toString$9 = toString$a; -var regexpFlags = regexpFlags$1; -var stickyHelpers$2 = regexpStickyHelpers; -var shared = shared$4.exports; -var create = objectCreate; -var getInternalState$1 = internalState.get; -var UNSUPPORTED_DOT_ALL$2 = regexpUnsupportedDotAll; -var UNSUPPORTED_NCG$1 = regexpUnsupportedNcg; - -var nativeReplace = shared('native-string-replace', String.prototype.replace); -var nativeExec = RegExp.prototype.exec; -var patchedExec = nativeExec; -var charAt$5 = uncurryThis$h(''.charAt); -var indexOf$1 = uncurryThis$h(''.indexOf); -var replace$5 = uncurryThis$h(''.replace); -var stringSlice$6 = uncurryThis$h(''.slice); - -var UPDATES_LAST_INDEX_WRONG = (function () { - var re1 = /a/; - var re2 = /b*/g; - call$9(nativeExec, re1, 'a'); - call$9(nativeExec, re2, 'a'); - return re1.lastIndex !== 0 || re2.lastIndex !== 0; -})(); - -var UNSUPPORTED_Y$2 = stickyHelpers$2.BROKEN_CARET; - -// nonparticipating capturing group, copied from es5-shim's String#split patch. -var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined; - -var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y$2 || UNSUPPORTED_DOT_ALL$2 || UNSUPPORTED_NCG$1; - -if (PATCH) { - patchedExec = function exec(string) { - var re = this; - var state = getInternalState$1(re); - var str = toString$9(string); - var raw = state.raw; - var result, reCopy, lastIndex, match, i, object, group; - - if (raw) { - raw.lastIndex = re.lastIndex; - result = call$9(patchedExec, raw, str); - re.lastIndex = raw.lastIndex; - return result; - } - - var groups = state.groups; - var sticky = UNSUPPORTED_Y$2 && re.sticky; - var flags = call$9(regexpFlags, re); - var source = re.source; - var charsAdded = 0; - var strCopy = str; - - if (sticky) { - flags = replace$5(flags, 'y', ''); - if (indexOf$1(flags, 'g') === -1) { - flags += 'g'; - } - - strCopy = stringSlice$6(str, re.lastIndex); - // Support anchored sticky behavior. - if (re.lastIndex > 0 && (!re.multiline || re.multiline && charAt$5(str, re.lastIndex - 1) !== '\n')) { - source = '(?: ' + source + ')'; - strCopy = ' ' + strCopy; - charsAdded++; - } - // ^(? + rx + ) is needed, in combination with some str slicing, to - // simulate the 'y' flag. - reCopy = new RegExp('^(?:' + source + ')', flags); - } - - if (NPCG_INCLUDED) { - reCopy = new RegExp('^' + source + '$(?!\\s)', flags); - } - if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex; - - match = call$9(nativeExec, sticky ? reCopy : re, strCopy); - - if (sticky) { - if (match) { - match.input = stringSlice$6(match.input, charsAdded); - match[0] = stringSlice$6(match[0], charsAdded); - match.index = re.lastIndex; - re.lastIndex += match[0].length; - } else re.lastIndex = 0; - } else if (UPDATES_LAST_INDEX_WRONG && match) { - re.lastIndex = re.global ? match.index + match[0].length : lastIndex; - } - if (NPCG_INCLUDED && match && match.length > 1) { - // Fix browsers whose `exec` methods don't consistently return `undefined` - // for NPCG, like IE8. NOTE: This doesn't work for /(.?)?/ - call$9(nativeReplace, match[0], reCopy, function () { - for (i = 1; i < arguments.length - 2; i++) { - if (arguments[i] === undefined) match[i] = undefined; - } - }); - } - - if (match && groups) { - match.groups = object = create(null); - for (i = 0; i < groups.length; i++) { - group = groups[i]; - object[group[0]] = match[group[1]]; - } - } - - return match; - }; -} - -var regexpExec$3 = patchedExec; - -var $$e = _export; -var exec$6 = regexpExec$3; - -// `RegExp.prototype.exec` method -// https://tc39.es/ecma262/#sec-regexp.prototype.exec -$$e({ target: 'RegExp', proto: true, forced: /./.exec !== exec$6 }, { - exec: exec$6 -}); - -var NATIVE_BIND$1 = functionBindNative; - -var FunctionPrototype = Function.prototype; -var apply$4 = FunctionPrototype.apply; -var call$8 = FunctionPrototype.call; - -// eslint-disable-next-line es-x/no-reflect -- safe -var functionApply = typeof Reflect == 'object' && Reflect.apply || (NATIVE_BIND$1 ? call$8.bind(apply$4) : function () { - return call$8.apply(apply$4, arguments); -}); - -// TODO: Remove from `core-js@4` since it's moved to entry points - -var uncurryThis$g = functionUncurryThis; -var defineBuiltIn$1 = defineBuiltIn$5; -var regexpExec$2 = regexpExec$3; -var fails$b = fails$p; -var wellKnownSymbol$a = wellKnownSymbol$i; -var createNonEnumerableProperty$3 = createNonEnumerableProperty$7; - -var SPECIES$5 = wellKnownSymbol$a('species'); -var RegExpPrototype$3 = RegExp.prototype; - -var fixRegexpWellKnownSymbolLogic = function (KEY, exec, FORCED, SHAM) { - var SYMBOL = wellKnownSymbol$a(KEY); - - var DELEGATES_TO_SYMBOL = !fails$b(function () { - // String methods call symbol-named RegEp methods - var O = {}; - O[SYMBOL] = function () { return 7; }; - return ''[KEY](O) != 7; - }); - - var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails$b(function () { - // Symbol-named RegExp methods call .exec - var execCalled = false; - var re = /a/; - - if (KEY === 'split') { - // We can't use real regex here since it causes deoptimization - // and serious performance degradation in V8 - // https://github.com/zloirock/core-js/issues/306 - re = {}; - // RegExp[@@split] doesn't call the regex's exec method, but first creates - // a new one. We need to return the patched regex when creating the new one. - re.constructor = {}; - re.constructor[SPECIES$5] = function () { return re; }; - re.flags = ''; - re[SYMBOL] = /./[SYMBOL]; - } - - re.exec = function () { execCalled = true; return null; }; - - re[SYMBOL](''); - return !execCalled; - }); - - if ( - !DELEGATES_TO_SYMBOL || - !DELEGATES_TO_EXEC || - FORCED - ) { - var uncurriedNativeRegExpMethod = uncurryThis$g(/./[SYMBOL]); - var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) { - var uncurriedNativeMethod = uncurryThis$g(nativeMethod); - var $exec = regexp.exec; - if ($exec === regexpExec$2 || $exec === RegExpPrototype$3.exec) { - if (DELEGATES_TO_SYMBOL && !forceStringMethod) { - // The native String method already delegates to @@method (this - // polyfilled function), leasing to infinite recursion. - // We avoid it by directly calling the native @@method method. - return { done: true, value: uncurriedNativeRegExpMethod(regexp, str, arg2) }; - } - return { done: true, value: uncurriedNativeMethod(str, regexp, arg2) }; - } - return { done: false }; - }); - - defineBuiltIn$1(String.prototype, KEY, methods[0]); - defineBuiltIn$1(RegExpPrototype$3, SYMBOL, methods[1]); - } - - if (SHAM) createNonEnumerableProperty$3(RegExpPrototype$3[SYMBOL], 'sham', true); -}; - -var uncurryThis$f = functionUncurryThis; -var toIntegerOrInfinity$2 = toIntegerOrInfinity$5; -var toString$8 = toString$a; -var requireObjectCoercible$5 = requireObjectCoercible$8; - -var charAt$4 = uncurryThis$f(''.charAt); -var charCodeAt$1 = uncurryThis$f(''.charCodeAt); -var stringSlice$5 = uncurryThis$f(''.slice); - -var createMethod$2 = function (CONVERT_TO_STRING) { - return function ($this, pos) { - var S = toString$8(requireObjectCoercible$5($this)); - var position = toIntegerOrInfinity$2(pos); - var size = S.length; - var first, second; - if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined; - first = charCodeAt$1(S, position); - return first < 0xD800 || first > 0xDBFF || position + 1 === size - || (second = charCodeAt$1(S, position + 1)) < 0xDC00 || second > 0xDFFF - ? CONVERT_TO_STRING - ? charAt$4(S, position) - : first - : CONVERT_TO_STRING - ? stringSlice$5(S, position, position + 2) - : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000; - }; -}; - -var stringMultibyte = { - // `String.prototype.codePointAt` method - // https://tc39.es/ecma262/#sec-string.prototype.codepointat - codeAt: createMethod$2(false), - // `String.prototype.at` method - // https://github.com/mathiasbynens/String.prototype.at - charAt: createMethod$2(true) -}; - -var charAt$3 = stringMultibyte.charAt; - -// `AdvanceStringIndex` abstract operation -// https://tc39.es/ecma262/#sec-advancestringindex -var advanceStringIndex$3 = function (S, index, unicode) { - return index + (unicode ? charAt$3(S, index).length : 1); -}; - -var uncurryThis$e = functionUncurryThis; -var toObject$4 = toObject$7; - -var floor$1 = Math.floor; -var charAt$2 = uncurryThis$e(''.charAt); -var replace$4 = uncurryThis$e(''.replace); -var stringSlice$4 = uncurryThis$e(''.slice); -var SUBSTITUTION_SYMBOLS = /\$([$&'`]|\d{1,2}|<[^>]*>)/g; -var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&'`]|\d{1,2})/g; - -// `GetSubstitution` abstract operation -// https://tc39.es/ecma262/#sec-getsubstitution -var getSubstitution$2 = function (matched, str, position, captures, namedCaptures, replacement) { - var tailPos = position + matched.length; - var m = captures.length; - var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED; - if (namedCaptures !== undefined) { - namedCaptures = toObject$4(namedCaptures); - symbols = SUBSTITUTION_SYMBOLS; - } - return replace$4(replacement, symbols, function (match, ch) { - var capture; - switch (charAt$2(ch, 0)) { - case '$': return '$'; - case '&': return matched; - case '`': return stringSlice$4(str, 0, position); - case "'": return stringSlice$4(str, tailPos); - case '<': - capture = namedCaptures[stringSlice$4(ch, 1, -1)]; - break; - default: // \d\d? - var n = +ch; - if (n === 0) return match; - if (n > m) { - var f = floor$1(n / 10); - if (f === 0) return match; - if (f <= m) return captures[f - 1] === undefined ? charAt$2(ch, 1) : captures[f - 1] + charAt$2(ch, 1); - return match; - } - capture = captures[n - 1]; - } - return capture === undefined ? '' : capture; - }); -}; - -var call$7 = functionCall; -var anObject$4 = anObject$b; -var isCallable$6 = isCallable$m; -var classof$4 = classofRaw$1; -var regexpExec$1 = regexpExec$3; - -var $TypeError$6 = TypeError; - -// `RegExpExec` abstract operation -// https://tc39.es/ecma262/#sec-regexpexec -var regexpExecAbstract = function (R, S) { - var exec = R.exec; - if (isCallable$6(exec)) { - var result = call$7(exec, R, S); - if (result !== null) anObject$4(result); - return result; - } - if (classof$4(R) === 'RegExp') return call$7(regexpExec$1, R, S); - throw $TypeError$6('RegExp#exec called on incompatible receiver'); -}; - -var apply$3 = functionApply; -var call$6 = functionCall; -var uncurryThis$d = functionUncurryThis; -var fixRegExpWellKnownSymbolLogic$2 = fixRegexpWellKnownSymbolLogic; -var fails$a = fails$p; -var anObject$3 = anObject$b; -var isCallable$5 = isCallable$m; -var toIntegerOrInfinity$1 = toIntegerOrInfinity$5; -var toLength$2 = toLength$4; -var toString$7 = toString$a; -var requireObjectCoercible$4 = requireObjectCoercible$8; -var advanceStringIndex$2 = advanceStringIndex$3; -var getMethod$3 = getMethod$5; -var getSubstitution$1 = getSubstitution$2; -var regExpExec$1 = regexpExecAbstract; -var wellKnownSymbol$9 = wellKnownSymbol$i; - -var REPLACE$1 = wellKnownSymbol$9('replace'); -var max$4 = Math.max; -var min$2 = Math.min; -var concat = uncurryThis$d([].concat); -var push$3 = uncurryThis$d([].push); -var stringIndexOf$2 = uncurryThis$d(''.indexOf); -var stringSlice$3 = uncurryThis$d(''.slice); - -var maybeToString = function (it) { - return it === undefined ? it : String(it); -}; - -// IE <= 11 replaces $0 with the whole match, as if it was $& -// https://stackoverflow.com/questions/6024666/getting-ie-to-replace-a-regex-with-the-literal-string-0 -var REPLACE_KEEPS_$0 = (function () { - // eslint-disable-next-line regexp/prefer-escape-replacement-dollar-char -- required for testing - return 'a'.replace(/./, '$0') === '$0'; -})(); - -// Safari <= 13.0.3(?) substitutes nth capture where n>m with an empty string -var REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE = (function () { - if (/./[REPLACE$1]) { - return /./[REPLACE$1]('a', '$0') === ''; - } - return false; -})(); - -var REPLACE_SUPPORTS_NAMED_GROUPS = !fails$a(function () { - var re = /./; - re.exec = function () { - var result = []; - result.groups = { a: '7' }; - return result; - }; - // eslint-disable-next-line regexp/no-useless-dollar-replacements -- false positive - return ''.replace(re, '$') !== '7'; -}); - -// @@replace logic -fixRegExpWellKnownSymbolLogic$2('replace', function (_, nativeReplace, maybeCallNative) { - var UNSAFE_SUBSTITUTE = REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE ? '$' : '$0'; - - return [ - // `String.prototype.replace` method - // https://tc39.es/ecma262/#sec-string.prototype.replace - function replace(searchValue, replaceValue) { - var O = requireObjectCoercible$4(this); - var replacer = searchValue == undefined ? undefined : getMethod$3(searchValue, REPLACE$1); - return replacer - ? call$6(replacer, searchValue, O, replaceValue) - : call$6(nativeReplace, toString$7(O), searchValue, replaceValue); - }, - // `RegExp.prototype[@@replace]` method - // https://tc39.es/ecma262/#sec-regexp.prototype-@@replace - function (string, replaceValue) { - var rx = anObject$3(this); - var S = toString$7(string); - - if ( - typeof replaceValue == 'string' && - stringIndexOf$2(replaceValue, UNSAFE_SUBSTITUTE) === -1 && - stringIndexOf$2(replaceValue, '$<') === -1 - ) { - var res = maybeCallNative(nativeReplace, rx, S, replaceValue); - if (res.done) return res.value; - } - - var functionalReplace = isCallable$5(replaceValue); - if (!functionalReplace) replaceValue = toString$7(replaceValue); - - var global = rx.global; - if (global) { - var fullUnicode = rx.unicode; - rx.lastIndex = 0; - } - var results = []; - while (true) { - var result = regExpExec$1(rx, S); - if (result === null) break; - - push$3(results, result); - if (!global) break; - - var matchStr = toString$7(result[0]); - if (matchStr === '') rx.lastIndex = advanceStringIndex$2(S, toLength$2(rx.lastIndex), fullUnicode); - } - - var accumulatedResult = ''; - var nextSourcePosition = 0; - for (var i = 0; i < results.length; i++) { - result = results[i]; - - var matched = toString$7(result[0]); - var position = max$4(min$2(toIntegerOrInfinity$1(result.index), S.length), 0); - var captures = []; - // NOTE: This is equivalent to - // captures = result.slice(1).map(maybeToString) - // but for some reason `nativeSlice.call(result, 1, result.length)` (called in - // the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and - // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it. - for (var j = 1; j < result.length; j++) push$3(captures, maybeToString(result[j])); - var namedCaptures = result.groups; - if (functionalReplace) { - var replacerArgs = concat([matched], captures, position, S); - if (namedCaptures !== undefined) push$3(replacerArgs, namedCaptures); - var replacement = toString$7(apply$3(replaceValue, undefined, replacerArgs)); - } else { - replacement = getSubstitution$1(matched, S, position, captures, namedCaptures, replaceValue); - } - if (position >= nextSourcePosition) { - accumulatedResult += stringSlice$3(S, nextSourcePosition, position) + replacement; - nextSourcePosition = position + matched.length; - } - } - return accumulatedResult + stringSlice$3(S, nextSourcePosition); - } - ]; -}, !REPLACE_SUPPORTS_NAMED_GROUPS || !REPLACE_KEEPS_$0 || REGEXP_REPLACE_SUBSTITUTES_UNDEFINED_CAPTURE); - -var isObject$7 = isObject$d; -var classof$3 = classofRaw$1; -var wellKnownSymbol$8 = wellKnownSymbol$i; - -var MATCH$1 = wellKnownSymbol$8('match'); - -// `IsRegExp` abstract operation -// https://tc39.es/ecma262/#sec-isregexp -var isRegexp = function (it) { - var isRegExp; - return isObject$7(it) && ((isRegExp = it[MATCH$1]) !== undefined ? !!isRegExp : classof$3(it) == 'RegExp'); -}; - -var call$5 = functionCall; -var hasOwn$2 = hasOwnProperty_1; -var isPrototypeOf$2 = objectIsPrototypeOf; -var regExpFlags = regexpFlags$1; - -var RegExpPrototype$2 = RegExp.prototype; - -var regexpGetFlags = function (R) { - var flags = R.flags; - return flags === undefined && !('flags' in RegExpPrototype$2) && !hasOwn$2(R, 'flags') && isPrototypeOf$2(RegExpPrototype$2, R) - ? call$5(regExpFlags, R) : flags; -}; - -var $$d = _export; -var call$4 = functionCall; -var uncurryThis$c = functionUncurryThis; -var requireObjectCoercible$3 = requireObjectCoercible$8; -var isCallable$4 = isCallable$m; -var isRegExp$2 = isRegexp; -var toString$6 = toString$a; -var getMethod$2 = getMethod$5; -var getRegExpFlags$1 = regexpGetFlags; -var getSubstitution = getSubstitution$2; -var wellKnownSymbol$7 = wellKnownSymbol$i; - -var REPLACE = wellKnownSymbol$7('replace'); -var $TypeError$5 = TypeError; -var indexOf = uncurryThis$c(''.indexOf); -uncurryThis$c(''.replace); -var stringSlice$2 = uncurryThis$c(''.slice); -var max$3 = Math.max; - -var stringIndexOf$1 = function (string, searchValue, fromIndex) { - if (fromIndex > string.length) return -1; - if (searchValue === '') return fromIndex; - return indexOf(string, searchValue, fromIndex); -}; - -// `String.prototype.replaceAll` method -// https://tc39.es/ecma262/#sec-string.prototype.replaceall -$$d({ target: 'String', proto: true }, { - replaceAll: function replaceAll(searchValue, replaceValue) { - var O = requireObjectCoercible$3(this); - var IS_REG_EXP, flags, replacer, string, searchString, functionalReplace, searchLength, advanceBy, replacement; - var position = 0; - var endOfLastMatch = 0; - var result = ''; - if (searchValue != null) { - IS_REG_EXP = isRegExp$2(searchValue); - if (IS_REG_EXP) { - flags = toString$6(requireObjectCoercible$3(getRegExpFlags$1(searchValue))); - if (!~indexOf(flags, 'g')) throw $TypeError$5('`.replaceAll` does not allow non-global regexes'); - } - replacer = getMethod$2(searchValue, REPLACE); - if (replacer) { - return call$4(replacer, searchValue, O, replaceValue); - } - } - string = toString$6(O); - searchString = toString$6(searchValue); - functionalReplace = isCallable$4(replaceValue); - if (!functionalReplace) replaceValue = toString$6(replaceValue); - searchLength = searchString.length; - advanceBy = max$3(1, searchLength); - position = stringIndexOf$1(string, searchString, 0); - while (position !== -1) { - replacement = functionalReplace - ? toString$6(replaceValue(searchString, position, string)) - : getSubstitution(searchString, string, position, [], undefined, replaceValue); - result += stringSlice$2(string, endOfLastMatch, position) + replacement; - endOfLastMatch = position + searchLength; - position = stringIndexOf$1(string, searchString, position + advanceBy); - } - if (endOfLastMatch < string.length) { - result += stringSlice$2(string, endOfLastMatch); - } - return result; - } -}); - -var defineProperty$1 = objectDefineProperty.f; - -var proxyAccessor$2 = function (Target, Source, key) { - key in Target || defineProperty$1(Target, key, { - configurable: true, - get: function () { return Source[key]; }, - set: function (it) { Source[key] = it; } - }); -}; - -var isCallable$3 = isCallable$m; -var isObject$6 = isObject$d; -var setPrototypeOf$1 = objectSetPrototypeOf; - -// makes subclassing work correct for wrapped built-ins -var inheritIfRequired$2 = function ($this, dummy, Wrapper) { - var NewTarget, NewTargetPrototype; - if ( - // it can work only with native `setPrototypeOf` - setPrototypeOf$1 && - // we haven't completely correct pre-ES6 way for getting `new.target`, so use this - isCallable$3(NewTarget = dummy.constructor) && - NewTarget !== Wrapper && - isObject$6(NewTargetPrototype = NewTarget.prototype) && - NewTargetPrototype !== Wrapper.prototype - ) setPrototypeOf$1($this, NewTargetPrototype); - return $this; -}; - -var toString$5 = toString$a; - -var normalizeStringArgument$1 = function (argument, $default) { - return argument === undefined ? arguments.length < 2 ? '' : $default : toString$5(argument); -}; - -var isObject$5 = isObject$d; -var createNonEnumerableProperty$2 = createNonEnumerableProperty$7; - -// `InstallErrorCause` abstract operation -// https://tc39.es/proposal-error-cause/#sec-errorobjects-install-error-cause -var installErrorCause$1 = function (O, options) { - if (isObject$5(options) && 'cause' in options) { - createNonEnumerableProperty$2(O, 'cause', options.cause); - } -}; - -var uncurryThis$b = functionUncurryThis; - -var $Error = Error; -var replace$3 = uncurryThis$b(''.replace); - -var TEST = (function (arg) { return String($Error(arg).stack); })('zxcasd'); -var V8_OR_CHAKRA_STACK_ENTRY = /\n\s*at [^:]*:[^\n]*/; -var IS_V8_OR_CHAKRA_STACK = V8_OR_CHAKRA_STACK_ENTRY.test(TEST); - -var clearErrorStack$1 = function (stack, dropEntries) { - if (IS_V8_OR_CHAKRA_STACK && typeof stack == 'string' && !$Error.prepareStackTrace) { - while (dropEntries--) stack = replace$3(stack, V8_OR_CHAKRA_STACK_ENTRY, ''); - } return stack; -}; - -var fails$9 = fails$p; -var createPropertyDescriptor$1 = createPropertyDescriptor$5; - -var errorStackInstallable = !fails$9(function () { - var error = Error('a'); - if (!('stack' in error)) return true; - // eslint-disable-next-line es-x/no-object-defineproperty -- safe - Object.defineProperty(error, 'stack', createPropertyDescriptor$1(1, 7)); - return error.stack !== 7; -}); - -var getBuiltIn$3 = getBuiltIn$8; -var hasOwn$1 = hasOwnProperty_1; -var createNonEnumerableProperty$1 = createNonEnumerableProperty$7; -var isPrototypeOf$1 = objectIsPrototypeOf; -var setPrototypeOf = objectSetPrototypeOf; -var copyConstructorProperties = copyConstructorProperties$2; -var proxyAccessor$1 = proxyAccessor$2; -var inheritIfRequired$1 = inheritIfRequired$2; -var normalizeStringArgument = normalizeStringArgument$1; -var installErrorCause = installErrorCause$1; -var clearErrorStack = clearErrorStack$1; -var ERROR_STACK_INSTALLABLE = errorStackInstallable; -var DESCRIPTORS$3 = descriptors; - -var wrapErrorConstructorWithCause$1 = function (FULL_NAME, wrapper, FORCED, IS_AGGREGATE_ERROR) { - var STACK_TRACE_LIMIT = 'stackTraceLimit'; - var OPTIONS_POSITION = IS_AGGREGATE_ERROR ? 2 : 1; - var path = FULL_NAME.split('.'); - var ERROR_NAME = path[path.length - 1]; - var OriginalError = getBuiltIn$3.apply(null, path); - - if (!OriginalError) return; - - var OriginalErrorPrototype = OriginalError.prototype; - - // V8 9.3- bug https://bugs.chromium.org/p/v8/issues/detail?id=12006 - if (hasOwn$1(OriginalErrorPrototype, 'cause')) delete OriginalErrorPrototype.cause; - - if (!FORCED) return OriginalError; - - var BaseError = getBuiltIn$3('Error'); - - var WrappedError = wrapper(function (a, b) { - var message = normalizeStringArgument(IS_AGGREGATE_ERROR ? b : a, undefined); - var result = IS_AGGREGATE_ERROR ? new OriginalError(a) : new OriginalError(); - if (message !== undefined) createNonEnumerableProperty$1(result, 'message', message); - if (ERROR_STACK_INSTALLABLE) createNonEnumerableProperty$1(result, 'stack', clearErrorStack(result.stack, 2)); - if (this && isPrototypeOf$1(OriginalErrorPrototype, this)) inheritIfRequired$1(result, this, WrappedError); - if (arguments.length > OPTIONS_POSITION) installErrorCause(result, arguments[OPTIONS_POSITION]); - return result; - }); - - WrappedError.prototype = OriginalErrorPrototype; - - if (ERROR_NAME !== 'Error') { - if (setPrototypeOf) setPrototypeOf(WrappedError, BaseError); - else copyConstructorProperties(WrappedError, BaseError, { name: true }); - } else if (DESCRIPTORS$3 && STACK_TRACE_LIMIT in OriginalError) { - proxyAccessor$1(WrappedError, OriginalError, STACK_TRACE_LIMIT); - proxyAccessor$1(WrappedError, OriginalError, 'prepareStackTrace'); - } - - copyConstructorProperties(WrappedError, OriginalError); - - try { - // Safari 13- bug: WebAssembly errors does not have a proper `.name` - if (OriginalErrorPrototype.name !== ERROR_NAME) { - createNonEnumerableProperty$1(OriginalErrorPrototype, 'name', ERROR_NAME); - } - OriginalErrorPrototype.constructor = WrappedError; - } catch (error) { /* empty */ } - - return WrappedError; -}; - -/* eslint-disable no-unused-vars -- required for functions `.length` */ - -var $$c = _export; -var global$2 = global$g; -var apply$2 = functionApply; -var wrapErrorConstructorWithCause = wrapErrorConstructorWithCause$1; - -var WEB_ASSEMBLY = 'WebAssembly'; -var WebAssembly = global$2[WEB_ASSEMBLY]; - -var FORCED$2 = Error('e', { cause: 7 }).cause !== 7; - -var exportGlobalErrorCauseWrapper = function (ERROR_NAME, wrapper) { - var O = {}; - O[ERROR_NAME] = wrapErrorConstructorWithCause(ERROR_NAME, wrapper, FORCED$2); - $$c({ global: true, constructor: true, arity: 1, forced: FORCED$2 }, O); -}; - -var exportWebAssemblyErrorCauseWrapper = function (ERROR_NAME, wrapper) { - if (WebAssembly && WebAssembly[ERROR_NAME]) { - var O = {}; - O[ERROR_NAME] = wrapErrorConstructorWithCause(WEB_ASSEMBLY + '.' + ERROR_NAME, wrapper, FORCED$2); - $$c({ target: WEB_ASSEMBLY, stat: true, constructor: true, arity: 1, forced: FORCED$2 }, O); - } -}; - -// https://github.com/tc39/proposal-error-cause -exportGlobalErrorCauseWrapper('Error', function (init) { - return function Error(message) { return apply$2(init, this, arguments); }; -}); -exportGlobalErrorCauseWrapper('EvalError', function (init) { - return function EvalError(message) { return apply$2(init, this, arguments); }; -}); -exportGlobalErrorCauseWrapper('RangeError', function (init) { - return function RangeError(message) { return apply$2(init, this, arguments); }; -}); -exportGlobalErrorCauseWrapper('ReferenceError', function (init) { - return function ReferenceError(message) { return apply$2(init, this, arguments); }; -}); -exportGlobalErrorCauseWrapper('SyntaxError', function (init) { - return function SyntaxError(message) { return apply$2(init, this, arguments); }; -}); -exportGlobalErrorCauseWrapper('TypeError', function (init) { - return function TypeError(message) { return apply$2(init, this, arguments); }; -}); -exportGlobalErrorCauseWrapper('URIError', function (init) { - return function URIError(message) { return apply$2(init, this, arguments); }; -}); -exportWebAssemblyErrorCauseWrapper('CompileError', function (init) { - return function CompileError(message) { return apply$2(init, this, arguments); }; -}); -exportWebAssemblyErrorCauseWrapper('LinkError', function (init) { - return function LinkError(message) { return apply$2(init, this, arguments); }; -}); -exportWebAssemblyErrorCauseWrapper('RuntimeError', function (init) { - return function RuntimeError(message) { return apply$2(init, this, arguments); }; -}); - -// TODO: Remove from `core-js@4` since it's moved to entry points - -var $$b = _export; -var call$3 = functionCall; -var uncurryThis$a = functionUncurryThis; -var isCallable$2 = isCallable$m; -var isObject$4 = isObject$d; - -var DELEGATES_TO_EXEC = function () { - var execCalled = false; - var re = /[ac]/; - re.exec = function () { - execCalled = true; - return /./.exec.apply(this, arguments); - }; - return re.test('abc') === true && execCalled; -}(); - -var $TypeError$4 = TypeError; -var un$Test = uncurryThis$a(/./.test); - -// `RegExp.prototype.test` method -// https://tc39.es/ecma262/#sec-regexp.prototype.test -$$b({ target: 'RegExp', proto: true, forced: !DELEGATES_TO_EXEC }, { - test: function (str) { - var exec = this.exec; - if (!isCallable$2(exec)) return un$Test(this, str); - var result = call$3(exec, this, str); - if (result !== null && !isObject$4(result)) { - throw new $TypeError$4('RegExp exec method returned something other than an Object or null'); - } - return !!result; - } -}); - -// a string of all valid unicode whitespaces -var whitespaces$2 = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002' + - '\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'; - -var uncurryThis$9 = functionUncurryThis; -var requireObjectCoercible$2 = requireObjectCoercible$8; -var toString$4 = toString$a; -var whitespaces$1 = whitespaces$2; - -var replace$2 = uncurryThis$9(''.replace); -var whitespace = '[' + whitespaces$1 + ']'; -var ltrim = RegExp('^' + whitespace + whitespace + '*'); -var rtrim = RegExp(whitespace + whitespace + '*$'); - -// `String.prototype.{ trim, trimStart, trimEnd, trimLeft, trimRight }` methods implementation -var createMethod$1 = function (TYPE) { - return function ($this) { - var string = toString$4(requireObjectCoercible$2($this)); - if (TYPE & 1) string = replace$2(string, ltrim, ''); - if (TYPE & 2) string = replace$2(string, rtrim, ''); - return string; - }; -}; - -var stringTrim = { - // `String.prototype.{ trimLeft, trimStart }` methods - // https://tc39.es/ecma262/#sec-string.prototype.trimstart - start: createMethod$1(1), - // `String.prototype.{ trimRight, trimEnd }` methods - // https://tc39.es/ecma262/#sec-string.prototype.trimend - end: createMethod$1(2), - // `String.prototype.trim` method - // https://tc39.es/ecma262/#sec-string.prototype.trim - trim: createMethod$1(3) -}; - -var PROPER_FUNCTION_NAME = functionName.PROPER; -var fails$8 = fails$p; -var whitespaces = whitespaces$2; - -var non = '\u200B\u0085\u180E'; - -// check that a method works with the correct list -// of whitespaces and has a correct name -var stringTrimForced = function (METHOD_NAME) { - return fails$8(function () { - return !!whitespaces[METHOD_NAME]() - || non[METHOD_NAME]() !== non - || (PROPER_FUNCTION_NAME && whitespaces[METHOD_NAME].name !== METHOD_NAME); - }); -}; - -var $$a = _export; -var $trim = stringTrim.trim; -var forcedStringTrimMethod$1 = stringTrimForced; - -// `String.prototype.trim` method -// https://tc39.es/ecma262/#sec-string.prototype.trim -$$a({ target: 'String', proto: true, forced: forcedStringTrimMethod$1('trim') }, { - trim: function trim() { - return $trim(this); - } -}); - -var classof$2 = classofRaw$1; - -// `IsArray` abstract operation -// https://tc39.es/ecma262/#sec-isarray -// eslint-disable-next-line es-x/no-array-isarray -- safe -var isArray$4 = Array.isArray || function isArray(argument) { - return classof$2(argument) == 'Array'; -}; - -var uncurryThis$8 = functionUncurryThis; -var fails$7 = fails$p; -var isCallable$1 = isCallable$m; -var classof$1 = classof$6; -var getBuiltIn$2 = getBuiltIn$8; -var inspectSource = inspectSource$3; - -var noop = function () { /* empty */ }; -var empty = []; -var construct = getBuiltIn$2('Reflect', 'construct'); -var constructorRegExp = /^\s*(?:class|function)\b/; -var exec$5 = uncurryThis$8(constructorRegExp.exec); -var INCORRECT_TO_STRING = !constructorRegExp.exec(noop); - -var isConstructorModern = function isConstructor(argument) { - if (!isCallable$1(argument)) return false; - try { - construct(noop, empty, argument); - return true; - } catch (error) { - return false; - } -}; - -var isConstructorLegacy = function isConstructor(argument) { - if (!isCallable$1(argument)) return false; - switch (classof$1(argument)) { - case 'AsyncFunction': - case 'GeneratorFunction': - case 'AsyncGeneratorFunction': return false; - } - try { - // we can't check .prototype since constructors produced by .bind haven't it - // `Function#toString` throws on some built-it function in some legacy engines - // (for example, `DOMQuad` and similar in FF41-) - return INCORRECT_TO_STRING || !!exec$5(constructorRegExp, inspectSource(argument)); - } catch (error) { - return true; - } -}; - -isConstructorLegacy.sham = true; - -// `IsConstructor` abstract operation -// https://tc39.es/ecma262/#sec-isconstructor -var isConstructor$3 = !construct || fails$7(function () { - var called; - return isConstructorModern(isConstructorModern.call) - || !isConstructorModern(Object) - || !isConstructorModern(function () { called = true; }) - || called; -}) ? isConstructorLegacy : isConstructorModern; - -var toPropertyKey = toPropertyKey$3; -var definePropertyModule$1 = objectDefineProperty; -var createPropertyDescriptor = createPropertyDescriptor$5; - -var createProperty$4 = function (object, key, value) { - var propertyKey = toPropertyKey(key); - if (propertyKey in object) definePropertyModule$1.f(object, propertyKey, createPropertyDescriptor(0, value)); - else object[propertyKey] = value; -}; - -var fails$6 = fails$p; -var wellKnownSymbol$6 = wellKnownSymbol$i; -var V8_VERSION$1 = engineV8Version; - -var SPECIES$4 = wellKnownSymbol$6('species'); - -var arrayMethodHasSpeciesSupport$5 = function (METHOD_NAME) { - // We can't use this feature detection in V8 since it causes - // deoptimization and serious performance degradation - // https://github.com/zloirock/core-js/issues/677 - return V8_VERSION$1 >= 51 || !fails$6(function () { - var array = []; - var constructor = array.constructor = {}; - constructor[SPECIES$4] = function () { - return { foo: 1 }; - }; - return array[METHOD_NAME](Boolean).foo !== 1; - }); -}; - -var uncurryThis$7 = functionUncurryThis; - -var arraySlice$3 = uncurryThis$7([].slice); - -var $$9 = _export; -var isArray$3 = isArray$4; -var isConstructor$2 = isConstructor$3; -var isObject$3 = isObject$d; -var toAbsoluteIndex$2 = toAbsoluteIndex$4; -var lengthOfArrayLike$5 = lengthOfArrayLike$7; -var toIndexedObject = toIndexedObject$6; -var createProperty$3 = createProperty$4; -var wellKnownSymbol$5 = wellKnownSymbol$i; -var arrayMethodHasSpeciesSupport$4 = arrayMethodHasSpeciesSupport$5; -var un$Slice = arraySlice$3; - -var HAS_SPECIES_SUPPORT$3 = arrayMethodHasSpeciesSupport$4('slice'); - -var SPECIES$3 = wellKnownSymbol$5('species'); -var $Array$2 = Array; -var max$2 = Math.max; - -// `Array.prototype.slice` method -// https://tc39.es/ecma262/#sec-array.prototype.slice -// fallback for not array-like ES3 strings and DOM objects -$$9({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$3 }, { - slice: function slice(start, end) { - var O = toIndexedObject(this); - var length = lengthOfArrayLike$5(O); - var k = toAbsoluteIndex$2(start, length); - var fin = toAbsoluteIndex$2(end === undefined ? length : end, length); - // inline `ArraySpeciesCreate` for usage native `Array#slice` where it's possible - var Constructor, result, n; - if (isArray$3(O)) { - Constructor = O.constructor; - // cross-realm fallback - if (isConstructor$2(Constructor) && (Constructor === $Array$2 || isArray$3(Constructor.prototype))) { - Constructor = undefined; - } else if (isObject$3(Constructor)) { - Constructor = Constructor[SPECIES$3]; - if (Constructor === null) Constructor = undefined; - } - if (Constructor === $Array$2 || Constructor === undefined) { - return un$Slice(O, k, fin); - } - } - result = new (Constructor === undefined ? $Array$2 : Constructor)(max$2(fin - k, 0)); - for (n = 0; k < fin; k++, n++) if (k in O) createProperty$3(result, n, O[k]); - result.length = n; - return result; - } -}); - -var fails$5 = fails$p; - -var arrayMethodIsStrict$2 = function (METHOD_NAME, argument) { - var method = [][METHOD_NAME]; - return !!method && fails$5(function () { - // eslint-disable-next-line no-useless-call -- required for testing - method.call(null, argument || function () { return 1; }, 1); - }); -}; - -/* eslint-disable es-x/no-array-prototype-indexof -- required for testing */ -var $$8 = _export; -var uncurryThis$6 = functionUncurryThis; -var $IndexOf = arrayIncludes.indexOf; -var arrayMethodIsStrict$1 = arrayMethodIsStrict$2; - -var un$IndexOf = uncurryThis$6([].indexOf); - -var NEGATIVE_ZERO = !!un$IndexOf && 1 / un$IndexOf([1], 1, -0) < 0; -var STRICT_METHOD$1 = arrayMethodIsStrict$1('indexOf'); - -// `Array.prototype.indexOf` method -// https://tc39.es/ecma262/#sec-array.prototype.indexof -$$8({ target: 'Array', proto: true, forced: NEGATIVE_ZERO || !STRICT_METHOD$1 }, { - indexOf: function indexOf(searchElement /* , fromIndex = 0 */) { - var fromIndex = arguments.length > 1 ? arguments[1] : undefined; - return NEGATIVE_ZERO - // convert -0 to +0 - ? un$IndexOf(this, searchElement, fromIndex) || 0 - : $IndexOf(this, searchElement, fromIndex); - } -}); - -var isConstructor$1 = isConstructor$3; -var tryToString$1 = tryToString$3; - -var $TypeError$3 = TypeError; - -// `Assert: IsConstructor(argument) is true` -var aConstructor$1 = function (argument) { - if (isConstructor$1(argument)) return argument; - throw $TypeError$3(tryToString$1(argument) + ' is not a constructor'); -}; - -var anObject$2 = anObject$b; -var aConstructor = aConstructor$1; -var wellKnownSymbol$4 = wellKnownSymbol$i; - -var SPECIES$2 = wellKnownSymbol$4('species'); - -// `SpeciesConstructor` abstract operation -// https://tc39.es/ecma262/#sec-speciesconstructor -var speciesConstructor$1 = function (O, defaultConstructor) { - var C = anObject$2(O).constructor; - var S; - return C === undefined || (S = anObject$2(C)[SPECIES$2]) == undefined ? defaultConstructor : aConstructor(S); -}; - -var toAbsoluteIndex$1 = toAbsoluteIndex$4; -var lengthOfArrayLike$4 = lengthOfArrayLike$7; -var createProperty$2 = createProperty$4; - -var $Array$1 = Array; -var max$1 = Math.max; - -var arraySliceSimple = function (O, start, end) { - var length = lengthOfArrayLike$4(O); - var k = toAbsoluteIndex$1(start, length); - var fin = toAbsoluteIndex$1(end === undefined ? length : end, length); - var result = $Array$1(max$1(fin - k, 0)); - for (var n = 0; k < fin; k++, n++) createProperty$2(result, n, O[k]); - result.length = n; - return result; -}; - -var apply$1 = functionApply; -var call$2 = functionCall; -var uncurryThis$5 = functionUncurryThis; -var fixRegExpWellKnownSymbolLogic$1 = fixRegexpWellKnownSymbolLogic; -var isRegExp$1 = isRegexp; -var anObject$1 = anObject$b; -var requireObjectCoercible$1 = requireObjectCoercible$8; -var speciesConstructor = speciesConstructor$1; -var advanceStringIndex$1 = advanceStringIndex$3; -var toLength$1 = toLength$4; -var toString$3 = toString$a; -var getMethod$1 = getMethod$5; -var arraySlice$2 = arraySliceSimple; -var callRegExpExec = regexpExecAbstract; -var regexpExec = regexpExec$3; -var stickyHelpers$1 = regexpStickyHelpers; -var fails$4 = fails$p; - -var UNSUPPORTED_Y$1 = stickyHelpers$1.UNSUPPORTED_Y; -var MAX_UINT32 = 0xFFFFFFFF; -var min$1 = Math.min; -var $push = [].push; -var exec$4 = uncurryThis$5(/./.exec); -var push$2 = uncurryThis$5($push); -var stringSlice$1 = uncurryThis$5(''.slice); - -// Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec -// Weex JS has frozen built-in prototypes, so use try / catch wrapper -var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails$4(function () { - // eslint-disable-next-line regexp/no-empty-group -- required for testing - var re = /(?:)/; - var originalExec = re.exec; - re.exec = function () { return originalExec.apply(this, arguments); }; - var result = 'ab'.split(re); - return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b'; -}); - -// @@split logic -fixRegExpWellKnownSymbolLogic$1('split', function (SPLIT, nativeSplit, maybeCallNative) { - var internalSplit; - if ( - 'abbc'.split(/(b)*/)[1] == 'c' || - // eslint-disable-next-line regexp/no-empty-group -- required for testing - 'test'.split(/(?:)/, -1).length != 4 || - 'ab'.split(/(?:ab)*/).length != 2 || - '.'.split(/(.?)(.?)/).length != 4 || - // eslint-disable-next-line regexp/no-empty-capturing-group, regexp/no-empty-group -- required for testing - '.'.split(/()()/).length > 1 || - ''.split(/.?/).length - ) { - // based on es5-shim implementation, need to rework it - internalSplit = function (separator, limit) { - var string = toString$3(requireObjectCoercible$1(this)); - var lim = limit === undefined ? MAX_UINT32 : limit >>> 0; - if (lim === 0) return []; - if (separator === undefined) return [string]; - // If `separator` is not a regex, use native split - if (!isRegExp$1(separator)) { - return call$2(nativeSplit, string, separator, lim); - } - var output = []; - var flags = (separator.ignoreCase ? 'i' : '') + - (separator.multiline ? 'm' : '') + - (separator.unicode ? 'u' : '') + - (separator.sticky ? 'y' : ''); - var lastLastIndex = 0; - // Make `global` and avoid `lastIndex` issues by working with a copy - var separatorCopy = new RegExp(separator.source, flags + 'g'); - var match, lastIndex, lastLength; - while (match = call$2(regexpExec, separatorCopy, string)) { - lastIndex = separatorCopy.lastIndex; - if (lastIndex > lastLastIndex) { - push$2(output, stringSlice$1(string, lastLastIndex, match.index)); - if (match.length > 1 && match.index < string.length) apply$1($push, output, arraySlice$2(match, 1)); - lastLength = match[0].length; - lastLastIndex = lastIndex; - if (output.length >= lim) break; - } - if (separatorCopy.lastIndex === match.index) separatorCopy.lastIndex++; // Avoid an infinite loop - } - if (lastLastIndex === string.length) { - if (lastLength || !exec$4(separatorCopy, '')) push$2(output, ''); - } else push$2(output, stringSlice$1(string, lastLastIndex)); - return output.length > lim ? arraySlice$2(output, 0, lim) : output; - }; - // Chakra, V8 - } else if ('0'.split(undefined, 0).length) { - internalSplit = function (separator, limit) { - return separator === undefined && limit === 0 ? [] : call$2(nativeSplit, this, separator, limit); - }; - } else internalSplit = nativeSplit; - - return [ - // `String.prototype.split` method - // https://tc39.es/ecma262/#sec-string.prototype.split - function split(separator, limit) { - var O = requireObjectCoercible$1(this); - var splitter = separator == undefined ? undefined : getMethod$1(separator, SPLIT); - return splitter - ? call$2(splitter, separator, O, limit) - : call$2(internalSplit, toString$3(O), separator, limit); - }, - // `RegExp.prototype[@@split]` method - // https://tc39.es/ecma262/#sec-regexp.prototype-@@split - // - // NOTE: This cannot be properly polyfilled in engines that don't support - // the 'y' flag. - function (string, limit) { - var rx = anObject$1(this); - var S = toString$3(string); - var res = maybeCallNative(internalSplit, rx, S, limit, internalSplit !== nativeSplit); - - if (res.done) return res.value; - - var C = speciesConstructor(rx, RegExp); - - var unicodeMatching = rx.unicode; - var flags = (rx.ignoreCase ? 'i' : '') + - (rx.multiline ? 'm' : '') + - (rx.unicode ? 'u' : '') + - (UNSUPPORTED_Y$1 ? 'g' : 'y'); - - // ^(? + rx + ) is needed, in combination with some S slicing, to - // simulate the 'y' flag. - var splitter = new C(UNSUPPORTED_Y$1 ? '^(?:' + rx.source + ')' : rx, flags); - var lim = limit === undefined ? MAX_UINT32 : limit >>> 0; - if (lim === 0) return []; - if (S.length === 0) return callRegExpExec(splitter, S) === null ? [S] : []; - var p = 0; - var q = 0; - var A = []; - while (q < S.length) { - splitter.lastIndex = UNSUPPORTED_Y$1 ? 0 : q; - var z = callRegExpExec(splitter, UNSUPPORTED_Y$1 ? stringSlice$1(S, q) : S); - var e; - if ( - z === null || - (e = min$1(toLength$1(splitter.lastIndex + (UNSUPPORTED_Y$1 ? q : 0)), S.length)) === p - ) { - q = advanceStringIndex$1(S, q, unicodeMatching); - } else { - push$2(A, stringSlice$1(S, p, q)); - if (A.length === lim) return A; - for (var i = 1; i <= z.length - 1; i++) { - push$2(A, z[i]); - if (A.length === lim) return A; - } - q = p = e; - } - } - push$2(A, stringSlice$1(S, p)); - return A; - } - ]; -}, !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC, UNSUPPORTED_Y$1); - -var uncurryThis$4 = functionUncurryThis; -var aCallable$1 = aCallable$3; -var NATIVE_BIND = functionBindNative; - -var bind$1 = uncurryThis$4(uncurryThis$4.bind); - -// optional / simple context binding -var functionBindContext = function (fn, that) { - aCallable$1(fn); - return that === undefined ? fn : NATIVE_BIND ? bind$1(fn, that) : function (/* ...args */) { - return fn.apply(that, arguments); - }; -}; - -var isArray$2 = isArray$4; -var isConstructor = isConstructor$3; -var isObject$2 = isObject$d; -var wellKnownSymbol$3 = wellKnownSymbol$i; - -var SPECIES$1 = wellKnownSymbol$3('species'); -var $Array = Array; - -// a part of `ArraySpeciesCreate` abstract operation -// https://tc39.es/ecma262/#sec-arrayspeciescreate -var arraySpeciesConstructor$1 = function (originalArray) { - var C; - if (isArray$2(originalArray)) { - C = originalArray.constructor; - // cross-realm fallback - if (isConstructor(C) && (C === $Array || isArray$2(C.prototype))) C = undefined; - else if (isObject$2(C)) { - C = C[SPECIES$1]; - if (C === null) C = undefined; - } - } return C === undefined ? $Array : C; -}; - -var arraySpeciesConstructor = arraySpeciesConstructor$1; - -// `ArraySpeciesCreate` abstract operation -// https://tc39.es/ecma262/#sec-arrayspeciescreate -var arraySpeciesCreate$3 = function (originalArray, length) { - return new (arraySpeciesConstructor(originalArray))(length === 0 ? 0 : length); -}; - -var bind = functionBindContext; -var uncurryThis$3 = functionUncurryThis; -var IndexedObject = indexedObject; -var toObject$3 = toObject$7; -var lengthOfArrayLike$3 = lengthOfArrayLike$7; -var arraySpeciesCreate$2 = arraySpeciesCreate$3; - -var push$1 = uncurryThis$3([].push); - -// `Array.prototype.{ forEach, map, filter, some, every, find, findIndex, filterReject }` methods implementation -var createMethod = function (TYPE) { - var IS_MAP = TYPE == 1; - var IS_FILTER = TYPE == 2; - var IS_SOME = TYPE == 3; - var IS_EVERY = TYPE == 4; - var IS_FIND_INDEX = TYPE == 6; - var IS_FILTER_REJECT = TYPE == 7; - var NO_HOLES = TYPE == 5 || IS_FIND_INDEX; - return function ($this, callbackfn, that, specificCreate) { - var O = toObject$3($this); - var self = IndexedObject(O); - var boundFunction = bind(callbackfn, that); - var length = lengthOfArrayLike$3(self); - var index = 0; - var create = specificCreate || arraySpeciesCreate$2; - var target = IS_MAP ? create($this, length) : IS_FILTER || IS_FILTER_REJECT ? create($this, 0) : undefined; - var value, result; - for (;length > index; index++) if (NO_HOLES || index in self) { - value = self[index]; - result = boundFunction(value, index, O); - if (TYPE) { - if (IS_MAP) target[index] = result; // map - else if (result) switch (TYPE) { - case 3: return true; // some - case 5: return value; // find - case 6: return index; // findIndex - case 2: push$1(target, value); // filter - } else switch (TYPE) { - case 4: return false; // every - case 7: push$1(target, value); // filterReject - } - } - } - return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target; - }; -}; - -var arrayIteration = { - // `Array.prototype.forEach` method - // https://tc39.es/ecma262/#sec-array.prototype.foreach - forEach: createMethod(0), - // `Array.prototype.map` method - // https://tc39.es/ecma262/#sec-array.prototype.map - map: createMethod(1), - // `Array.prototype.filter` method - // https://tc39.es/ecma262/#sec-array.prototype.filter - filter: createMethod(2), - // `Array.prototype.some` method - // https://tc39.es/ecma262/#sec-array.prototype.some - some: createMethod(3), - // `Array.prototype.every` method - // https://tc39.es/ecma262/#sec-array.prototype.every - every: createMethod(4), - // `Array.prototype.find` method - // https://tc39.es/ecma262/#sec-array.prototype.find - find: createMethod(5), - // `Array.prototype.findIndex` method - // https://tc39.es/ecma262/#sec-array.prototype.findIndex - findIndex: createMethod(6), - // `Array.prototype.filterReject` method - // https://github.com/tc39/proposal-array-filtering - filterReject: createMethod(7) -}; - -var $$7 = _export; -var $map = arrayIteration.map; -var arrayMethodHasSpeciesSupport$3 = arrayMethodHasSpeciesSupport$5; - -var HAS_SPECIES_SUPPORT$2 = arrayMethodHasSpeciesSupport$3('map'); - -// `Array.prototype.map` method -// https://tc39.es/ecma262/#sec-array.prototype.map -// with adding support of @@species -$$7({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$2 }, { - map: function map(callbackfn /* , thisArg */) { - return $map(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); - } -}); - -var $TypeError$2 = TypeError; -var MAX_SAFE_INTEGER = 0x1FFFFFFFFFFFFF; // 2 ** 53 - 1 == 9007199254740991 - -var doesNotExceedSafeInteger$2 = function (it) { - if (it > MAX_SAFE_INTEGER) throw $TypeError$2('Maximum allowed index exceeded'); - return it; -}; - -var $$6 = _export; -var fails$3 = fails$p; -var isArray$1 = isArray$4; -var isObject$1 = isObject$d; -var toObject$2 = toObject$7; -var lengthOfArrayLike$2 = lengthOfArrayLike$7; -var doesNotExceedSafeInteger$1 = doesNotExceedSafeInteger$2; -var createProperty$1 = createProperty$4; -var arraySpeciesCreate$1 = arraySpeciesCreate$3; -var arrayMethodHasSpeciesSupport$2 = arrayMethodHasSpeciesSupport$5; -var wellKnownSymbol$2 = wellKnownSymbol$i; -var V8_VERSION = engineV8Version; - -var IS_CONCAT_SPREADABLE = wellKnownSymbol$2('isConcatSpreadable'); - -// We can't use this feature detection in V8 since it causes -// deoptimization and serious performance degradation -// https://github.com/zloirock/core-js/issues/679 -var IS_CONCAT_SPREADABLE_SUPPORT = V8_VERSION >= 51 || !fails$3(function () { - var array = []; - array[IS_CONCAT_SPREADABLE] = false; - return array.concat()[0] !== array; -}); - -var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport$2('concat'); - -var isConcatSpreadable = function (O) { - if (!isObject$1(O)) return false; - var spreadable = O[IS_CONCAT_SPREADABLE]; - return spreadable !== undefined ? !!spreadable : isArray$1(O); -}; - -var FORCED$1 = !IS_CONCAT_SPREADABLE_SUPPORT || !SPECIES_SUPPORT; - -// `Array.prototype.concat` method -// https://tc39.es/ecma262/#sec-array.prototype.concat -// with adding support of @@isConcatSpreadable and @@species -$$6({ target: 'Array', proto: true, arity: 1, forced: FORCED$1 }, { - // eslint-disable-next-line no-unused-vars -- required for `.length` - concat: function concat(arg) { - var O = toObject$2(this); - var A = arraySpeciesCreate$1(O, 0); - var n = 0; - var i, k, length, len, E; - for (i = -1, length = arguments.length; i < length; i++) { - E = i === -1 ? O : arguments[i]; - if (isConcatSpreadable(E)) { - len = lengthOfArrayLike$2(E); - doesNotExceedSafeInteger$1(n + len); - for (k = 0; k < len; k++, n++) if (k in E) createProperty$1(A, n, E[k]); - } else { - doesNotExceedSafeInteger$1(n + 1); - createProperty$1(A, n++, E); - } - } - A.length = n; - return A; - } -}); - -var common$2 = {}; - -var call$1 = functionCall; -var fixRegExpWellKnownSymbolLogic = fixRegexpWellKnownSymbolLogic; -var anObject = anObject$b; -var toLength = toLength$4; -var toString$2 = toString$a; -var requireObjectCoercible = requireObjectCoercible$8; -var getMethod = getMethod$5; -var advanceStringIndex = advanceStringIndex$3; -var regExpExec = regexpExecAbstract; - -// @@match logic -fixRegExpWellKnownSymbolLogic('match', function (MATCH, nativeMatch, maybeCallNative) { - return [ - // `String.prototype.match` method - // https://tc39.es/ecma262/#sec-string.prototype.match - function match(regexp) { - var O = requireObjectCoercible(this); - var matcher = regexp == undefined ? undefined : getMethod(regexp, MATCH); - return matcher ? call$1(matcher, regexp, O) : new RegExp(regexp)[MATCH](toString$2(O)); - }, - // `RegExp.prototype[@@match]` method - // https://tc39.es/ecma262/#sec-regexp.prototype-@@match - function (string) { - var rx = anObject(this); - var S = toString$2(string); - var res = maybeCallNative(nativeMatch, rx, S); - - if (res.done) return res.value; - - if (!rx.global) return regExpExec(rx, S); - - var fullUnicode = rx.unicode; - rx.lastIndex = 0; - var A = []; - var n = 0; - var result; - while ((result = regExpExec(rx, S)) !== null) { - var matchStr = toString$2(result[0]); - A[n] = matchStr; - if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode); - n++; - } - return n === 0 ? null : A; - } - ]; -}); - -var old = {}; - -var hasRequiredOld; - -function requireOld() { - if (hasRequiredOld) return old; - hasRequiredOld = 1; - var pathModule = require$$2__default["default"]; - var isWindows = process.platform === 'win32'; - var fs = require$$1__default["default"]; - var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG); - - function rethrow() { - var callback; - - if (DEBUG) { - var backtrace = new Error(); - callback = debugCallback; - } else callback = missingCallback; - - return callback; - - function debugCallback(err) { - if (err) { - backtrace.message = err.message; - err = backtrace; - missingCallback(err); - } - } - - function missingCallback(err) { - if (err) { - if (process.throwDeprecation) throw err;else if (!process.noDeprecation) { - var msg = 'fs: missing callback ' + (err.stack || err.message); - if (process.traceDeprecation) console.trace(msg);else console.error(msg); - } - } - } - } - - function maybeCallback(cb) { - return typeof cb === 'function' ? cb : rethrow(); - } - - pathModule.normalize; - - if (isWindows) { - var nextPartRe = /(.*?)(?:[\/\\]+|$)/g; - } else { - var nextPartRe = /(.*?)(?:[\/]+|$)/g; - } - - if (isWindows) { - var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/; - } else { - var splitRootRe = /^[\/]*/; - } - - old.realpathSync = function realpathSync(p, cache) { - p = pathModule.resolve(p); - - if (cache && Object.prototype.hasOwnProperty.call(cache, p)) { - return cache[p]; - } - - var original = p, - seenLinks = {}, - knownHard = {}; - var pos; - var current; - var base; - var previous; - start(); - - function start() { - var m = splitRootRe.exec(p); - pos = m[0].length; - current = m[0]; - base = m[0]; - previous = ''; - - if (isWindows && !knownHard[base]) { - fs.lstatSync(base); - knownHard[base] = true; - } - } - - while (pos < p.length) { - nextPartRe.lastIndex = pos; - var result = nextPartRe.exec(p); - previous = current; - current += result[0]; - base = previous + result[1]; - pos = nextPartRe.lastIndex; - - if (knownHard[base] || cache && cache[base] === base) { - continue; - } - - var resolvedLink; - - if (cache && Object.prototype.hasOwnProperty.call(cache, base)) { - resolvedLink = cache[base]; - } else { - var stat = fs.lstatSync(base); - - if (!stat.isSymbolicLink()) { - knownHard[base] = true; - if (cache) cache[base] = base; - continue; - } - - var linkTarget = null; - - if (!isWindows) { - var id = stat.dev.toString(32) + ':' + stat.ino.toString(32); - - if (seenLinks.hasOwnProperty(id)) { - linkTarget = seenLinks[id]; - } - } - - if (linkTarget === null) { - fs.statSync(base); - linkTarget = fs.readlinkSync(base); - } - - resolvedLink = pathModule.resolve(previous, linkTarget); - if (cache) cache[base] = resolvedLink; - if (!isWindows) seenLinks[id] = linkTarget; - } - - p = pathModule.resolve(resolvedLink, p.slice(pos)); - start(); - } - - if (cache) cache[original] = p; - return p; - }; - - old.realpath = function realpath(p, cache, cb) { - if (typeof cb !== 'function') { - cb = maybeCallback(cache); - cache = null; - } - - p = pathModule.resolve(p); - - if (cache && Object.prototype.hasOwnProperty.call(cache, p)) { - return process.nextTick(cb.bind(null, null, cache[p])); - } - - var original = p, - seenLinks = {}, - knownHard = {}; - var pos; - var current; - var base; - var previous; - start(); - - function start() { - var m = splitRootRe.exec(p); - pos = m[0].length; - current = m[0]; - base = m[0]; - previous = ''; - - if (isWindows && !knownHard[base]) { - fs.lstat(base, function (err) { - if (err) return cb(err); - knownHard[base] = true; - LOOP(); - }); - } else { - process.nextTick(LOOP); - } - } - - function LOOP() { - if (pos >= p.length) { - if (cache) cache[original] = p; - return cb(null, p); - } - - nextPartRe.lastIndex = pos; - var result = nextPartRe.exec(p); - previous = current; - current += result[0]; - base = previous + result[1]; - pos = nextPartRe.lastIndex; - - if (knownHard[base] || cache && cache[base] === base) { - return process.nextTick(LOOP); - } - - if (cache && Object.prototype.hasOwnProperty.call(cache, base)) { - return gotResolvedLink(cache[base]); - } - - return fs.lstat(base, gotStat); - } - - function gotStat(err, stat) { - if (err) return cb(err); - - if (!stat.isSymbolicLink()) { - knownHard[base] = true; - if (cache) cache[base] = base; - return process.nextTick(LOOP); - } - - if (!isWindows) { - var id = stat.dev.toString(32) + ':' + stat.ino.toString(32); - - if (seenLinks.hasOwnProperty(id)) { - return gotTarget(null, seenLinks[id], base); - } - } - - fs.stat(base, function (err) { - if (err) return cb(err); - fs.readlink(base, function (err, target) { - if (!isWindows) seenLinks[id] = target; - gotTarget(err, target); - }); - }); - } - - function gotTarget(err, target, base) { - if (err) return cb(err); - var resolvedLink = pathModule.resolve(previous, target); - if (cache) cache[base] = resolvedLink; - gotResolvedLink(resolvedLink); - } - - function gotResolvedLink(resolvedLink) { - p = pathModule.resolve(resolvedLink, p.slice(pos)); - start(); - } - }; - - return old; -} - -var fs_realpath; -var hasRequiredFs_realpath; - -function requireFs_realpath() { - if (hasRequiredFs_realpath) return fs_realpath; - hasRequiredFs_realpath = 1; - fs_realpath = realpath; - realpath.realpath = realpath; - realpath.sync = realpathSync; - realpath.realpathSync = realpathSync; - realpath.monkeypatch = monkeypatch; - realpath.unmonkeypatch = unmonkeypatch; - var fs = require$$1__default["default"]; - var origRealpath = fs.realpath; - var origRealpathSync = fs.realpathSync; - var version = process.version; - var ok = /^v[0-5]\./.test(version); - var old = requireOld(); - - function newError(er) { - return er && er.syscall === 'realpath' && (er.code === 'ELOOP' || er.code === 'ENOMEM' || er.code === 'ENAMETOOLONG'); - } - - function realpath(p, cache, cb) { - if (ok) { - return origRealpath(p, cache, cb); - } - - if (typeof cache === 'function') { - cb = cache; - cache = null; - } - - origRealpath(p, cache, function (er, result) { - if (newError(er)) { - old.realpath(p, cache, cb); - } else { - cb(er, result); - } - }); - } - - function realpathSync(p, cache) { - if (ok) { - return origRealpathSync(p, cache); - } - - try { - return origRealpathSync(p, cache); - } catch (er) { - if (newError(er)) { - return old.realpathSync(p, cache); - } else { - throw er; - } - } - } - - function monkeypatch() { - fs.realpath = realpath; - fs.realpathSync = realpathSync; - } - - function unmonkeypatch() { - fs.realpath = origRealpath; - fs.realpathSync = origRealpathSync; - } - - return fs_realpath; -} - -var $$5 = _export; -var $filter = arrayIteration.filter; -var arrayMethodHasSpeciesSupport$1 = arrayMethodHasSpeciesSupport$5; - -var HAS_SPECIES_SUPPORT$1 = arrayMethodHasSpeciesSupport$1('filter'); - -// `Array.prototype.filter` method -// https://tc39.es/ecma262/#sec-array.prototype.filter -// with adding support of @@species -$$5({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT$1 }, { - filter: function filter(callbackfn /* , thisArg */) { - return $filter(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); - } -}); - -var getBuiltIn$1 = getBuiltIn$8; -var definePropertyModule = objectDefineProperty; -var wellKnownSymbol$1 = wellKnownSymbol$i; -var DESCRIPTORS$2 = descriptors; - -var SPECIES = wellKnownSymbol$1('species'); - -var setSpecies$1 = function (CONSTRUCTOR_NAME) { - var Constructor = getBuiltIn$1(CONSTRUCTOR_NAME); - var defineProperty = definePropertyModule.f; - - if (DESCRIPTORS$2 && Constructor && !Constructor[SPECIES]) { - defineProperty(Constructor, SPECIES, { - configurable: true, - get: function () { return this; } - }); - } -}; - -var DESCRIPTORS$1 = descriptors; -var global$1 = global$g; -var uncurryThis$2 = functionUncurryThis; -var isForced = isForced_1; -var inheritIfRequired = inheritIfRequired$2; -var createNonEnumerableProperty = createNonEnumerableProperty$7; -var getOwnPropertyNames = objectGetOwnPropertyNames.f; -var isPrototypeOf = objectIsPrototypeOf; -var isRegExp = isRegexp; -var toString$1 = toString$a; -var getRegExpFlags = regexpGetFlags; -var stickyHelpers = regexpStickyHelpers; -var proxyAccessor = proxyAccessor$2; -var defineBuiltIn = defineBuiltIn$5; -var fails$2 = fails$p; -var hasOwn = hasOwnProperty_1; -var enforceInternalState = internalState.enforce; -var setSpecies = setSpecies$1; -var wellKnownSymbol = wellKnownSymbol$i; -var UNSUPPORTED_DOT_ALL$1 = regexpUnsupportedDotAll; -var UNSUPPORTED_NCG = regexpUnsupportedNcg; - -var MATCH = wellKnownSymbol('match'); -var NativeRegExp = global$1.RegExp; -var RegExpPrototype$1 = NativeRegExp.prototype; -var SyntaxError = global$1.SyntaxError; -var exec$3 = uncurryThis$2(RegExpPrototype$1.exec); -var charAt$1 = uncurryThis$2(''.charAt); -var replace$1 = uncurryThis$2(''.replace); -var stringIndexOf = uncurryThis$2(''.indexOf); -var stringSlice = uncurryThis$2(''.slice); -// TODO: Use only proper RegExpIdentifierName -var IS_NCG = /^\?<[^\s\d!#%&*+<=>@^][^\s!#%&*+<=>@^]*>/; -var re1 = /a/g; -var re2 = /a/g; - -// "new" should create a new object, old webkit bug -var CORRECT_NEW = new NativeRegExp(re1) !== re1; - -var MISSED_STICKY = stickyHelpers.MISSED_STICKY; -var UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y; - -var BASE_FORCED = DESCRIPTORS$1 && - (!CORRECT_NEW || MISSED_STICKY || UNSUPPORTED_DOT_ALL$1 || UNSUPPORTED_NCG || fails$2(function () { - re2[MATCH] = false; - // RegExp constructor can alter flags and IsRegExp works correct with @@match - return NativeRegExp(re1) != re1 || NativeRegExp(re2) == re2 || NativeRegExp(re1, 'i') != '/a/i'; - })); - -var handleDotAll = function (string) { - var length = string.length; - var index = 0; - var result = ''; - var brackets = false; - var chr; - for (; index <= length; index++) { - chr = charAt$1(string, index); - if (chr === '\\') { - result += chr + charAt$1(string, ++index); - continue; - } - if (!brackets && chr === '.') { - result += '[\\s\\S]'; - } else { - if (chr === '[') { - brackets = true; - } else if (chr === ']') { - brackets = false; - } result += chr; - } - } return result; -}; - -var handleNCG = function (string) { - var length = string.length; - var index = 0; - var result = ''; - var named = []; - var names = {}; - var brackets = false; - var ncg = false; - var groupid = 0; - var groupname = ''; - var chr; - for (; index <= length; index++) { - chr = charAt$1(string, index); - if (chr === '\\') { - chr = chr + charAt$1(string, ++index); - } else if (chr === ']') { - brackets = false; - } else if (!brackets) switch (true) { - case chr === '[': - brackets = true; - break; - case chr === '(': - if (exec$3(IS_NCG, stringSlice(string, index + 1))) { - index += 2; - ncg = true; - } - result += chr; - groupid++; - continue; - case chr === '>' && ncg: - if (groupname === '' || hasOwn(names, groupname)) { - throw new SyntaxError('Invalid capture group name'); - } - names[groupname] = true; - named[named.length] = [groupname, groupid]; - ncg = false; - groupname = ''; - continue; - } - if (ncg) groupname += chr; - else result += chr; - } return [result, named]; -}; - -// `RegExp` constructor -// https://tc39.es/ecma262/#sec-regexp-constructor -if (isForced('RegExp', BASE_FORCED)) { - var RegExpWrapper = function RegExp(pattern, flags) { - var thisIsRegExp = isPrototypeOf(RegExpPrototype$1, this); - var patternIsRegExp = isRegExp(pattern); - var flagsAreUndefined = flags === undefined; - var groups = []; - var rawPattern = pattern; - var rawFlags, dotAll, sticky, handled, result, state; - - if (!thisIsRegExp && patternIsRegExp && flagsAreUndefined && pattern.constructor === RegExpWrapper) { - return pattern; - } - - if (patternIsRegExp || isPrototypeOf(RegExpPrototype$1, pattern)) { - pattern = pattern.source; - if (flagsAreUndefined) flags = getRegExpFlags(rawPattern); - } - - pattern = pattern === undefined ? '' : toString$1(pattern); - flags = flags === undefined ? '' : toString$1(flags); - rawPattern = pattern; - - if (UNSUPPORTED_DOT_ALL$1 && 'dotAll' in re1) { - dotAll = !!flags && stringIndexOf(flags, 's') > -1; - if (dotAll) flags = replace$1(flags, /s/g, ''); - } - - rawFlags = flags; - - if (MISSED_STICKY && 'sticky' in re1) { - sticky = !!flags && stringIndexOf(flags, 'y') > -1; - if (sticky && UNSUPPORTED_Y) flags = replace$1(flags, /y/g, ''); - } - - if (UNSUPPORTED_NCG) { - handled = handleNCG(pattern); - pattern = handled[0]; - groups = handled[1]; - } - - result = inheritIfRequired(NativeRegExp(pattern, flags), thisIsRegExp ? this : RegExpPrototype$1, RegExpWrapper); - - if (dotAll || sticky || groups.length) { - state = enforceInternalState(result); - if (dotAll) { - state.dotAll = true; - state.raw = RegExpWrapper(handleDotAll(pattern), rawFlags); - } - if (sticky) state.sticky = true; - if (groups.length) state.groups = groups; - } - - if (pattern !== rawPattern) try { - // fails in old engines, but we have no alternatives for unsupported regex syntax - createNonEnumerableProperty(result, 'source', rawPattern === '' ? '(?:)' : rawPattern); - } catch (error) { /* empty */ } - - return result; - }; - - for (var keys = getOwnPropertyNames(NativeRegExp), index = 0; keys.length > index;) { - proxyAccessor(RegExpWrapper, NativeRegExp, keys[index++]); - } - - RegExpPrototype$1.constructor = RegExpWrapper; - RegExpWrapper.prototype = RegExpPrototype$1; - defineBuiltIn(global$1, 'RegExp', RegExpWrapper, { constructor: true }); -} - -// https://tc39.es/ecma262/#sec-get-regexp-@@species -setSpecies('RegExp'); - -var makeBuiltIn = makeBuiltIn$3.exports; -var defineProperty = objectDefineProperty; - -var defineBuiltInAccessor$1 = function (target, name, descriptor) { - if (descriptor.get) makeBuiltIn(descriptor.get, name, { getter: true }); - if (descriptor.set) makeBuiltIn(descriptor.set, name, { setter: true }); - return defineProperty.f(target, name, descriptor); -}; - -var DESCRIPTORS = descriptors; -var UNSUPPORTED_DOT_ALL = regexpUnsupportedDotAll; -var classof = classofRaw$1; -var defineBuiltInAccessor = defineBuiltInAccessor$1; -var getInternalState = internalState.get; - -var RegExpPrototype = RegExp.prototype; -var $TypeError$1 = TypeError; - -// `RegExp.prototype.dotAll` getter -// https://tc39.es/ecma262/#sec-get-regexp.prototype.dotall -if (DESCRIPTORS && UNSUPPORTED_DOT_ALL) { - defineBuiltInAccessor(RegExpPrototype, 'dotAll', { - configurable: true, - get: function dotAll() { - if (this === RegExpPrototype) return undefined; - // We can't use InternalStateModule.getterFor because - // we don't add metadata for regexps created by a literal. - if (classof(this) === 'RegExp') { - return !!getInternalState(this).dotAll; - } - throw $TypeError$1('Incompatible receiver, RegExp required'); - } - }); -} - -var concatMap; -var hasRequiredConcatMap; - -function requireConcatMap() { - if (hasRequiredConcatMap) return concatMap; - hasRequiredConcatMap = 1; - - concatMap = function concatMap(xs, fn) { - var res = []; - - for (var i = 0; i < xs.length; i++) { - var x = fn(xs[i], i); - if (isArray(x)) res.push.apply(res, x);else res.push(x); - } - - return res; - }; - - var isArray = Array.isArray || function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]'; - }; - - return concatMap; -} - -var balancedMatch; -var hasRequiredBalancedMatch; - -function requireBalancedMatch() { - if (hasRequiredBalancedMatch) return balancedMatch; - hasRequiredBalancedMatch = 1; - - balancedMatch = balanced; - - function balanced(a, b, str) { - if (a instanceof RegExp) a = maybeMatch(a, str); - if (b instanceof RegExp) b = maybeMatch(b, str); - var r = range(a, b, str); - return r && { - start: r[0], - end: r[1], - pre: str.slice(0, r[0]), - body: str.slice(r[0] + a.length, r[1]), - post: str.slice(r[1] + b.length) - }; - } - - function maybeMatch(reg, str) { - var m = str.match(reg); - return m ? m[0] : null; - } - - balanced.range = range; - - function range(a, b, str) { - var begs, beg, left, right, result; - var ai = str.indexOf(a); - var bi = str.indexOf(b, ai + 1); - var i = ai; - - if (ai >= 0 && bi > 0) { - begs = []; - left = str.length; - - while (i >= 0 && !result) { - if (i == ai) { - begs.push(i); - ai = str.indexOf(a, i + 1); - } else if (begs.length == 1) { - result = [begs.pop(), bi]; - } else { - beg = begs.pop(); - - if (beg < left) { - left = beg; - right = bi; - } - - bi = str.indexOf(b, i + 1); - } - - i = ai < bi && ai >= 0 ? ai : bi; - } - - if (begs.length) { - result = [left, right]; - } - } - - return result; - } - - return balancedMatch; -} - -var braceExpansion; -var hasRequiredBraceExpansion; - -function requireBraceExpansion() { - if (hasRequiredBraceExpansion) return braceExpansion; - hasRequiredBraceExpansion = 1; - var concatMap = requireConcatMap(); - var balanced = requireBalancedMatch(); - braceExpansion = expandTop; - var escSlash = '\0SLASH' + Math.random() + '\0'; - var escOpen = '\0OPEN' + Math.random() + '\0'; - var escClose = '\0CLOSE' + Math.random() + '\0'; - var escComma = '\0COMMA' + Math.random() + '\0'; - var escPeriod = '\0PERIOD' + Math.random() + '\0'; - - function numeric(str) { - return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0); - } - - function escapeBraces(str) { - return str.split('\\\\').join(escSlash).split('\\{').join(escOpen).split('\\}').join(escClose).split('\\,').join(escComma).split('\\.').join(escPeriod); - } - - function unescapeBraces(str) { - return str.split(escSlash).join('\\').split(escOpen).join('{').split(escClose).join('}').split(escComma).join(',').split(escPeriod).join('.'); - } - - function parseCommaParts(str) { - if (!str) return ['']; - var parts = []; - var m = balanced('{', '}', str); - if (!m) return str.split(','); - var pre = m.pre; - var body = m.body; - var post = m.post; - var p = pre.split(','); - p[p.length - 1] += '{' + body + '}'; - var postParts = parseCommaParts(post); - - if (post.length) { - p[p.length - 1] += postParts.shift(); - p.push.apply(p, postParts); - } - - parts.push.apply(parts, p); - return parts; - } - - function expandTop(str) { - if (!str) return []; - - if (str.substr(0, 2) === '{}') { - str = '\\{\\}' + str.substr(2); - } - - return expand(escapeBraces(str), true).map(unescapeBraces); - } - - function embrace(str) { - return '{' + str + '}'; - } - - function isPadded(el) { - return /^-?0\d/.test(el); - } - - function lte(i, y) { - return i <= y; - } - - function gte(i, y) { - return i >= y; - } - - function expand(str, isTop) { - var expansions = []; - var m = balanced('{', '}', str); - if (!m || /\$$/.test(m.pre)) return [str]; - var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body); - var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body); - var isSequence = isNumericSequence || isAlphaSequence; - var isOptions = m.body.indexOf(',') >= 0; - - if (!isSequence && !isOptions) { - if (m.post.match(/,.*\}/)) { - str = m.pre + '{' + m.body + escClose + m.post; - return expand(str); - } - - return [str]; - } - - var n; - - if (isSequence) { - n = m.body.split(/\.\./); - } else { - n = parseCommaParts(m.body); - - if (n.length === 1) { - n = expand(n[0], false).map(embrace); - - if (n.length === 1) { - var post = m.post.length ? expand(m.post, false) : ['']; - return post.map(function (p) { - return m.pre + n[0] + p; - }); - } - } - } - - var pre = m.pre; - var post = m.post.length ? expand(m.post, false) : ['']; - var N; - - if (isSequence) { - var x = numeric(n[0]); - var y = numeric(n[1]); - var width = Math.max(n[0].length, n[1].length); - var incr = n.length == 3 ? Math.abs(numeric(n[2])) : 1; - var test = lte; - var reverse = y < x; - - if (reverse) { - incr *= -1; - test = gte; - } - - var pad = n.some(isPadded); - N = []; - - for (var i = x; test(i, y); i += incr) { - var c; - - if (isAlphaSequence) { - c = String.fromCharCode(i); - if (c === '\\') c = ''; - } else { - c = String(i); - - if (pad) { - var need = width - c.length; - - if (need > 0) { - var z = new Array(need + 1).join('0'); - if (i < 0) c = '-' + z + c.slice(1);else c = z + c; - } - } - } - - N.push(c); - } - } else { - N = concatMap(n, function (el) { - return expand(el, false); - }); - } - - for (var j = 0; j < N.length; j++) { - for (var k = 0; k < post.length; k++) { - var expansion = pre + N[j] + post[k]; - if (!isTop || isSequence || expansion) expansions.push(expansion); - } - } - - return expansions; - } - - return braceExpansion; -} - -var minimatch_1; -var hasRequiredMinimatch; - -function requireMinimatch() { - if (hasRequiredMinimatch) return minimatch_1; - hasRequiredMinimatch = 1; - minimatch_1 = minimatch; - minimatch.Minimatch = Minimatch; - var path = { - sep: '/' - }; - - try { - path = require('path'); - } catch (er) {} - - var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}; - var expand = requireBraceExpansion(); - var plTypes = { - '!': { - open: '(?:(?!(?:', - close: '))[^/]*?)' - }, - '?': { - open: '(?:', - close: ')?' - }, - '+': { - open: '(?:', - close: ')+' - }, - '*': { - open: '(?:', - close: ')*' - }, - '@': { - open: '(?:', - close: ')' - } - }; - var qmark = '[^/]'; - var star = qmark + '*?'; - var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?'; - var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?'; - var reSpecials = charSet('().*{}+?[]^$\\!'); - - function charSet(s) { - return s.split('').reduce(function (set, c) { - set[c] = true; - return set; - }, {}); - } - - var slashSplit = /\/+/; - minimatch.filter = filter; - - function filter(pattern, options) { - options = options || {}; - return function (p, i, list) { - return minimatch(p, pattern, options); - }; - } - - function ext(a, b) { - a = a || {}; - b = b || {}; - var t = {}; - Object.keys(b).forEach(function (k) { - t[k] = b[k]; - }); - Object.keys(a).forEach(function (k) { - t[k] = a[k]; - }); - return t; - } - - minimatch.defaults = function (def) { - if (!def || !Object.keys(def).length) return minimatch; - var orig = minimatch; - - var m = function minimatch(p, pattern, options) { - return orig.minimatch(p, pattern, ext(def, options)); - }; - - m.Minimatch = function Minimatch(pattern, options) { - return new orig.Minimatch(pattern, ext(def, options)); - }; - - return m; - }; - - Minimatch.defaults = function (def) { - if (!def || !Object.keys(def).length) return Minimatch; - return minimatch.defaults(def).Minimatch; - }; - - function minimatch(p, pattern, options) { - if (typeof pattern !== 'string') { - throw new TypeError('glob pattern string required'); - } - - if (!options) options = {}; - - if (!options.nocomment && pattern.charAt(0) === '#') { - return false; - } - - if (pattern.trim() === '') return p === ''; - return new Minimatch(pattern, options).match(p); - } - - function Minimatch(pattern, options) { - if (!(this instanceof Minimatch)) { - return new Minimatch(pattern, options); - } - - if (typeof pattern !== 'string') { - throw new TypeError('glob pattern string required'); - } - - if (!options) options = {}; - pattern = pattern.trim(); - - if (path.sep !== '/') { - pattern = pattern.split(path.sep).join('/'); - } - - this.options = options; - this.set = []; - this.pattern = pattern; - this.regexp = null; - this.negate = false; - this.comment = false; - this.empty = false; - this.make(); - } - - Minimatch.prototype.debug = function () {}; - - Minimatch.prototype.make = make; - - function make() { - if (this._made) return; - var pattern = this.pattern; - var options = this.options; - - if (!options.nocomment && pattern.charAt(0) === '#') { - this.comment = true; - return; - } - - if (!pattern) { - this.empty = true; - return; - } - - this.parseNegate(); - var set = this.globSet = this.braceExpand(); - if (options.debug) this.debug = console.error; - this.debug(this.pattern, set); - set = this.globParts = set.map(function (s) { - return s.split(slashSplit); - }); - this.debug(this.pattern, set); - set = set.map(function (s, si, set) { - return s.map(this.parse, this); - }, this); - this.debug(this.pattern, set); - set = set.filter(function (s) { - return s.indexOf(false) === -1; - }); - this.debug(this.pattern, set); - this.set = set; - } - - Minimatch.prototype.parseNegate = parseNegate; - - function parseNegate() { - var pattern = this.pattern; - var negate = false; - var options = this.options; - var negateOffset = 0; - if (options.nonegate) return; - - for (var i = 0, l = pattern.length; i < l && pattern.charAt(i) === '!'; i++) { - negate = !negate; - negateOffset++; - } - - if (negateOffset) this.pattern = pattern.substr(negateOffset); - this.negate = negate; - } - - minimatch.braceExpand = function (pattern, options) { - return braceExpand(pattern, options); - }; - - Minimatch.prototype.braceExpand = braceExpand; - - function braceExpand(pattern, options) { - if (!options) { - if (this instanceof Minimatch) { - options = this.options; - } else { - options = {}; - } - } - - pattern = typeof pattern === 'undefined' ? this.pattern : pattern; - - if (typeof pattern === 'undefined') { - throw new TypeError('undefined pattern'); - } - - if (options.nobrace || !pattern.match(/\{.*\}/)) { - return [pattern]; - } - - return expand(pattern); - } - - Minimatch.prototype.parse = parse; - var SUBPARSE = {}; - - function parse(pattern, isSub) { - if (pattern.length > 1024 * 64) { - throw new TypeError('pattern is too long'); - } - - var options = this.options; - if (!options.noglobstar && pattern === '**') return GLOBSTAR; - if (pattern === '') return ''; - var re = ''; - var hasMagic = !!options.nocase; - var escaping = false; - var patternListStack = []; - var negativeLists = []; - var stateChar; - var inClass = false; - var reClassStart = -1; - var classStart = -1; - var patternStart = pattern.charAt(0) === '.' ? '' : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))' : '(?!\\.)'; - var self = this; - - function clearStateChar() { - if (stateChar) { - switch (stateChar) { - case '*': - re += star; - hasMagic = true; - break; - - case '?': - re += qmark; - hasMagic = true; - break; - - default: - re += '\\' + stateChar; - break; - } - - self.debug('clearStateChar %j %j', stateChar, re); - stateChar = false; - } - } - - for (var i = 0, len = pattern.length, c; i < len && (c = pattern.charAt(i)); i++) { - this.debug('%s\t%s %s %j', pattern, i, re, c); - - if (escaping && reSpecials[c]) { - re += '\\' + c; - escaping = false; - continue; - } - - switch (c) { - case '/': - return false; - - case '\\': - clearStateChar(); - escaping = true; - continue; - - case '?': - case '*': - case '+': - case '@': - case '!': - this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c); - - if (inClass) { - this.debug(' in class'); - if (c === '!' && i === classStart + 1) c = '^'; - re += c; - continue; - } - - self.debug('call clearStateChar %j', stateChar); - clearStateChar(); - stateChar = c; - if (options.noext) clearStateChar(); - continue; - - case '(': - if (inClass) { - re += '('; - continue; - } - - if (!stateChar) { - re += '\\('; - continue; - } - - patternListStack.push({ - type: stateChar, - start: i - 1, - reStart: re.length, - open: plTypes[stateChar].open, - close: plTypes[stateChar].close - }); - re += stateChar === '!' ? '(?:(?!(?:' : '(?:'; - this.debug('plType %j %j', stateChar, re); - stateChar = false; - continue; - - case ')': - if (inClass || !patternListStack.length) { - re += '\\)'; - continue; - } - - clearStateChar(); - hasMagic = true; - var pl = patternListStack.pop(); - re += pl.close; - - if (pl.type === '!') { - negativeLists.push(pl); - } - - pl.reEnd = re.length; - continue; - - case '|': - if (inClass || !patternListStack.length || escaping) { - re += '\\|'; - escaping = false; - continue; - } - - clearStateChar(); - re += '|'; - continue; - - case '[': - clearStateChar(); - - if (inClass) { - re += '\\' + c; - continue; - } - - inClass = true; - classStart = i; - reClassStart = re.length; - re += c; - continue; - - case ']': - if (i === classStart + 1 || !inClass) { - re += '\\' + c; - escaping = false; - continue; - } - - if (inClass) { - var cs = pattern.substring(classStart + 1, i); - - try { - RegExp('[' + cs + ']'); - } catch (er) { - var sp = this.parse(cs, SUBPARSE); - re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'; - hasMagic = hasMagic || sp[1]; - inClass = false; - continue; - } - } - - hasMagic = true; - inClass = false; - re += c; - continue; - - default: - clearStateChar(); - - if (escaping) { - escaping = false; - } else if (reSpecials[c] && !(c === '^' && inClass)) { - re += '\\'; - } - - re += c; - } - } - - if (inClass) { - cs = pattern.substr(classStart + 1); - sp = this.parse(cs, SUBPARSE); - re = re.substr(0, reClassStart) + '\\[' + sp[0]; - hasMagic = hasMagic || sp[1]; - } - - for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) { - var tail = re.slice(pl.reStart + pl.open.length); - this.debug('setting tail', re, pl); - tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) { - if (!$2) { - $2 = '\\'; - } - - return $1 + $1 + $2 + '|'; - }); - this.debug('tail=%j\n %s', tail, tail, pl, re); - var t = pl.type === '*' ? star : pl.type === '?' ? qmark : '\\' + pl.type; - hasMagic = true; - re = re.slice(0, pl.reStart) + t + '\\(' + tail; - } - - clearStateChar(); - - if (escaping) { - re += '\\\\'; - } - - var addPatternStart = false; - - switch (re.charAt(0)) { - case '.': - case '[': - case '(': - addPatternStart = true; - } - - for (var n = negativeLists.length - 1; n > -1; n--) { - var nl = negativeLists[n]; - var nlBefore = re.slice(0, nl.reStart); - var nlFirst = re.slice(nl.reStart, nl.reEnd - 8); - var nlLast = re.slice(nl.reEnd - 8, nl.reEnd); - var nlAfter = re.slice(nl.reEnd); - nlLast += nlAfter; - var openParensBefore = nlBefore.split('(').length - 1; - var cleanAfter = nlAfter; - - for (i = 0; i < openParensBefore; i++) { - cleanAfter = cleanAfter.replace(/\)[+*?]?/, ''); - } - - nlAfter = cleanAfter; - var dollar = ''; - - if (nlAfter === '' && isSub !== SUBPARSE) { - dollar = '$'; - } - - var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast; - re = newRe; - } - - if (re !== '' && hasMagic) { - re = '(?=.)' + re; - } - - if (addPatternStart) { - re = patternStart + re; - } - - if (isSub === SUBPARSE) { - return [re, hasMagic]; - } - - if (!hasMagic) { - return globUnescape(pattern); - } - - var flags = options.nocase ? 'i' : ''; - - try { - var regExp = new RegExp('^' + re + '$', flags); - } catch (er) { - return new RegExp('$.'); - } - - regExp._glob = pattern; - regExp._src = re; - return regExp; - } - - minimatch.makeRe = function (pattern, options) { - return new Minimatch(pattern, options || {}).makeRe(); - }; - - Minimatch.prototype.makeRe = makeRe; - - function makeRe() { - if (this.regexp || this.regexp === false) return this.regexp; - var set = this.set; - - if (!set.length) { - this.regexp = false; - return this.regexp; - } - - var options = this.options; - var twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot; - var flags = options.nocase ? 'i' : ''; - var re = set.map(function (pattern) { - return pattern.map(function (p) { - return p === GLOBSTAR ? twoStar : typeof p === 'string' ? regExpEscape(p) : p._src; - }).join('\\\/'); - }).join('|'); - re = '^(?:' + re + ')$'; - if (this.negate) re = '^(?!' + re + ').*$'; - - try { - this.regexp = new RegExp(re, flags); - } catch (ex) { - this.regexp = false; - } - - return this.regexp; - } - - minimatch.match = function (list, pattern, options) { - options = options || {}; - var mm = new Minimatch(pattern, options); - list = list.filter(function (f) { - return mm.match(f); - }); - - if (mm.options.nonull && !list.length) { - list.push(pattern); - } - - return list; - }; - - Minimatch.prototype.match = match; - - function match(f, partial) { - this.debug('match', f, this.pattern); - if (this.comment) return false; - if (this.empty) return f === ''; - if (f === '/' && partial) return true; - var options = this.options; - - if (path.sep !== '/') { - f = f.split(path.sep).join('/'); - } - - f = f.split(slashSplit); - this.debug(this.pattern, 'split', f); - var set = this.set; - this.debug(this.pattern, 'set', set); - var filename; - var i; - - for (i = f.length - 1; i >= 0; i--) { - filename = f[i]; - if (filename) break; - } - - for (i = 0; i < set.length; i++) { - var pattern = set[i]; - var file = f; - - if (options.matchBase && pattern.length === 1) { - file = [filename]; - } - - var hit = this.matchOne(file, pattern, partial); - - if (hit) { - if (options.flipNegate) return true; - return !this.negate; - } - } - - if (options.flipNegate) return false; - return this.negate; - } - - Minimatch.prototype.matchOne = function (file, pattern, partial) { - var options = this.options; - this.debug('matchOne', { - 'this': this, - file: file, - pattern: pattern - }); - this.debug('matchOne', file.length, pattern.length); - - for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) { - this.debug('matchOne loop'); - var p = pattern[pi]; - var f = file[fi]; - this.debug(pattern, p, f); - if (p === false) return false; - - if (p === GLOBSTAR) { - this.debug('GLOBSTAR', [pattern, p, f]); - var fr = fi; - var pr = pi + 1; - - if (pr === pl) { - this.debug('** at the end'); - - for (; fi < fl; fi++) { - if (file[fi] === '.' || file[fi] === '..' || !options.dot && file[fi].charAt(0) === '.') return false; - } - - return true; - } - - while (fr < fl) { - var swallowee = file[fr]; - this.debug('\nglobstar while', file, fr, pattern, pr, swallowee); - - if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) { - this.debug('globstar found match!', fr, fl, swallowee); - return true; - } else { - if (swallowee === '.' || swallowee === '..' || !options.dot && swallowee.charAt(0) === '.') { - this.debug('dot detected!', file, fr, pattern, pr); - break; - } - - this.debug('globstar swallow a segment, and continue'); - fr++; - } - } - - if (partial) { - this.debug('\n>>> no match, partial?', file, fr, pattern, pr); - if (fr === fl) return true; - } - - return false; - } - - var hit; - - if (typeof p === 'string') { - if (options.nocase) { - hit = f.toLowerCase() === p.toLowerCase(); - } else { - hit = f === p; - } - - this.debug('string match', p, f, hit); - } else { - hit = f.match(p); - this.debug('pattern match', p, f, hit); - } - - if (!hit) return false; - } - - if (fi === fl && pi === pl) { - return true; - } else if (fi === fl) { - return partial; - } else if (pi === pl) { - var emptyFileEnd = fi === fl - 1 && file[fi] === ''; - return emptyFileEnd; - } - - throw new Error('wtf?'); - }; - - function globUnescape(s) { - return s.replace(/\\(.)/g, '$1'); - } - - function regExpEscape(s) { - return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); - } - - return minimatch_1; -} - -var inherits = {exports: {}}; - -var inherits_browser = {exports: {}}; - -var hasRequiredInherits_browser; - -function requireInherits_browser() { - if (hasRequiredInherits_browser) return inherits_browser.exports; - hasRequiredInherits_browser = 1; - - if (typeof Object.create === 'function') { - inherits_browser.exports = function inherits(ctor, superCtor) { - if (superCtor) { - ctor.super_ = superCtor; - ctor.prototype = Object.create(superCtor.prototype, { - constructor: { - value: ctor, - enumerable: false, - writable: true, - configurable: true - } - }); - } - }; - } else { - inherits_browser.exports = function inherits(ctor, superCtor) { - if (superCtor) { - ctor.super_ = superCtor; - - var TempCtor = function TempCtor() {}; - - TempCtor.prototype = superCtor.prototype; - ctor.prototype = new TempCtor(); - ctor.prototype.constructor = ctor; - } - }; - } - - return inherits_browser.exports; -} - -var hasRequiredInherits; - -function requireInherits() { - if (hasRequiredInherits) return inherits.exports; - hasRequiredInherits = 1; - - (function (module) { - try { - var util = require('util'); - - if (typeof util.inherits !== 'function') throw ''; - module.exports = util.inherits; - } catch (e) { - module.exports = requireInherits_browser(); - } - })(inherits); - - return inherits.exports; -} - -var pathIsAbsolute = {exports: {}}; - -var hasRequiredPathIsAbsolute; - -function requirePathIsAbsolute() { - if (hasRequiredPathIsAbsolute) return pathIsAbsolute.exports; - hasRequiredPathIsAbsolute = 1; - - function posix(path) { - return path.charAt(0) === '/'; - } - - function win32(path) { - var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/; - var result = splitDeviceRe.exec(path); - var device = result[1] || ''; - var isUnc = Boolean(device && device.charAt(1) !== ':'); - return Boolean(result[2] || isUnc); - } - - pathIsAbsolute.exports = process.platform === 'win32' ? win32 : posix; - pathIsAbsolute.exports.posix = posix; - pathIsAbsolute.exports.win32 = win32; - return pathIsAbsolute.exports; -} - -var tryToString = tryToString$3; - -var $TypeError = TypeError; - -var deletePropertyOrThrow$2 = function (O, P) { - if (!delete O[P]) throw $TypeError('Cannot delete property ' + tryToString(P) + ' of ' + tryToString(O)); -}; - -var arraySlice$1 = arraySliceSimple; - -var floor = Math.floor; - -var mergeSort = function (array, comparefn) { - var length = array.length; - var middle = floor(length / 2); - return length < 8 ? insertionSort(array, comparefn) : merge( - array, - mergeSort(arraySlice$1(array, 0, middle), comparefn), - mergeSort(arraySlice$1(array, middle), comparefn), - comparefn - ); -}; - -var insertionSort = function (array, comparefn) { - var length = array.length; - var i = 1; - var element, j; - - while (i < length) { - j = i; - element = array[i]; - while (j && comparefn(array[j - 1], element) > 0) { - array[j] = array[--j]; - } - if (j !== i++) array[j] = element; - } return array; -}; - -var merge = function (array, left, right, comparefn) { - var llength = left.length; - var rlength = right.length; - var lindex = 0; - var rindex = 0; - - while (lindex < llength || rindex < rlength) { - array[lindex + rindex] = (lindex < llength && rindex < rlength) - ? comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++] - : lindex < llength ? left[lindex++] : right[rindex++]; - } return array; -}; - -var arraySort = mergeSort; - -var userAgent$1 = engineUserAgent; - -var firefox = userAgent$1.match(/firefox\/(\d+)/i); - -var engineFfVersion = !!firefox && +firefox[1]; - -var UA = engineUserAgent; - -var engineIsIeOrEdge = /MSIE|Trident/.test(UA); - -var userAgent = engineUserAgent; - -var webkit = userAgent.match(/AppleWebKit\/(\d+)\./); - -var engineWebkitVersion = !!webkit && +webkit[1]; - -var $$4 = _export; -var uncurryThis$1 = functionUncurryThis; -var aCallable = aCallable$3; -var toObject$1 = toObject$7; -var lengthOfArrayLike$1 = lengthOfArrayLike$7; -var deletePropertyOrThrow$1 = deletePropertyOrThrow$2; -var toString = toString$a; -var fails$1 = fails$p; -var internalSort = arraySort; -var arrayMethodIsStrict = arrayMethodIsStrict$2; -var FF = engineFfVersion; -var IE_OR_EDGE = engineIsIeOrEdge; -var V8 = engineV8Version; -var WEBKIT = engineWebkitVersion; - -var test$1 = []; -var un$Sort = uncurryThis$1(test$1.sort); -var push = uncurryThis$1(test$1.push); - -// IE8- -var FAILS_ON_UNDEFINED = fails$1(function () { - test$1.sort(undefined); -}); -// V8 bug -var FAILS_ON_NULL = fails$1(function () { - test$1.sort(null); -}); -// Old WebKit -var STRICT_METHOD = arrayMethodIsStrict('sort'); - -var STABLE_SORT = !fails$1(function () { - // feature detection can be too slow, so check engines versions - if (V8) return V8 < 70; - if (FF && FF > 3) return; - if (IE_OR_EDGE) return true; - if (WEBKIT) return WEBKIT < 603; - - var result = ''; - var code, chr, value, index; - - // generate an array with more 512 elements (Chakra and old V8 fails only in this case) - for (code = 65; code < 76; code++) { - chr = String.fromCharCode(code); - - switch (code) { - case 66: case 69: case 70: case 72: value = 3; break; - case 68: case 71: value = 4; break; - default: value = 2; - } - - for (index = 0; index < 47; index++) { - test$1.push({ k: chr + index, v: value }); - } - } - - test$1.sort(function (a, b) { return b.v - a.v; }); - - for (index = 0; index < test$1.length; index++) { - chr = test$1[index].k.charAt(0); - if (result.charAt(result.length - 1) !== chr) result += chr; - } - - return result !== 'DGBEFHACIJK'; -}); - -var FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD || !STABLE_SORT; - -var getSortCompare = function (comparefn) { - return function (x, y) { - if (y === undefined) return -1; - if (x === undefined) return 1; - if (comparefn !== undefined) return +comparefn(x, y) || 0; - return toString(x) > toString(y) ? 1 : -1; - }; -}; - -// `Array.prototype.sort` method -// https://tc39.es/ecma262/#sec-array.prototype.sort -$$4({ target: 'Array', proto: true, forced: FORCED }, { - sort: function sort(comparefn) { - if (comparefn !== undefined) aCallable(comparefn); - - var array = toObject$1(this); - - if (STABLE_SORT) return comparefn === undefined ? un$Sort(array) : un$Sort(array, comparefn); - - var items = []; - var arrayLength = lengthOfArrayLike$1(array); - var itemsLength, index; - - for (index = 0; index < arrayLength; index++) { - if (index in array) push(items, array[index]); - } - - internalSort(items, getSortCompare(comparefn)); - - itemsLength = items.length; - index = 0; - - while (index < itemsLength) array[index] = items[index++]; - while (index < arrayLength) deletePropertyOrThrow$1(array, index++); - - return array; - } -}); - -var common$1 = {}; - -var hasRequiredCommon$1; - -function requireCommon$1() { - if (hasRequiredCommon$1) return common$1; - hasRequiredCommon$1 = 1; - common$1.setopts = setopts; - common$1.ownProp = ownProp; - common$1.makeAbs = makeAbs; - common$1.finish = finish; - common$1.mark = mark; - common$1.isIgnored = isIgnored; - common$1.childrenIgnored = childrenIgnored; - - function ownProp(obj, field) { - return Object.prototype.hasOwnProperty.call(obj, field); - } - - var path = require$$2__default["default"]; - var minimatch = requireMinimatch(); - var isAbsolute = requirePathIsAbsolute(); - var Minimatch = minimatch.Minimatch; - - function alphasort(a, b) { - return a.localeCompare(b, 'en'); - } - - function setupIgnores(self, options) { - self.ignore = options.ignore || []; - if (!Array.isArray(self.ignore)) self.ignore = [self.ignore]; - - if (self.ignore.length) { - self.ignore = self.ignore.map(ignoreMap); - } - } - - function ignoreMap(pattern) { - var gmatcher = null; - - if (pattern.slice(-3) === '/**') { - var gpattern = pattern.replace(/(\/\*\*)+$/, ''); - gmatcher = new Minimatch(gpattern, { - dot: true - }); - } - - return { - matcher: new Minimatch(pattern, { - dot: true - }), - gmatcher: gmatcher - }; - } - - function setopts(self, pattern, options) { - if (!options) options = {}; - - if (options.matchBase && -1 === pattern.indexOf("/")) { - if (options.noglobstar) { - throw new Error("base matching requires globstar"); - } - - pattern = "**/" + pattern; - } - - self.silent = !!options.silent; - self.pattern = pattern; - self.strict = options.strict !== false; - self.realpath = !!options.realpath; - self.realpathCache = options.realpathCache || Object.create(null); - self.follow = !!options.follow; - self.dot = !!options.dot; - self.mark = !!options.mark; - self.nodir = !!options.nodir; - if (self.nodir) self.mark = true; - self.sync = !!options.sync; - self.nounique = !!options.nounique; - self.nonull = !!options.nonull; - self.nosort = !!options.nosort; - self.nocase = !!options.nocase; - self.stat = !!options.stat; - self.noprocess = !!options.noprocess; - self.absolute = !!options.absolute; - self.maxLength = options.maxLength || Infinity; - self.cache = options.cache || Object.create(null); - self.statCache = options.statCache || Object.create(null); - self.symlinks = options.symlinks || Object.create(null); - setupIgnores(self, options); - self.changedCwd = false; - var cwd = process.cwd(); - if (!ownProp(options, "cwd")) self.cwd = cwd;else { - self.cwd = path.resolve(options.cwd); - self.changedCwd = self.cwd !== cwd; - } - self.root = options.root || path.resolve(self.cwd, "/"); - self.root = path.resolve(self.root); - if (process.platform === "win32") self.root = self.root.replace(/\\/g, "/"); - self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd); - if (process.platform === "win32") self.cwdAbs = self.cwdAbs.replace(/\\/g, "/"); - self.nomount = !!options.nomount; - options.nonegate = true; - options.nocomment = true; - self.minimatch = new Minimatch(pattern, options); - self.options = self.minimatch.options; - } - - function finish(self) { - var nou = self.nounique; - var all = nou ? [] : Object.create(null); - - for (var i = 0, l = self.matches.length; i < l; i++) { - var matches = self.matches[i]; - - if (!matches || Object.keys(matches).length === 0) { - if (self.nonull) { - var literal = self.minimatch.globSet[i]; - if (nou) all.push(literal);else all[literal] = true; - } - } else { - var m = Object.keys(matches); - if (nou) all.push.apply(all, m);else m.forEach(function (m) { - all[m] = true; - }); - } - } - - if (!nou) all = Object.keys(all); - if (!self.nosort) all = all.sort(alphasort); - - if (self.mark) { - for (var i = 0; i < all.length; i++) { - all[i] = self._mark(all[i]); - } - - if (self.nodir) { - all = all.filter(function (e) { - var notDir = !/\/$/.test(e); - var c = self.cache[e] || self.cache[makeAbs(self, e)]; - if (notDir && c) notDir = c !== 'DIR' && !Array.isArray(c); - return notDir; - }); - } - } - - if (self.ignore.length) all = all.filter(function (m) { - return !isIgnored(self, m); - }); - self.found = all; - } - - function mark(self, p) { - var abs = makeAbs(self, p); - var c = self.cache[abs]; - var m = p; - - if (c) { - var isDir = c === 'DIR' || Array.isArray(c); - var slash = p.slice(-1) === '/'; - if (isDir && !slash) m += '/';else if (!isDir && slash) m = m.slice(0, -1); - - if (m !== p) { - var mabs = makeAbs(self, m); - self.statCache[mabs] = self.statCache[abs]; - self.cache[mabs] = self.cache[abs]; - } - } - - return m; - } - - function makeAbs(self, f) { - var abs = f; - - if (f.charAt(0) === '/') { - abs = path.join(self.root, f); - } else if (isAbsolute(f) || f === '') { - abs = f; - } else if (self.changedCwd) { - abs = path.resolve(self.cwd, f); - } else { - abs = path.resolve(f); - } - - if (process.platform === 'win32') abs = abs.replace(/\\/g, '/'); - return abs; - } - - function isIgnored(self, path) { - if (!self.ignore.length) return false; - return self.ignore.some(function (item) { - return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path)); - }); - } - - function childrenIgnored(self, path) { - if (!self.ignore.length) return false; - return self.ignore.some(function (item) { - return !!(item.gmatcher && item.gmatcher.match(path)); - }); - } - - return common$1; -} - -var sync; -var hasRequiredSync; - -function requireSync() { - if (hasRequiredSync) return sync; - hasRequiredSync = 1; - sync = globSync; - globSync.GlobSync = GlobSync; - var fs = require$$1__default["default"]; - var rp = requireFs_realpath(); - var minimatch = requireMinimatch(); - minimatch.Minimatch; - requireGlob().Glob; - var path = require$$2__default["default"]; - var assert = require$$6__default["default"]; - var isAbsolute = requirePathIsAbsolute(); - var common = requireCommon$1(); - var setopts = common.setopts; - var ownProp = common.ownProp; - var childrenIgnored = common.childrenIgnored; - var isIgnored = common.isIgnored; - - function globSync(pattern, options) { - if (typeof options === 'function' || arguments.length === 3) throw new TypeError('callback provided to sync glob\n' + 'See: https://github.com/isaacs/node-glob/issues/167'); - return new GlobSync(pattern, options).found; - } - - function GlobSync(pattern, options) { - if (!pattern) throw new Error('must provide pattern'); - if (typeof options === 'function' || arguments.length === 3) throw new TypeError('callback provided to sync glob\n' + 'See: https://github.com/isaacs/node-glob/issues/167'); - if (!(this instanceof GlobSync)) return new GlobSync(pattern, options); - setopts(this, pattern, options); - if (this.noprocess) return this; - var n = this.minimatch.set.length; - this.matches = new Array(n); - - for (var i = 0; i < n; i++) { - this._process(this.minimatch.set[i], i, false); - } - - this._finish(); - } - - GlobSync.prototype._finish = function () { - assert(this instanceof GlobSync); - - if (this.realpath) { - var self = this; - this.matches.forEach(function (matchset, index) { - var set = self.matches[index] = Object.create(null); - - for (var p in matchset) { - try { - p = self._makeAbs(p); - var real = rp.realpathSync(p, self.realpathCache); - set[real] = true; - } catch (er) { - if (er.syscall === 'stat') set[self._makeAbs(p)] = true;else throw er; - } - } - }); - } - - common.finish(this); - }; - - GlobSync.prototype._process = function (pattern, index, inGlobStar) { - assert(this instanceof GlobSync); - var n = 0; - - while (typeof pattern[n] === 'string') { - n++; - } - - var prefix; - - switch (n) { - case pattern.length: - this._processSimple(pattern.join('/'), index); - - return; - - case 0: - prefix = null; - break; - - default: - prefix = pattern.slice(0, n).join('/'); - break; - } - - var remain = pattern.slice(n); - 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 (childrenIgnored(this, read)) return; - var isGlobStar = remain[0] === minimatch.GLOBSTAR; - if (isGlobStar) this._processGlobStar(prefix, read, abs, remain, index, inGlobStar);else this._processReaddir(prefix, read, abs, remain, index, inGlobStar); - }; - - GlobSync.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar) { - var entries = this._readdir(abs, inGlobStar); - - if (!entries) return; - 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); - } - } - - var len = matchedEntries.length; - if (len === 0) return; - - 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.slice(-1) !== '/') e = prefix + '/' + e;else e = prefix + e; - } - - if (e.charAt(0) === '/' && !this.nomount) { - e = path.join(this.root, e); - } - - this._emitMatch(index, e); - } - - return; - } - - remain.shift(); - - for (var i = 0; i < len; i++) { - var e = matchedEntries[i]; - var newPattern; - if (prefix) newPattern = [prefix, e];else newPattern = [e]; - - this._process(newPattern.concat(remain), index, inGlobStar); - } - }; - - GlobSync.prototype._emitMatch = function (index, e) { - if (isIgnored(this, e)) return; - - var abs = 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; - if (this.stat) this._stat(e); - }; - - GlobSync.prototype._readdirInGlobStar = function (abs) { - if (this.follow) return this._readdir(abs, false); - var entries; - var lstat; - - try { - lstat = fs.lstatSync(abs); - } catch (er) { - if (er.code === 'ENOENT') { - return null; - } - } - - var isSym = lstat && lstat.isSymbolicLink(); - this.symlinks[abs] = isSym; - if (!isSym && lstat && !lstat.isDirectory()) this.cache[abs] = 'FILE';else entries = this._readdir(abs, false); - return entries; - }; - - GlobSync.prototype._readdir = function (abs, inGlobStar) { - if (inGlobStar && !ownProp(this.symlinks, abs)) return this._readdirInGlobStar(abs); - - if (ownProp(this.cache, abs)) { - var c = this.cache[abs]; - if (!c || c === 'FILE') return null; - if (Array.isArray(c)) return c; - } - - try { - return this._readdirEntries(abs, fs.readdirSync(abs)); - } catch (er) { - this._readdirError(abs, er); - - return null; - } - }; - - GlobSync.prototype._readdirEntries = function (abs, entries) { - 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 entries; - }; - - GlobSync.prototype._readdirError = function (f, er) { - switch (er.code) { - case 'ENOTSUP': - case 'ENOTDIR': - 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; - throw error; - } - - break; - - case 'ENOENT': - case 'ELOOP': - case 'ENAMETOOLONG': - case 'UNKNOWN': - this.cache[this._makeAbs(f)] = false; - break; - - default: - this.cache[this._makeAbs(f)] = false; - if (this.strict) throw er; - if (!this.silent) console.error('glob error', er); - break; - } - }; - - GlobSync.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar) { - var entries = this._readdir(abs, inGlobStar); - - if (!entries) return; - var remainWithoutGlobStar = remain.slice(1); - var gspref = prefix ? [prefix] : []; - var noGlobStar = gspref.concat(remainWithoutGlobStar); - - this._process(noGlobStar, index, false); - - var len = entries.length; - var isSym = this.symlinks[abs]; - if (isSym && inGlobStar) return; - - for (var i = 0; i < len; i++) { - var e = entries[i]; - if (e.charAt(0) === '.' && !this.dot) continue; - var instead = gspref.concat(entries[i], remainWithoutGlobStar); - - this._process(instead, index, true); - - var below = gspref.concat(entries[i], remain); - - this._process(below, index, true); - } - }; - - GlobSync.prototype._processSimple = function (prefix, index) { - var exists = this._stat(prefix); - - if (!this.matches[index]) this.matches[index] = Object.create(null); - if (!exists) return; - - 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 += '/'; - } - } - - if (process.platform === 'win32') prefix = prefix.replace(/\\/g, '/'); - - this._emitMatch(index, prefix); - }; - - GlobSync.prototype._stat = function (f) { - var abs = this._makeAbs(f); - - var needDir = f.slice(-1) === '/'; - if (f.length > this.maxLength) return false; - - if (!this.stat && ownProp(this.cache, abs)) { - var c = this.cache[abs]; - if (Array.isArray(c)) c = 'DIR'; - if (!needDir || c === 'DIR') return c; - if (needDir && c === 'FILE') return false; - } - var stat = this.statCache[abs]; - - if (!stat) { - var lstat; - - try { - lstat = fs.lstatSync(abs); - } catch (er) { - if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) { - this.statCache[abs] = false; - return false; - } - } - - if (lstat && lstat.isSymbolicLink()) { - try { - stat = fs.statSync(abs); - } catch (er) { - stat = lstat; - } - } else { - stat = lstat; - } - } - - this.statCache[abs] = stat; - var c = true; - if (stat) c = stat.isDirectory() ? 'DIR' : 'FILE'; - this.cache[abs] = this.cache[abs] || c; - if (needDir && c === 'FILE') return false; - return c; - }; - - GlobSync.prototype._mark = function (p) { - return common.mark(this, p); - }; - - GlobSync.prototype._makeAbs = function (f) { - return common.makeAbs(this, f); - }; - - return sync; -} - -var $$3 = _export; -var toObject = toObject$7; -var toAbsoluteIndex = toAbsoluteIndex$4; -var toIntegerOrInfinity = toIntegerOrInfinity$5; -var lengthOfArrayLike = lengthOfArrayLike$7; -var doesNotExceedSafeInteger = doesNotExceedSafeInteger$2; -var arraySpeciesCreate = arraySpeciesCreate$3; -var createProperty = createProperty$4; -var deletePropertyOrThrow = deletePropertyOrThrow$2; -var arrayMethodHasSpeciesSupport = arrayMethodHasSpeciesSupport$5; - -var HAS_SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('splice'); - -var max = Math.max; -var min = Math.min; - -// `Array.prototype.splice` method -// https://tc39.es/ecma262/#sec-array.prototype.splice -// with adding support of @@species -$$3({ target: 'Array', proto: true, forced: !HAS_SPECIES_SUPPORT }, { - splice: function splice(start, deleteCount /* , ...items */) { - var O = toObject(this); - var len = lengthOfArrayLike(O); - var actualStart = toAbsoluteIndex(start, len); - var argumentsLength = arguments.length; - var insertCount, actualDeleteCount, A, k, from, to; - if (argumentsLength === 0) { - insertCount = actualDeleteCount = 0; - } else if (argumentsLength === 1) { - insertCount = 0; - actualDeleteCount = len - actualStart; - } else { - insertCount = argumentsLength - 2; - actualDeleteCount = min(max(toIntegerOrInfinity(deleteCount), 0), len - actualStart); - } - doesNotExceedSafeInteger(len + insertCount - actualDeleteCount); - A = arraySpeciesCreate(O, actualDeleteCount); - for (k = 0; k < actualDeleteCount; k++) { - from = actualStart + k; - if (from in O) createProperty(A, k, O[from]); - } - A.length = actualDeleteCount; - if (insertCount < actualDeleteCount) { - for (k = actualStart; k < len - actualDeleteCount; k++) { - from = k + actualDeleteCount; - to = k + insertCount; - if (from in O) O[to] = O[from]; - else deletePropertyOrThrow(O, to); - } - for (k = len; k > len - actualDeleteCount + insertCount; k--) deletePropertyOrThrow(O, k - 1); - } else if (insertCount > actualDeleteCount) { - for (k = len - actualDeleteCount; k > actualStart; k--) { - from = k + actualDeleteCount - 1; - to = k + insertCount - 1; - if (from in O) O[to] = O[from]; - else deletePropertyOrThrow(O, to); - } - } - for (k = 0; k < insertCount; k++) { - O[k + actualStart] = arguments[k + 2]; - } - O.length = len - actualDeleteCount + insertCount; - return A; - } -}); - -var wrappy_1; -var hasRequiredWrappy; - -function requireWrappy() { - if (hasRequiredWrappy) return wrappy_1; - hasRequiredWrappy = 1; - wrappy_1 = wrappy; - - function wrappy(fn, cb) { - if (fn && cb) return wrappy(fn)(cb); - if (typeof fn !== 'function') throw new TypeError('need wrapper function'); - Object.keys(fn).forEach(function (k) { - wrapper[k] = fn[k]; - }); - return wrapper; - - function wrapper() { - var args = new Array(arguments.length); - - for (var i = 0; i < args.length; i++) { - args[i] = arguments[i]; - } - - var ret = fn.apply(this, args); - var cb = args[args.length - 1]; - - if (typeof ret === 'function' && ret !== cb) { - Object.keys(cb).forEach(function (k) { - ret[k] = cb[k]; - }); - } - - return ret; - } - } - - return wrappy_1; -} - -var once = {exports: {}}; - -var hasRequiredOnce; - -function requireOnce() { - if (hasRequiredOnce) return once.exports; - hasRequiredOnce = 1; - var wrappy = requireWrappy(); - once.exports = wrappy(once$1); - once.exports.strict = wrappy(onceStrict); - once$1.proto = once$1(function () { - Object.defineProperty(Function.prototype, 'once', { - value: function value() { - return once$1(this); - }, - configurable: true - }); - Object.defineProperty(Function.prototype, 'onceStrict', { - value: function value() { - return onceStrict(this); - }, - configurable: true - }); - }); - - function once$1(fn) { - var f = function f() { - if (f.called) return f.value; - f.called = true; - return f.value = fn.apply(this, arguments); - }; - - f.called = false; - return f; - } - - function onceStrict(fn) { - var f = function f() { - if (f.called) throw new Error(f.onceError); - f.called = true; - return f.value = fn.apply(this, arguments); - }; - - var name = fn.name || 'Function wrapped with `once`'; - f.onceError = name + " shouldn't be called more than once"; - f.called = false; - return f; - } - - return once.exports; -} - -var inflight_1; -var hasRequiredInflight; - -function requireInflight() { - if (hasRequiredInflight) return inflight_1; - hasRequiredInflight = 1; - var wrappy = requireWrappy(); - var reqs = Object.create(null); - var once = requireOnce(); - inflight_1 = wrappy(inflight); - - function inflight(key, cb) { - if (reqs[key]) { - reqs[key].push(cb); - return null; - } else { - reqs[key] = [cb]; - return makeres(key); - } - } - - function makeres(key) { - return once(function RES() { - var cbs = reqs[key]; - var len = cbs.length; - var args = slice(arguments); - - try { - for (var i = 0; i < len; i++) { - cbs[i].apply(null, args); - } - } finally { - if (cbs.length > len) { - cbs.splice(0, len); - process.nextTick(function () { - RES.apply(null, args); - }); - } else { - delete reqs[key]; - } - } - }); - } - - function slice(args) { - var length = args.length; - var array = []; - - for (var i = 0; i < length; i++) array[i] = args[i]; - - return array; - } - - return inflight_1; -} - -var glob_1; -var hasRequiredGlob; - -function requireGlob() { - if (hasRequiredGlob) return glob_1; - hasRequiredGlob = 1; - glob_1 = glob; - var fs = require$$1__default["default"]; - var rp = requireFs_realpath(); - var minimatch = requireMinimatch(); - minimatch.Minimatch; - var inherits = requireInherits(); - var EE = require$$4__default["default"].EventEmitter; - var path = require$$2__default["default"]; - var assert = require$$6__default["default"]; - var isAbsolute = requirePathIsAbsolute(); - var globSync = requireSync(); - var common = requireCommon$1(); - var setopts = common.setopts; - var ownProp = common.ownProp; - var inflight = requireInflight(); - var childrenIgnored = common.childrenIgnored; - var isIgnored = common.isIgnored; - var once = requireOnce(); - - function glob(pattern, options, cb) { - if (typeof options === 'function') cb = options, options = {}; - if (!options) options = {}; - - if (options.sync) { - if (cb) throw new TypeError('callback provided to sync glob'); - return globSync(pattern, options); - } - - return new Glob(pattern, options, cb); - } - - glob.sync = globSync; - var GlobSync = glob.GlobSync = globSync.GlobSync; - glob.glob = glob; - - function extend(origin, add) { - if (add === null || typeof add !== 'object') { - return origin; - } - - var keys = Object.keys(add); - var i = keys.length; - - while (i--) { - origin[keys[i]] = add[keys[i]]; - } - - return origin; - } - - 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; - }; - - glob.Glob = Glob; - inherits(Glob, EE); - - function Glob(pattern, options, cb) { - if (typeof options === 'function') { - cb = options; - options = null; - } - - if (options && options.sync) { - if (cb) throw new TypeError('callback provided to sync glob'); - return new GlobSync(pattern, options); - } - - if (!(this instanceof Glob)) return new Glob(pattern, options, cb); - setopts(this, pattern, options); - this._didRealPath = false; - var n = this.minimatch.set.length; - this.matches = new Array(n); - - if (typeof cb === 'function') { - cb = once(cb); - this.on('error', cb); - this.on('end', function (matches) { - cb(null, matches); - }); - } - - var self = this; - this._processing = 0; - this._emitQueue = []; - this._processQueue = []; - this.paused = false; - if (this.noprocess) return this; - if (n === 0) return done(); - var sync = true; - - for (var i = 0; i < n; i++) { - this._process(this.minimatch.set[i], i, false, done); - } - - sync = false; - - function done() { - --self._processing; - - if (self._processing <= 0) { - if (sync) { - process.nextTick(function () { - self._finish(); - }); - } else { - self._finish(); - } - } - } - } - - Glob.prototype._finish = function () { - assert(this instanceof Glob); - if (this.aborted) return; - if (this.realpath && !this._didRealpath) return this._realpath(); - common.finish(this); - this.emit('end', this.found); - }; - - Glob.prototype._realpath = function () { - if (this._didRealpath) return; - this._didRealpath = true; - var n = this.matches.length; - if (n === 0) return this._finish(); - var self = this; - - for (var i = 0; i < this.matches.length; i++) this._realpathSet(i, next); - - function next() { - if (--n === 0) self._finish(); - } - }; - - 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(); - var set = this.matches[index] = Object.create(null); - found.forEach(function (p, i) { - 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); - - if (--n === 0) { - self.matches[index] = set; - cb(); - } - }); - }); - }; - - Glob.prototype._mark = function (p) { - return common.mark(this, p); - }; - - Glob.prototype._makeAbs = function (f) { - return common.makeAbs(this, f); - }; - - Glob.prototype.abort = function () { - this.aborted = true; - this.emit('abort'); - }; - - Glob.prototype.pause = function () { - if (!this.paused) { - this.paused = true; - this.emit('pause'); - } - }; - - 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]); - } - } - } - }; - - Glob.prototype._process = function (pattern, index, inGlobStar, cb) { - assert(this instanceof Glob); - assert(typeof cb === 'function'); - if (this.aborted) return; - this._processing++; - - if (this.paused) { - this._processQueue.push([pattern, index, inGlobStar, cb]); - - return; - } - - var n = 0; - - while (typeof pattern[n] === 'string') { - n++; - } - - var prefix; - - switch (n) { - case pattern.length: - this._processSimple(pattern.join('/'), index, cb); - - return; - - case 0: - prefix = null; - break; - - default: - prefix = pattern.slice(0, n).join('/'); - break; - } - - var remain = pattern.slice(n); - 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 (childrenIgnored(this, read)) return cb(); - 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); - }; - - 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); - }); - }; - - Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) { - if (!entries) return cb(); - 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); - } - } - - var len = matchedEntries.length; - if (len === 0) return cb(); - - 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); - } - - return cb(); - } - - remain.shift(); - - for (var i = 0; i < len; i++) { - var e = matchedEntries[i]; - - if (prefix) { - if (prefix !== '/') e = prefix + '/' + e;else e = prefix + e; - } - - this._process([e].concat(remain), index, inGlobStar, cb); - } - - 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; - } - - 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); - }; - - Glob.prototype._readdirInGlobStar = function (abs, cb) { - if (this.aborted) return; - 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 (!isSym && lstat && !lstat.isDirectory()) { - self.cache[abs] = 'FILE'; - cb(); - } else self._readdir(abs, false, cb); - } - }; - - Glob.prototype._readdir = function (abs, inGlobStar, cb) { - if (this.aborted) return; - cb = inflight('readdir\0' + abs + '\0' + inGlobStar, cb); - if (!cb) return; - 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); - } - 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 (!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; - - switch (er.code) { - case 'ENOTSUP': - case 'ENOTDIR': - 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': - case 'ELOOP': - case 'ENAMETOOLONG': - case 'UNKNOWN': - this.cache[this._makeAbs(f)] = false; - break; - - default: - this.cache[this._makeAbs(f)] = false; - - if (this.strict) { - this.emit('error', er); - 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) { - if (!entries) return cb(); - var remainWithoutGlobStar = remain.slice(1); - var gspref = prefix ? [prefix] : []; - var noGlobStar = gspref.concat(remainWithoutGlobStar); - - this._process(noGlobStar, index, false, cb); - - var isSym = this.symlinks[abs]; - var len = entries.length; - if (isSym && inGlobStar) return cb(); - - for (var i = 0; i < len; i++) { - var e = entries[i]; - if (e.charAt(0) === '.' && !this.dot) continue; - 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(); - }; - - Glob.prototype._processSimple = function (prefix, index, cb) { - 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) { - if (!this.matches[index]) this.matches[index] = Object.create(null); - if (!exists) return cb(); - - 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 += '/'; - } - } - - if (process.platform === 'win32') prefix = prefix.replace(/\\/g, '/'); - - this._emitMatch(index, prefix); - - cb(); - }; - - Glob.prototype._stat = function (f, cb) { - var abs = this._makeAbs(f); - - var needDir = f.slice(-1) === '/'; - if (f.length > this.maxLength) return cb(); - - if (!this.stat && ownProp(this.cache, abs)) { - var c = this.cache[abs]; - if (Array.isArray(c)) c = 'DIR'; - if (!needDir || c === 'DIR') return cb(null, c); - if (needDir && c === 'FILE') return cb(); - } - 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); - } - } - - var self = this; - var statcb = inflight('stat\0' + abs, lstatcb_); - if (statcb) fs.lstat(abs, statcb); - - function lstatcb_(er, lstat) { - if (lstat && lstat.isSymbolicLink()) { - 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); - } - } - }; - - Glob.prototype._stat2 = function (f, abs, er, stat, cb) { - if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) { - this.statCache[abs] = false; - return cb(); - } - - var needDir = f.slice(-1) === '/'; - this.statCache[abs] = stat; - if (abs.slice(-1) === '/' && stat && !stat.isDirectory()) return cb(null, false, stat); - var c = true; - if (stat) c = stat.isDirectory() ? 'DIR' : 'FILE'; - this.cache[abs] = this.cache[abs] || c; - if (needDir && c === 'FILE') return cb(); - return cb(null, c, stat); - }; - - return glob_1; -} - -var hasRequiredCommon; - -function requireCommon() { - if (hasRequiredCommon) return common$2; - hasRequiredCommon = 1; - - var os = require$$0__default["default"]; - var fs = require$$1__default["default"]; - var glob = requireGlob(); - var shell = requireShell(); - var shellMethods = Object.create(shell); - common$2.extend = Object.assign; - var isElectron = Boolean(process.versions.electron); - var DEFAULT_CONFIG = { - fatal: false, - globOptions: {}, - maxdepth: 255, - noglob: false, - silent: false, - verbose: false, - execPath: null, - bufLength: 64 * 1024 - }; - var config = { - reset: function reset() { - Object.assign(this, DEFAULT_CONFIG); - - if (!isElectron) { - this.execPath = process.execPath; - } - }, - resetForTesting: function resetForTesting() { - this.reset(); - this.silent = true; - } - }; - config.reset(); - common$2.config = config; - var state = { - error: null, - errorCode: 0, - currentCmd: 'shell.js' - }; - common$2.state = state; - delete process.env.OLDPWD; - - function isObject(a) { - return typeof a === 'object' && a !== null; - } - - common$2.isObject = isObject; - - function log() { - if (!config.silent) { - console.error.apply(console, arguments); - } - } - - common$2.log = log; - - function convertErrorOutput(msg) { - if (typeof msg !== 'string') { - throw new TypeError('input must be a string'); - } - - return msg.replace(/\\/g, '/'); - } - - common$2.convertErrorOutput = convertErrorOutput; - - function error(msg, _code, options) { - if (typeof msg !== 'string') throw new Error('msg must be a string'); - var DEFAULT_OPTIONS = { - continue: false, - code: 1, - prefix: state.currentCmd + ': ', - silent: false - }; - - if (typeof _code === 'number' && isObject(options)) { - options.code = _code; - } else if (isObject(_code)) { - options = _code; - } else if (typeof _code === 'number') { - options = { - code: _code - }; - } else if (typeof _code !== 'number') { - options = {}; - } - - options = Object.assign({}, DEFAULT_OPTIONS, options); - if (!state.errorCode) state.errorCode = options.code; - var logEntry = convertErrorOutput(options.prefix + msg); - state.error = state.error ? state.error + '\n' : ''; - state.error += logEntry; - if (config.fatal) throw new Error(logEntry); - if (msg.length > 0 && !options.silent) log(logEntry); - - if (!options.continue) { - throw { - msg: 'earlyExit', - retValue: new ShellString('', state.error, state.errorCode) - }; - } - } - - common$2.error = error; - - function ShellString(stdout, stderr, code) { - var that; - - if (stdout instanceof Array) { - that = stdout; - that.stdout = stdout.join('\n'); - if (stdout.length > 0) that.stdout += '\n'; - } else { - that = new String(stdout); - that.stdout = stdout; - } - - that.stderr = stderr; - that.code = code; - pipeMethods.forEach(function (cmd) { - that[cmd] = shellMethods[cmd].bind(that); - }); - return that; - } - - common$2.ShellString = ShellString; - - function parseOptions(opt, map, errorOptions) { - if (typeof opt !== 'string' && !isObject(opt)) { - throw new Error('options must be strings or key-value pairs'); - } else if (!isObject(map)) { - throw new Error('parseOptions() internal error: map must be an object'); - } else if (errorOptions && !isObject(errorOptions)) { - throw new Error('parseOptions() internal error: errorOptions must be object'); - } - - if (opt === '--') { - return {}; - } - - var options = {}; - Object.keys(map).forEach(function (letter) { - var optName = map[letter]; - - if (optName[0] !== '!') { - options[optName] = false; - } - }); - if (opt === '') return options; - - if (typeof opt === 'string') { - if (opt[0] !== '-') { - throw new Error("Options string must start with a '-'"); - } - - var chars = opt.slice(1).split(''); - chars.forEach(function (c) { - if (c in map) { - var optionName = map[c]; - - if (optionName[0] === '!') { - options[optionName.slice(1)] = false; - } else { - options[optionName] = true; - } - } else { - error('option not recognized: ' + c, errorOptions || {}); - } - }); - } else { - Object.keys(opt).forEach(function (key) { - var c = key[1]; - - if (c in map) { - var optionName = map[c]; - options[optionName] = opt[key]; - } else { - error('option not recognized: ' + c, errorOptions || {}); - } - }); - } - - return options; - } - - common$2.parseOptions = parseOptions; - - function expand(list) { - if (!Array.isArray(list)) { - throw new TypeError('must be an array'); - } - - var expanded = []; - list.forEach(function (listEl) { - if (typeof listEl !== 'string') { - expanded.push(listEl); - } else { - var ret; - - try { - ret = glob.sync(listEl, config.globOptions); - ret = ret.length > 0 ? ret : [listEl]; - } catch (e) { - ret = [listEl]; - } - - expanded = expanded.concat(ret); - } - }); - return expanded; - } - - common$2.expand = expand; - var buffer = typeof Buffer.alloc === 'function' ? function (len) { - return Buffer.alloc(len || config.bufLength); - } : function (len) { - return new Buffer(len || config.bufLength); - }; - common$2.buffer = buffer; - - function unlinkSync(file) { - try { - fs.unlinkSync(file); - } catch (e) { - if (e.code === 'EPERM') { - fs.chmodSync(file, '0666'); - fs.unlinkSync(file); - } else { - throw e; - } - } - } - - common$2.unlinkSync = unlinkSync; - - function statFollowLinks() { - return fs.statSync.apply(fs, arguments); - } - - common$2.statFollowLinks = statFollowLinks; - - function statNoFollowLinks() { - return fs.lstatSync.apply(fs, arguments); - } - - common$2.statNoFollowLinks = statNoFollowLinks; - - function randomFileName() { - function randomHash(count) { - if (count === 1) { - return parseInt(16 * Math.random(), 10).toString(16); - } - - var hash = ''; - - for (var i = 0; i < count; i++) { - hash += randomHash(1); - } - - return hash; - } - - return 'shelljs_' + randomHash(20); - } - - common$2.randomFileName = randomFileName; - - function wrap(cmd, fn, options) { - options = options || {}; - return function () { - var retValue = null; - state.currentCmd = cmd; - state.error = null; - state.errorCode = 0; - - try { - var args = [].slice.call(arguments, 0); - - if (config.verbose) { - console.error.apply(console, [cmd].concat(args)); - } - - state.pipedValue = this && typeof this.stdout === 'string' ? this.stdout : ''; - - if (options.unix === false) { - retValue = fn.apply(this, args); - } else { - if (isObject(args[0]) && args[0].constructor.name === 'Object') {} else if (args.length === 0 || typeof args[0] !== 'string' || args[0].length <= 1 || args[0][0] !== '-') { - args.unshift(''); - } - - args = args.reduce(function (accum, cur) { - if (Array.isArray(cur)) { - return accum.concat(cur); - } - - accum.push(cur); - return accum; - }, []); - args = args.map(function (arg) { - if (isObject(arg) && arg.constructor.name === 'String') { - return arg.toString(); - } - - return arg; - }); - var homeDir = os.homedir(); - args = args.map(function (arg) { - if (typeof arg === 'string' && arg.slice(0, 2) === '~/' || arg === '~') { - return arg.replace(/^~/, homeDir); - } - - return arg; - }); - - if (!config.noglob && options.allowGlobbing === true) { - args = args.slice(0, options.globStart).concat(expand(args.slice(options.globStart))); - } - - try { - if (isObject(options.cmdOptions)) { - args[0] = parseOptions(args[0], options.cmdOptions); - } - - retValue = fn.apply(this, args); - } catch (e) { - if (e.msg === 'earlyExit') { - retValue = e.retValue; - } else { - throw e; - } - } - } - } catch (e) { - if (!state.error) { - e.name = 'ShellJSInternalError'; - throw e; - } - - if (config.fatal) throw e; - } - - if (options.wrapOutput && (typeof retValue === 'string' || Array.isArray(retValue))) { - retValue = new ShellString(retValue, state.error, state.errorCode); - } - - state.currentCmd = 'shell.js'; - return retValue; - }; - } - - common$2.wrap = wrap; - - function _readFromPipe() { - return state.pipedValue; - } - - common$2.readFromPipe = _readFromPipe; - var DEFAULT_WRAP_OPTIONS = { - allowGlobbing: true, - canReceivePipe: false, - cmdOptions: null, - globStart: 1, - pipeOnly: false, - wrapOutput: true, - unix: true - }; - var pipeMethods = []; - - function _register(name, implementation, wrapOptions) { - wrapOptions = wrapOptions || {}; - Object.keys(wrapOptions).forEach(function (option) { - if (!DEFAULT_WRAP_OPTIONS.hasOwnProperty(option)) { - throw new Error("Unknown option '" + option + "'"); - } - - if (typeof wrapOptions[option] !== typeof DEFAULT_WRAP_OPTIONS[option]) { - throw new TypeError("Unsupported type '" + typeof wrapOptions[option] + "' for option '" + option + "'"); - } - }); - wrapOptions = Object.assign({}, DEFAULT_WRAP_OPTIONS, wrapOptions); - - if (shell.hasOwnProperty(name)) { - throw new Error('Command `' + name + '` already exists'); - } - - if (wrapOptions.pipeOnly) { - wrapOptions.canReceivePipe = true; - shellMethods[name] = wrap(name, implementation, wrapOptions); - } else { - shell[name] = wrap(name, implementation, wrapOptions); - } - - if (wrapOptions.canReceivePipe) { - pipeMethods.push(name); - } - } - - common$2.register = _register; - return common$2; -} - -var cat; -var hasRequiredCat; - -function requireCat() { - if (hasRequiredCat) return cat; - hasRequiredCat = 1; - var common = requireCommon(); - var fs = require$$1__default["default"]; - common.register('cat', _cat, { - canReceivePipe: true, - cmdOptions: { - 'n': 'number' - } - }); - - function _cat(options, files) { - var cat = common.readFromPipe(); - if (!files && !cat) common.error('no paths given'); - files = [].slice.call(arguments, 1); - files.forEach(function (file) { - if (!fs.existsSync(file)) { - common.error('no such file or directory: ' + file); - } else if (common.statFollowLinks(file).isDirectory()) { - common.error(file + ': Is a directory'); - } - - cat += fs.readFileSync(file, 'utf8'); - }); - - if (options.number) { - cat = addNumbers(cat); - } - - return cat; - } - - cat = _cat; - - function addNumbers(cat) { - var lines = cat.split('\n'); - var lastLine = lines.pop(); - lines = lines.map(function (line, i) { - return numberedLine(i + 1, line); - }); - - if (lastLine.length) { - lastLine = numberedLine(lines.length + 1, lastLine); - } - - lines.push(lastLine); - return lines.join('\n'); - } - - function numberedLine(n, line) { - var number = (' ' + n).slice(-6) + '\t'; - return number + line; - } - - return cat; -} - -var cd; -var hasRequiredCd; - -function requireCd() { - if (hasRequiredCd) return cd; - hasRequiredCd = 1; - var os = require$$0__default["default"]; - var common = requireCommon(); - common.register('cd', _cd, {}); - - function _cd(options, dir) { - if (!dir) dir = os.homedir(); - - if (dir === '-') { - if (!process.env.OLDPWD) { - common.error('could not find previous directory'); - } else { - dir = process.env.OLDPWD; - } - } - - try { - var curDir = process.cwd(); - process.chdir(dir); - process.env.OLDPWD = curDir; - } catch (e) { - var err; - - try { - common.statFollowLinks(dir); - err = 'not a directory: ' + dir; - } catch (e2) { - err = 'no such file or directory: ' + dir; - } - - if (err) common.error(err); - } - - return ''; - } - - cd = _cd; - return cd; -} - -var chmod; -var hasRequiredChmod; - -function requireChmod() { - if (hasRequiredChmod) return chmod; - hasRequiredChmod = 1; - var common = requireCommon(); - var fs = require$$1__default["default"]; - var path = require$$2__default["default"]; - - var PERMS = function (base) { - return { - OTHER_EXEC: base.EXEC, - OTHER_WRITE: base.WRITE, - OTHER_READ: base.READ, - GROUP_EXEC: base.EXEC << 3, - GROUP_WRITE: base.WRITE << 3, - GROUP_READ: base.READ << 3, - OWNER_EXEC: base.EXEC << 6, - OWNER_WRITE: base.WRITE << 6, - OWNER_READ: base.READ << 6, - STICKY: parseInt('01000', 8), - SETGID: parseInt('02000', 8), - SETUID: parseInt('04000', 8), - TYPE_MASK: parseInt('0770000', 8) - }; - }({ - EXEC: 1, - WRITE: 2, - READ: 4 - }); - - common.register('chmod', _chmod, {}); - - function _chmod(options, mode, filePattern) { - if (!filePattern) { - if (options.length > 0 && options.charAt(0) === '-') { - [].unshift.call(arguments, ''); - } else { - common.error('You must specify a file.'); - } - } - - options = common.parseOptions(options, { - 'R': 'recursive', - 'c': 'changes', - 'v': 'verbose' - }); - filePattern = [].slice.call(arguments, 2); - var files; - - if (options.recursive) { - files = []; - filePattern.forEach(function addFile(expandedFile) { - var stat = common.statNoFollowLinks(expandedFile); - - if (!stat.isSymbolicLink()) { - files.push(expandedFile); - - if (stat.isDirectory()) { - fs.readdirSync(expandedFile).forEach(function (child) { - addFile(expandedFile + '/' + child); - }); - } - } - }); - } else { - files = filePattern; - } - - files.forEach(function innerChmod(file) { - file = path.resolve(file); - - if (!fs.existsSync(file)) { - common.error('File not found: ' + file); - } - - if (options.recursive && common.statNoFollowLinks(file).isSymbolicLink()) { - return; - } - - var stat = common.statFollowLinks(file); - var isDir = stat.isDirectory(); - var perms = stat.mode; - var type = perms & PERMS.TYPE_MASK; - var newPerms = perms; - - if (isNaN(parseInt(mode, 8))) { - mode.split(',').forEach(function (symbolicMode) { - var pattern = /([ugoa]*)([=\+-])([rwxXst]*)/i; - var matches = pattern.exec(symbolicMode); - - if (matches) { - var applyTo = matches[1]; - var operator = matches[2]; - var change = matches[3]; - var changeOwner = applyTo.indexOf('u') !== -1 || applyTo === 'a' || applyTo === ''; - var changeGroup = applyTo.indexOf('g') !== -1 || applyTo === 'a' || applyTo === ''; - var changeOther = applyTo.indexOf('o') !== -1 || applyTo === 'a' || applyTo === ''; - var changeRead = change.indexOf('r') !== -1; - var changeWrite = change.indexOf('w') !== -1; - var changeExec = change.indexOf('x') !== -1; - var changeExecDir = change.indexOf('X') !== -1; - var changeSticky = change.indexOf('t') !== -1; - var changeSetuid = change.indexOf('s') !== -1; - - if (changeExecDir && isDir) { - changeExec = true; - } - - var mask = 0; - - if (changeOwner) { - mask |= (changeRead ? PERMS.OWNER_READ : 0) + (changeWrite ? PERMS.OWNER_WRITE : 0) + (changeExec ? PERMS.OWNER_EXEC : 0) + (changeSetuid ? PERMS.SETUID : 0); - } - - if (changeGroup) { - mask |= (changeRead ? PERMS.GROUP_READ : 0) + (changeWrite ? PERMS.GROUP_WRITE : 0) + (changeExec ? PERMS.GROUP_EXEC : 0) + (changeSetuid ? PERMS.SETGID : 0); - } - - if (changeOther) { - mask |= (changeRead ? PERMS.OTHER_READ : 0) + (changeWrite ? PERMS.OTHER_WRITE : 0) + (changeExec ? PERMS.OTHER_EXEC : 0); - } - - if (changeSticky) { - mask |= PERMS.STICKY; - } - - switch (operator) { - case '+': - newPerms |= mask; - break; - - case '-': - newPerms &= ~mask; - break; - - case '=': - newPerms = type + mask; - - if (common.statFollowLinks(file).isDirectory()) { - newPerms |= PERMS.SETUID + PERMS.SETGID & perms; - } - - break; - - default: - common.error('Could not recognize operator: `' + operator + '`'); - } - - if (options.verbose) { - console.log(file + ' -> ' + newPerms.toString(8)); - } - - if (perms !== newPerms) { - if (!options.verbose && options.changes) { - console.log(file + ' -> ' + newPerms.toString(8)); - } - - fs.chmodSync(file, newPerms); - perms = newPerms; - } - } else { - common.error('Invalid symbolic mode change: ' + symbolicMode); - } - }); - } else { - newPerms = type + parseInt(mode, 8); - - if (common.statFollowLinks(file).isDirectory()) { - newPerms |= PERMS.SETUID + PERMS.SETGID & perms; - } - - fs.chmodSync(file, newPerms); - } - }); - return ''; - } - - chmod = _chmod; - return chmod; -} - -var cp; -var hasRequiredCp; - -function requireCp() { - if (hasRequiredCp) return cp; - hasRequiredCp = 1; - var fs = require$$1__default["default"]; - var path = require$$2__default["default"]; - var common = requireCommon(); - common.register('cp', _cp, { - cmdOptions: { - 'f': '!no_force', - 'n': 'no_force', - 'u': 'update', - 'R': 'recursive', - 'r': 'recursive', - 'L': 'followsymlink', - 'P': 'noFollowsymlink' - }, - wrapOutput: false - }); - - function copyFileSync(srcFile, destFile, options) { - if (!fs.existsSync(srcFile)) { - common.error('copyFileSync: no such file or directory: ' + srcFile); - } - - var isWindows = process.platform === 'win32'; - - try { - if (options.update && common.statFollowLinks(srcFile).mtime < fs.statSync(destFile).mtime) { - return; - } - } catch (e) {} - - if (common.statNoFollowLinks(srcFile).isSymbolicLink() && !options.followsymlink) { - try { - common.statNoFollowLinks(destFile); - common.unlinkSync(destFile); - } catch (e) {} - - var symlinkFull = fs.readlinkSync(srcFile); - fs.symlinkSync(symlinkFull, destFile, isWindows ? 'junction' : null); - } else { - var buf = common.buffer(); - var bufLength = buf.length; - var bytesRead = bufLength; - var pos = 0; - var fdr = null; - var fdw = null; - - try { - fdr = fs.openSync(srcFile, 'r'); - } catch (e) { - common.error('copyFileSync: could not read src file (' + srcFile + ')'); - } - - try { - fdw = fs.openSync(destFile, 'w'); - } catch (e) { - common.error('copyFileSync: could not write to dest file (code=' + e.code + '):' + destFile); - } - - while (bytesRead === bufLength) { - bytesRead = fs.readSync(fdr, buf, 0, bufLength, pos); - fs.writeSync(fdw, buf, 0, bytesRead); - pos += bytesRead; - } - - fs.closeSync(fdr); - fs.closeSync(fdw); - fs.chmodSync(destFile, common.statFollowLinks(srcFile).mode); - } - } - - function cpdirSyncRecursive(sourceDir, destDir, currentDepth, opts) { - if (!opts) opts = {}; - if (currentDepth >= common.config.maxdepth) return; - currentDepth++; - var isWindows = process.platform === 'win32'; - - try { - fs.mkdirSync(destDir); - } catch (e) { - if (e.code !== 'EEXIST') throw e; - } - - var files = fs.readdirSync(sourceDir); - - for (var i = 0; i < files.length; i++) { - var srcFile = sourceDir + '/' + files[i]; - var destFile = destDir + '/' + files[i]; - var srcFileStat = common.statNoFollowLinks(srcFile); - var symlinkFull; - - if (opts.followsymlink) { - if (cpcheckcycle(sourceDir, srcFile)) { - console.error('Cycle link found.'); - symlinkFull = fs.readlinkSync(srcFile); - fs.symlinkSync(symlinkFull, destFile, isWindows ? 'junction' : null); - continue; - } - } - - if (srcFileStat.isDirectory()) { - cpdirSyncRecursive(srcFile, destFile, currentDepth, opts); - } else if (srcFileStat.isSymbolicLink() && !opts.followsymlink) { - symlinkFull = fs.readlinkSync(srcFile); - - try { - common.statNoFollowLinks(destFile); - common.unlinkSync(destFile); - } catch (e) {} - - fs.symlinkSync(symlinkFull, destFile, isWindows ? 'junction' : null); - } else if (srcFileStat.isSymbolicLink() && opts.followsymlink) { - srcFileStat = common.statFollowLinks(srcFile); - - if (srcFileStat.isDirectory()) { - cpdirSyncRecursive(srcFile, destFile, currentDepth, opts); - } else { - copyFileSync(srcFile, destFile, opts); - } - } else { - if (fs.existsSync(destFile) && opts.no_force) { - common.log('skipping existing file: ' + files[i]); - } else { - copyFileSync(srcFile, destFile, opts); - } - } - } - - var checkDir = common.statFollowLinks(sourceDir); - fs.chmodSync(destDir, checkDir.mode); - } - - function checkRecentCreated(sources, index) { - var lookedSource = sources[index]; - return sources.slice(0, index).some(function (src) { - return path.basename(src) === path.basename(lookedSource); - }); - } - - function cpcheckcycle(sourceDir, srcFile) { - var srcFileStat = common.statNoFollowLinks(srcFile); - - if (srcFileStat.isSymbolicLink()) { - var cyclecheck = common.statFollowLinks(srcFile); - - if (cyclecheck.isDirectory()) { - var sourcerealpath = fs.realpathSync(sourceDir); - var symlinkrealpath = fs.realpathSync(srcFile); - var re = new RegExp(symlinkrealpath); - - if (re.test(sourcerealpath)) { - return true; - } - } - } - - return false; - } - - function _cp(options, sources, dest) { - if (options.followsymlink) { - options.noFollowsymlink = false; - } - - if (!options.recursive && !options.noFollowsymlink) { - options.followsymlink = true; - } - - if (arguments.length < 3) { - common.error('missing and/or '); - } else { - sources = [].slice.call(arguments, 1, arguments.length - 1); - dest = arguments[arguments.length - 1]; - } - - var destExists = fs.existsSync(dest); - var destStat = destExists && common.statFollowLinks(dest); - - if ((!destExists || !destStat.isDirectory()) && sources.length > 1) { - common.error('dest is not a directory (too many sources)'); - } - - if (destExists && destStat.isFile() && options.no_force) { - return new common.ShellString('', '', 0); - } - - sources.forEach(function (src, srcIndex) { - if (!fs.existsSync(src)) { - if (src === '') src = "''"; - common.error('no such file or directory: ' + src, { - continue: true - }); - return; - } - - var srcStat = common.statFollowLinks(src); - - if (!options.noFollowsymlink && srcStat.isDirectory()) { - if (!options.recursive) { - common.error("omitting directory '" + src + "'", { - continue: true - }); - } else { - var newDest = destStat && destStat.isDirectory() ? path.join(dest, path.basename(src)) : dest; - - try { - common.statFollowLinks(path.dirname(dest)); - cpdirSyncRecursive(src, newDest, 0, { - no_force: options.no_force, - followsymlink: options.followsymlink - }); - } catch (e) { - common.error("cannot create directory '" + dest + "': No such file or directory"); - } - } - } else { - var thisDest = dest; - - if (destStat && destStat.isDirectory()) { - thisDest = path.normalize(dest + '/' + path.basename(src)); - } - - var thisDestExists = fs.existsSync(thisDest); - - if (thisDestExists && checkRecentCreated(sources, srcIndex)) { - if (!options.no_force) { - common.error("will not overwrite just-created '" + thisDest + "' with '" + src + "'", { - continue: true - }); - } - - return; - } - - if (thisDestExists && options.no_force) { - return; - } - - if (path.relative(src, thisDest) === '') { - common.error("'" + thisDest + "' and '" + src + "' are the same file", { - continue: true - }); - return; - } - - copyFileSync(src, thisDest, options); - } - }); - return new common.ShellString('', common.state.error, common.state.errorCode); - } - - cp = _cp; - return cp; -} - -var dirs = {}; - -var hasRequiredDirs; - -function requireDirs() { - if (hasRequiredDirs) return dirs; - hasRequiredDirs = 1; - var common = requireCommon(); - - var _cd = requireCd(); - - var path = require$$2__default["default"]; - common.register('dirs', _dirs, { - wrapOutput: false - }); - common.register('pushd', _pushd, { - wrapOutput: false - }); - common.register('popd', _popd, { - wrapOutput: false - }); - var _dirStack = []; - - function _isStackIndex(index) { - return /^[\-+]\d+$/.test(index); - } - - function _parseStackIndex(index) { - if (_isStackIndex(index)) { - if (Math.abs(index) < _dirStack.length + 1) { - return /^-/.test(index) ? Number(index) - 1 : Number(index); - } - - common.error(index + ': directory stack index out of range'); - } else { - common.error(index + ': invalid number'); - } - } - - function _actualDirStack() { - return [process.cwd()].concat(_dirStack); - } - - function _pushd(options, dir) { - if (_isStackIndex(options)) { - dir = options; - options = ''; - } - - options = common.parseOptions(options, { - 'n': 'no-cd', - 'q': 'quiet' - }); - - var dirs = _actualDirStack(); - - if (dir === '+0') { - return dirs; - } else if (!dir) { - if (dirs.length > 1) { - dirs = dirs.splice(1, 1).concat(dirs); - } else { - return common.error('no other directory'); - } - } else if (_isStackIndex(dir)) { - var n = _parseStackIndex(dir); - - dirs = dirs.slice(n).concat(dirs.slice(0, n)); - } else { - if (options['no-cd']) { - dirs.splice(1, 0, dir); - } else { - dirs.unshift(dir); - } - } - - if (options['no-cd']) { - dirs = dirs.slice(1); - } else { - dir = path.resolve(dirs.shift()); - - _cd('', dir); - } - - _dirStack = dirs; - return _dirs(options.quiet ? '-q' : ''); - } - - dirs.pushd = _pushd; - - function _popd(options, index) { - if (_isStackIndex(options)) { - index = options; - options = ''; - } - - options = common.parseOptions(options, { - 'n': 'no-cd', - 'q': 'quiet' - }); - - if (!_dirStack.length) { - return common.error('directory stack empty'); - } - - index = _parseStackIndex(index || '+0'); - - if (options['no-cd'] || index > 0 || _dirStack.length + index === 0) { - index = index > 0 ? index - 1 : index; - - _dirStack.splice(index, 1); - } else { - var dir = path.resolve(_dirStack.shift()); - - _cd('', dir); - } - - return _dirs(options.quiet ? '-q' : ''); - } - - dirs.popd = _popd; - - function _dirs(options, index) { - if (_isStackIndex(options)) { - index = options; - options = ''; - } - - options = common.parseOptions(options, { - 'c': 'clear', - 'q': 'quiet' - }); - - if (options.clear) { - _dirStack = []; - return _dirStack; - } - - var stack = _actualDirStack(); - - if (index) { - index = _parseStackIndex(index); - - if (index < 0) { - index = stack.length + index; - } - - if (!options.quiet) { - common.log(stack[index]); - } - - return stack[index]; - } - - if (!options.quiet) { - common.log(stack.join(' ')); - } - - return stack; - } - - dirs.dirs = _dirs; - return dirs; -} - -var echo; -var hasRequiredEcho; - -function requireEcho() { - if (hasRequiredEcho) return echo; - hasRequiredEcho = 1; - var format = require$$4__default$1["default"].format; - var common = requireCommon(); - common.register('echo', _echo, { - allowGlobbing: false - }); - - function _echo(opts) { - var messages = [].slice.call(arguments, opts ? 0 : 1); - var options = {}; - - try { - options = common.parseOptions(messages[0], { - 'e': 'escapes', - 'n': 'no_newline' - }, { - silent: true - }); - - if (messages[0]) { - messages.shift(); - } - } catch (_) { - common.state.error = null; - } - - var output = format.apply(null, messages); - - if (!options.no_newline) { - output += '\n'; - } - - process.stdout.write(output); - return output; - } - - echo = _echo; - return echo; -} - -var error_1; -var hasRequiredError; - -function requireError() { - if (hasRequiredError) return error_1; - hasRequiredError = 1; - var common = requireCommon(); - - function error() { - return common.state.error; - } - - error_1 = error; - return error_1; -} - -var execChild = {exports: {}}; - -var hasRequiredExecChild; - -function requireExecChild() { - if (hasRequiredExecChild) return execChild.exports; - hasRequiredExecChild = 1; - - (function (module) { - if (require.main !== module) { - throw new Error('This file should not be required'); - } - - var childProcess = require$$0__default$1["default"]; - var fs = require$$1__default["default"]; - var paramFilePath = process.argv[2]; - var serializedParams = fs.readFileSync(paramFilePath, 'utf8'); - var params = JSON.parse(serializedParams); - var cmd = params.command; - var execOptions = params.execOptions; - var pipe = params.pipe; - var stdoutFile = params.stdoutFile; - var stderrFile = params.stderrFile; - var c = childProcess.exec(cmd, execOptions, function (err) { - if (!err) { - process.exitCode = 0; - } else if (err.code === undefined) { - process.exitCode = 1; - } else { - process.exitCode = err.code; - } - }); - var stdoutStream = fs.createWriteStream(stdoutFile); - var stderrStream = fs.createWriteStream(stderrFile); - c.stdout.pipe(stdoutStream); - c.stderr.pipe(stderrStream); - c.stdout.pipe(process.stdout); - c.stderr.pipe(process.stderr); - - if (pipe) { - c.stdin.end(pipe); - } - })(execChild); - - return execChild.exports; -} - -var $$2 = _export; -var getBuiltIn = getBuiltIn$8; -var apply = functionApply; -var call = functionCall; -var uncurryThis = functionUncurryThis; -var fails = fails$p; -var isArray = isArray$4; -var isCallable = isCallable$m; -var isObject = isObject$d; -var isSymbol = isSymbol$3; -var arraySlice = arraySlice$3; -var NATIVE_SYMBOL = nativeSymbol; - -var $stringify = getBuiltIn('JSON', 'stringify'); -var exec$2 = uncurryThis(/./.exec); -var charAt = uncurryThis(''.charAt); -var charCodeAt = uncurryThis(''.charCodeAt); -var replace = uncurryThis(''.replace); -var numberToString = uncurryThis(1.0.toString); - -var tester = /[\uD800-\uDFFF]/g; -var low = /^[\uD800-\uDBFF]$/; -var hi = /^[\uDC00-\uDFFF]$/; - -var WRONG_SYMBOLS_CONVERSION = !NATIVE_SYMBOL || fails(function () { - var symbol = getBuiltIn('Symbol')(); - // MS Edge converts symbol values to JSON as {} - return $stringify([symbol]) != '[null]' - // WebKit converts symbol values to JSON as null - || $stringify({ a: symbol }) != '{}' - // V8 throws on boxed symbols - || $stringify(Object(symbol)) != '{}'; -}); - -// https://github.com/tc39/proposal-well-formed-stringify -var ILL_FORMED_UNICODE = fails(function () { - return $stringify('\uDF06\uD834') !== '"\\udf06\\ud834"' - || $stringify('\uDEAD') !== '"\\udead"'; -}); - -var stringifyWithSymbolsFix = function (it, replacer) { - var args = arraySlice(arguments); - var $replacer = replacer; - if (!isObject(replacer) && it === undefined || isSymbol(it)) return; // IE8 returns string on undefined - if (!isArray(replacer)) replacer = function (key, value) { - if (isCallable($replacer)) value = call($replacer, this, key, value); - if (!isSymbol(value)) return value; - }; - args[1] = replacer; - return apply($stringify, null, args); -}; - -var fixIllFormed = function (match, offset, string) { - var prev = charAt(string, offset - 1); - var next = charAt(string, offset + 1); - if ((exec$2(low, match) && !exec$2(hi, next)) || (exec$2(hi, match) && !exec$2(low, prev))) { - return '\\u' + numberToString(charCodeAt(match, 0), 16); - } return match; -}; - -if ($stringify) { - // `JSON.stringify` method - // https://tc39.es/ecma262/#sec-json.stringify - $$2({ target: 'JSON', stat: true, arity: 3, forced: WRONG_SYMBOLS_CONVERSION || ILL_FORMED_UNICODE }, { - // eslint-disable-next-line no-unused-vars -- required for `.length` - stringify: function stringify(it, replacer, space) { - var args = arraySlice(arguments); - var result = apply(WRONG_SYMBOLS_CONVERSION ? stringifyWithSymbolsFix : $stringify, null, args); - return ILL_FORMED_UNICODE && typeof result == 'string' ? replace(result, tester, fixIllFormed) : result; - } - }); -} - -var tempdir = {}; - -var hasRequiredTempdir; - -function requireTempdir() { - if (hasRequiredTempdir) return tempdir; - hasRequiredTempdir = 1; - var common = requireCommon(); - var os = require$$0__default["default"]; - var fs = require$$1__default["default"]; - common.register('tempdir', _tempDir, { - allowGlobbing: false, - wrapOutput: false - }); - - function writeableDir(dir) { - if (!dir || !fs.existsSync(dir)) return false; - if (!common.statFollowLinks(dir).isDirectory()) return false; - var testFile = dir + '/' + common.randomFileName(); - - try { - fs.writeFileSync(testFile, ' '); - common.unlinkSync(testFile); - return dir; - } catch (e) { - return false; - } - } - - var cachedTempDir; - - function _tempDir() { - if (cachedTempDir) return cachedTempDir; - cachedTempDir = writeableDir(os.tmpdir()) || writeableDir(process.env.TMPDIR) || writeableDir(process.env.TEMP) || writeableDir(process.env.TMP) || writeableDir(process.env.Wimp$ScrapDir) || writeableDir('C:\\TEMP') || writeableDir('C:\\TMP') || writeableDir('\\TEMP') || writeableDir('\\TMP') || writeableDir('/tmp') || writeableDir('/var/tmp') || writeableDir('/usr/tmp') || writeableDir('.'); - return cachedTempDir; - } - - function isCached() { - return cachedTempDir; - } - - function clearCache() { - cachedTempDir = undefined; - } - - tempdir.tempDir = _tempDir; - tempdir.isCached = isCached; - tempdir.clearCache = clearCache; - return tempdir; -} - -var pwd; -var hasRequiredPwd; - -function requirePwd() { - if (hasRequiredPwd) return pwd; - hasRequiredPwd = 1; - var path = require$$2__default["default"]; - var common = requireCommon(); - common.register('pwd', _pwd, { - allowGlobbing: false - }); - - function _pwd() { - var pwd = path.resolve(process.cwd()); - return pwd; - } - - pwd = _pwd; - return pwd; -} - -var exec$1; -var hasRequiredExec; - -function requireExec() { - if (hasRequiredExec) return exec$1; - hasRequiredExec = 1; - var common = requireCommon(); - var _tempDir = requireTempdir().tempDir; - - var _pwd = requirePwd(); - - var path = require$$2__default["default"]; - var fs = require$$1__default["default"]; - var child = require$$0__default$1["default"]; - var DEFAULT_MAXBUFFER_SIZE = 20 * 1024 * 1024; - var DEFAULT_ERROR_CODE = 1; - common.register('exec', _exec, { - unix: false, - canReceivePipe: true, - wrapOutput: false - }); - - function execSync(cmd, opts, pipe) { - if (!common.config.execPath) { - common.error('Unable to find a path to the node binary. Please manually set config.execPath'); - } - - var tempDir = _tempDir(); - - var paramsFile = path.resolve(tempDir + '/' + common.randomFileName()); - var stderrFile = path.resolve(tempDir + '/' + common.randomFileName()); - var stdoutFile = path.resolve(tempDir + '/' + common.randomFileName()); - opts = common.extend({ - silent: common.config.silent, - cwd: _pwd().toString(), - env: process.env, - maxBuffer: DEFAULT_MAXBUFFER_SIZE, - encoding: 'utf8' - }, opts); - if (fs.existsSync(paramsFile)) common.unlinkSync(paramsFile); - if (fs.existsSync(stderrFile)) common.unlinkSync(stderrFile); - if (fs.existsSync(stdoutFile)) common.unlinkSync(stdoutFile); - opts.cwd = path.resolve(opts.cwd); - var paramsToSerialize = { - command: cmd, - execOptions: opts, - pipe: pipe, - stdoutFile: stdoutFile, - stderrFile: stderrFile - }; - - function writeFileLockedDown(filePath, data) { - fs.writeFileSync(filePath, data, { - encoding: 'utf8', - mode: parseInt('600', 8) - }); - } - - writeFileLockedDown(stdoutFile, ''); - writeFileLockedDown(stderrFile, ''); - writeFileLockedDown(paramsFile, JSON.stringify(paramsToSerialize)); - var execArgs = [path.join(__dirname, 'exec-child.js'), paramsFile]; - - if (opts.silent) { - opts.stdio = 'ignore'; - } else { - opts.stdio = [0, 1, 2]; - } - - var code = 0; - - try { - delete opts.shell; - child.execFileSync(common.config.execPath, execArgs, opts); - } catch (e) { - code = e.status || DEFAULT_ERROR_CODE; - } - - var stdout = ''; - var stderr = ''; - - if (opts.encoding === 'buffer') { - stdout = fs.readFileSync(stdoutFile); - stderr = fs.readFileSync(stderrFile); - } else { - stdout = fs.readFileSync(stdoutFile, opts.encoding); - stderr = fs.readFileSync(stderrFile, opts.encoding); - } - - try { - common.unlinkSync(paramsFile); - } catch (e) {} - - try { - common.unlinkSync(stderrFile); - } catch (e) {} - - try { - common.unlinkSync(stdoutFile); - } catch (e) {} - - if (code !== 0) { - common.error(stderr, code, { - continue: true, - silent: true - }); - } - - var obj = common.ShellString(stdout, stderr, code); - return obj; - } - - function execAsync(cmd, opts, pipe, callback) { - opts = common.extend({ - silent: common.config.silent, - cwd: _pwd().toString(), - env: process.env, - maxBuffer: DEFAULT_MAXBUFFER_SIZE, - encoding: 'utf8' - }, opts); - var c = child.exec(cmd, opts, function (err, stdout, stderr) { - if (callback) { - if (!err) { - callback(0, stdout, stderr); - } else if (err.code === undefined) { - callback(1, stdout, stderr); - } else { - callback(err.code, stdout, stderr); - } - } - }); - if (pipe) c.stdin.end(pipe); - - if (!opts.silent) { - c.stdout.pipe(process.stdout); - c.stderr.pipe(process.stderr); - } - - return c; - } - - function _exec(command, options, callback) { - options = options || {}; - if (!command) common.error('must specify command'); - var pipe = common.readFromPipe(); - - if (typeof options === 'function') { - callback = options; - options = { - async: true - }; - } - - if (typeof options === 'object' && typeof callback === 'function') { - options.async = true; - } - - options = common.extend({ - silent: common.config.silent, - async: false - }, options); - - if (options.async) { - return execAsync(command, options, pipe, callback); - } else { - return execSync(command, options, pipe); - } - } - - exec$1 = _exec; - return exec$1; -} - -var ls; -var hasRequiredLs; - -function requireLs() { - if (hasRequiredLs) return ls; - hasRequiredLs = 1; - var path = require$$2__default["default"]; - var fs = require$$1__default["default"]; - var common = requireCommon(); - var glob = requireGlob(); - var globPatternRecursive = path.sep + '**'; - common.register('ls', _ls, { - cmdOptions: { - 'R': 'recursive', - 'A': 'all', - 'L': 'link', - 'a': 'all_deprecated', - 'd': 'directory', - 'l': 'long' - } - }); - - function _ls(options, paths) { - if (options.all_deprecated) { - common.log('ls: Option -a is deprecated. Use -A instead'); - options.all = true; - } - - if (!paths) { - paths = ['.']; - } else { - paths = [].slice.call(arguments, 1); - } - - var list = []; - - function pushFile(abs, relName, stat) { - if (process.platform === 'win32') { - relName = relName.replace(/\\/g, '/'); - } - - if (options.long) { - stat = stat || (options.link ? common.statFollowLinks(abs) : common.statNoFollowLinks(abs)); - list.push(addLsAttributes(relName, stat)); - } else { - list.push(relName); - } - } - - paths.forEach(function (p) { - var stat; - - try { - stat = options.link ? common.statFollowLinks(p) : common.statNoFollowLinks(p); - - if (stat.isSymbolicLink()) { - try { - var _stat = common.statFollowLinks(p); - - if (_stat.isDirectory()) { - stat = _stat; - } - } catch (_) {} - } - } catch (e) { - common.error('no such file or directory: ' + p, 2, { - continue: true - }); - return; - } - - if (stat.isDirectory() && !options.directory) { - if (options.recursive) { - glob.sync(p + globPatternRecursive, { - dot: options.all, - follow: options.link - }).forEach(function (item) { - if (path.relative(p, item)) { - pushFile(item, path.relative(p, item)); - } - }); - } else if (options.all) { - fs.readdirSync(p).forEach(function (item) { - pushFile(path.join(p, item), item); - }); - } else { - fs.readdirSync(p).forEach(function (item) { - if (item[0] !== '.') { - pushFile(path.join(p, item), item); - } - }); - } - } else { - pushFile(p, p, stat); - } - }); - return list; - } - - function addLsAttributes(pathName, stats) { - stats.name = pathName; - - stats.toString = function () { - return [this.mode, this.nlink, this.uid, this.gid, this.size, this.mtime, this.name].join(' '); - }; - - return stats; - } - - ls = _ls; - return ls; -} - -var find; -var hasRequiredFind; - -function requireFind() { - if (hasRequiredFind) return find; - hasRequiredFind = 1; - var path = require$$2__default["default"]; - var common = requireCommon(); - - var _ls = requireLs(); - - common.register('find', _find, {}); - - function _find(options, paths) { - if (!paths) { - common.error('no path specified'); - } else if (typeof paths === 'string') { - paths = [].slice.call(arguments, 1); - } - - var list = []; - - function pushFile(file) { - if (process.platform === 'win32') { - file = file.replace(/\\/g, '/'); - } - - list.push(file); - } - - paths.forEach(function (file) { - var stat; - - try { - stat = common.statFollowLinks(file); - } catch (e) { - common.error('no such file or directory: ' + file); - } - - pushFile(file); - - if (stat.isDirectory()) { - _ls({ - recursive: true, - all: true - }, file).forEach(function (subfile) { - pushFile(path.join(file, subfile)); - }); - } - }); - return list; - } - - find = _find; - return find; -} - -var grep; -var hasRequiredGrep; - -function requireGrep() { - if (hasRequiredGrep) return grep; - hasRequiredGrep = 1; - var common = requireCommon(); - var fs = require$$1__default["default"]; - common.register('grep', _grep, { - globStart: 2, - canReceivePipe: true, - cmdOptions: { - 'v': 'inverse', - 'l': 'nameOnly', - 'i': 'ignoreCase' - } - }); - - function _grep(options, regex, files) { - var pipe = common.readFromPipe(); - if (!files && !pipe) common.error('no paths given', 2); - files = [].slice.call(arguments, 2); - - if (pipe) { - files.unshift('-'); - } - - var grep = []; - - if (options.ignoreCase) { - regex = new RegExp(regex, 'i'); - } - - files.forEach(function (file) { - if (!fs.existsSync(file) && file !== '-') { - common.error('no such file or directory: ' + file, 2, { - continue: true - }); - return; - } - - var contents = file === '-' ? pipe : fs.readFileSync(file, 'utf8'); - - if (options.nameOnly) { - if (contents.match(regex)) { - grep.push(file); - } - } else { - var lines = contents.split('\n'); - lines.forEach(function (line) { - var matched = line.match(regex); - - if (options.inverse && !matched || !options.inverse && matched) { - grep.push(line); - } - }); - } - }); - return grep.join('\n') + '\n'; - } - - grep = _grep; - return grep; -} - -var head; -var hasRequiredHead; - -function requireHead() { - if (hasRequiredHead) return head; - hasRequiredHead = 1; - var common = requireCommon(); - var fs = require$$1__default["default"]; - common.register('head', _head, { - canReceivePipe: true, - cmdOptions: { - 'n': 'numLines' - } - }); - - function readSomeLines(file, numLines) { - var buf = common.buffer(); - var bufLength = buf.length; - var bytesRead = bufLength; - var pos = 0; - var fdr = fs.openSync(file, 'r'); - var numLinesRead = 0; - var ret = ''; - - while (bytesRead === bufLength && numLinesRead < numLines) { - bytesRead = fs.readSync(fdr, buf, 0, bufLength, pos); - var bufStr = buf.toString('utf8', 0, bytesRead); - numLinesRead += bufStr.split('\n').length - 1; - ret += bufStr; - pos += bytesRead; - } - - fs.closeSync(fdr); - return ret; - } - - function _head(options, files) { - var head = []; - var pipe = common.readFromPipe(); - if (!files && !pipe) common.error('no paths given'); - var idx = 1; - - if (options.numLines === true) { - idx = 2; - options.numLines = Number(arguments[1]); - } else if (options.numLines === false) { - options.numLines = 10; - } - - files = [].slice.call(arguments, idx); - - if (pipe) { - files.unshift('-'); - } - - var shouldAppendNewline = false; - files.forEach(function (file) { - if (file !== '-') { - if (!fs.existsSync(file)) { - common.error('no such file or directory: ' + file, { - continue: true - }); - return; - } else if (common.statFollowLinks(file).isDirectory()) { - common.error("error reading '" + file + "': Is a directory", { - continue: true - }); - return; - } - } - - var contents; - - if (file === '-') { - contents = pipe; - } else if (options.numLines < 0) { - contents = fs.readFileSync(file, 'utf8'); - } else { - contents = readSomeLines(file, options.numLines); - } - - var lines = contents.split('\n'); - var hasTrailingNewline = lines[lines.length - 1] === ''; - - if (hasTrailingNewline) { - lines.pop(); - } - - shouldAppendNewline = hasTrailingNewline || options.numLines < lines.length; - head = head.concat(lines.slice(0, options.numLines)); - }); - - if (shouldAppendNewline) { - head.push(''); - } - - return head.join('\n'); - } - - head = _head; - return head; -} - -var ln; -var hasRequiredLn; - -function requireLn() { - if (hasRequiredLn) return ln; - hasRequiredLn = 1; - var fs = require$$1__default["default"]; - var path = require$$2__default["default"]; - var common = requireCommon(); - common.register('ln', _ln, { - cmdOptions: { - 's': 'symlink', - 'f': 'force' - } - }); - - function _ln(options, source, dest) { - if (!source || !dest) { - common.error('Missing and/or '); - } - - source = String(source); - var sourcePath = path.normalize(source).replace(RegExp(path.sep + '$'), ''); - var isAbsolute = path.resolve(source) === sourcePath; - dest = path.resolve(process.cwd(), String(dest)); - - if (fs.existsSync(dest)) { - if (!options.force) { - common.error('Destination file exists', { - continue: true - }); - } - - fs.unlinkSync(dest); - } - - if (options.symlink) { - var isWindows = process.platform === 'win32'; - var linkType = isWindows ? 'file' : null; - var resolvedSourcePath = isAbsolute ? sourcePath : path.resolve(process.cwd(), path.dirname(dest), source); - - if (!fs.existsSync(resolvedSourcePath)) { - common.error('Source file does not exist', { - continue: true - }); - } else if (isWindows && common.statFollowLinks(resolvedSourcePath).isDirectory()) { - linkType = 'junction'; - } - - try { - fs.symlinkSync(linkType === 'junction' ? resolvedSourcePath : source, dest, linkType); - } catch (err) { - common.error(err.message); - } - } else { - if (!fs.existsSync(source)) { - common.error('Source file does not exist', { - continue: true - }); - } - - try { - fs.linkSync(source, dest); - } catch (err) { - common.error(err.message); - } - } - - return ''; - } - - ln = _ln; - return ln; -} - -var mkdir; -var hasRequiredMkdir; - -function requireMkdir() { - if (hasRequiredMkdir) return mkdir; - hasRequiredMkdir = 1; - var common = requireCommon(); - var fs = require$$1__default["default"]; - var path = require$$2__default["default"]; - common.register('mkdir', _mkdir, { - cmdOptions: { - 'p': 'fullpath' - } - }); - - function mkdirSyncRecursive(dir) { - var baseDir = path.dirname(dir); - - if (baseDir === dir) { - common.error('dirname() failed: [' + dir + ']'); - } - - if (fs.existsSync(baseDir)) { - fs.mkdirSync(dir, parseInt('0777', 8)); - return; - } - - mkdirSyncRecursive(baseDir); - fs.mkdirSync(dir, parseInt('0777', 8)); - } - - function _mkdir(options, dirs) { - if (!dirs) common.error('no paths given'); - - if (typeof dirs === 'string') { - dirs = [].slice.call(arguments, 1); - } - - dirs.forEach(function (dir) { - try { - var stat = common.statNoFollowLinks(dir); - - if (!options.fullpath) { - common.error('path already exists: ' + dir, { - continue: true - }); - } else if (stat.isFile()) { - common.error('cannot create directory ' + dir + ': File exists', { - continue: true - }); - } - - return; - } catch (e) {} - - var baseDir = path.dirname(dir); - - if (!fs.existsSync(baseDir) && !options.fullpath) { - common.error('no such file or directory: ' + baseDir, { - continue: true - }); - return; - } - - try { - if (options.fullpath) { - mkdirSyncRecursive(path.resolve(dir)); - } else { - fs.mkdirSync(dir, parseInt('0777', 8)); - } - } catch (e) { - var reason; - - if (e.code === 'EACCES') { - reason = 'Permission denied'; - } else if (e.code === 'ENOTDIR' || e.code === 'ENOENT') { - reason = 'Not a directory'; - } else { - throw e; - } - - common.error('cannot create directory ' + dir + ': ' + reason, { - continue: true - }); - } - }); - return ''; - } - - mkdir = _mkdir; - return mkdir; -} - -var rm; -var hasRequiredRm; - -function requireRm() { - if (hasRequiredRm) return rm; - hasRequiredRm = 1; - var common = requireCommon(); - var fs = require$$1__default["default"]; - common.register('rm', _rm, { - cmdOptions: { - 'f': 'force', - 'r': 'recursive', - 'R': 'recursive' - } - }); - - function rmdirSyncRecursive(dir, force, fromSymlink) { - var files; - files = fs.readdirSync(dir); - - for (var i = 0; i < files.length; i++) { - var file = dir + '/' + files[i]; - var currFile = common.statNoFollowLinks(file); - - if (currFile.isDirectory()) { - rmdirSyncRecursive(file, force); - } else { - if (force || isWriteable(file)) { - try { - common.unlinkSync(file); - } catch (e) { - common.error('could not remove file (code ' + e.code + '): ' + file, { - continue: true - }); - } - } - } - } - - if (fromSymlink) return; - var result; - - try { - var start = Date.now(); - - for (;;) { - try { - result = fs.rmdirSync(dir); - if (fs.existsSync(dir)) throw { - code: 'EAGAIN' - }; - break; - } catch (er) { - if (process.platform === 'win32' && (er.code === 'ENOTEMPTY' || er.code === 'EBUSY' || er.code === 'EPERM' || er.code === 'EAGAIN')) { - if (Date.now() - start > 1000) throw er; - } else if (er.code === 'ENOENT') { - break; - } else { - throw er; - } - } - } - } catch (e) { - common.error('could not remove directory (code ' + e.code + '): ' + dir, { - continue: true - }); - } - - return result; - } - - function isWriteable(file) { - var writePermission = true; - - try { - var __fd = fs.openSync(file, 'a'); - - fs.closeSync(__fd); - } catch (e) { - writePermission = false; - } - - return writePermission; - } - - function handleFile(file, options) { - if (options.force || isWriteable(file)) { - common.unlinkSync(file); - } else { - common.error('permission denied: ' + file, { - continue: true - }); - } - } - - function handleDirectory(file, options) { - if (options.recursive) { - rmdirSyncRecursive(file, options.force); - } else { - common.error('path is a directory', { - continue: true - }); - } - } - - function handleSymbolicLink(file, options) { - var stats; - - try { - stats = common.statFollowLinks(file); - } catch (e) { - common.unlinkSync(file); - return; - } - - if (stats.isFile()) { - common.unlinkSync(file); - } else if (stats.isDirectory()) { - if (file[file.length - 1] === '/') { - if (options.recursive) { - var fromSymlink = true; - rmdirSyncRecursive(file, options.force, fromSymlink); - } else { - common.error('path is a directory', { - continue: true - }); - } - } else { - common.unlinkSync(file); - } - } - } - - function handleFIFO(file) { - common.unlinkSync(file); - } - - function _rm(options, files) { - if (!files) common.error('no paths given'); - files = [].slice.call(arguments, 1); - files.forEach(function (file) { - var lstats; - - try { - var filepath = file[file.length - 1] === '/' ? file.slice(0, -1) : file; - lstats = common.statNoFollowLinks(filepath); - } catch (e) { - if (!options.force) { - common.error('no such file or directory: ' + file, { - continue: true - }); - } - - return; - } - - if (lstats.isFile()) { - handleFile(file, options); - } else if (lstats.isDirectory()) { - handleDirectory(file, options); - } else if (lstats.isSymbolicLink()) { - handleSymbolicLink(file, options); - } else if (lstats.isFIFO()) { - handleFIFO(file); - } - }); - return ''; - } - - rm = _rm; - return rm; -} - -var mv; -var hasRequiredMv; - -function requireMv() { - if (hasRequiredMv) return mv; - hasRequiredMv = 1; - var fs = require$$1__default["default"]; - var path = require$$2__default["default"]; - var common = requireCommon(); - var cp = requireCp(); - var rm = requireRm(); - common.register('mv', _mv, { - cmdOptions: { - 'f': '!no_force', - 'n': 'no_force' - } - }); - - function checkRecentCreated(sources, index) { - var lookedSource = sources[index]; - return sources.slice(0, index).some(function (src) { - return path.basename(src) === path.basename(lookedSource); - }); - } - - function _mv(options, sources, dest) { - if (arguments.length < 3) { - common.error('missing and/or '); - } else if (arguments.length > 3) { - sources = [].slice.call(arguments, 1, arguments.length - 1); - dest = arguments[arguments.length - 1]; - } else if (typeof sources === 'string') { - sources = [sources]; - } else { - common.error('invalid arguments'); - } - - var exists = fs.existsSync(dest); - var stats = exists && common.statFollowLinks(dest); - - if ((!exists || !stats.isDirectory()) && sources.length > 1) { - common.error('dest is not a directory (too many sources)'); - } - - if (exists && stats.isFile() && options.no_force) { - common.error('dest file already exists: ' + dest); - } - - sources.forEach(function (src, srcIndex) { - if (!fs.existsSync(src)) { - common.error('no such file or directory: ' + src, { - continue: true - }); - return; - } - - var thisDest = dest; - - if (fs.existsSync(dest) && common.statFollowLinks(dest).isDirectory()) { - thisDest = path.normalize(dest + '/' + path.basename(src)); - } - - var thisDestExists = fs.existsSync(thisDest); - - if (thisDestExists && checkRecentCreated(sources, srcIndex)) { - if (!options.no_force) { - common.error("will not overwrite just-created '" + thisDest + "' with '" + src + "'", { - continue: true - }); - } - - return; - } - - if (fs.existsSync(thisDest) && options.no_force) { - common.error('dest file already exists: ' + thisDest, { - continue: true - }); - return; - } - - if (path.resolve(src) === path.dirname(path.resolve(thisDest))) { - common.error('cannot move to self: ' + src, { - continue: true - }); - return; - } - - try { - fs.renameSync(src, thisDest); - } catch (e) { - if (e.code === 'EXDEV') { - cp('-r', src, thisDest); - rm('-rf', src); - } - } - }); - return ''; - } - - mv = _mv; - return mv; -} - -var popd = {}; - -var hasRequiredPopd; - -function requirePopd() { - if (hasRequiredPopd) return popd; - hasRequiredPopd = 1; - return popd; -} - -var pushd = {}; - -var hasRequiredPushd; - -function requirePushd() { - if (hasRequiredPushd) return pushd; - hasRequiredPushd = 1; - return pushd; -} - -var sed; -var hasRequiredSed; - -function requireSed() { - if (hasRequiredSed) return sed; - hasRequiredSed = 1; - var common = requireCommon(); - var fs = require$$1__default["default"]; - common.register('sed', _sed, { - globStart: 3, - canReceivePipe: true, - cmdOptions: { - 'i': 'inplace' - } - }); - - function _sed(options, regex, replacement, files) { - var pipe = common.readFromPipe(); - - if (typeof replacement !== 'string' && typeof replacement !== 'function') { - if (typeof replacement === 'number') { - replacement = replacement.toString(); - } else { - common.error('invalid replacement string'); - } - } - - if (typeof regex === 'string') { - regex = RegExp(regex); - } - - if (!files && !pipe) { - common.error('no files given'); - } - - files = [].slice.call(arguments, 3); - - if (pipe) { - files.unshift('-'); - } - - var sed = []; - files.forEach(function (file) { - if (!fs.existsSync(file) && file !== '-') { - common.error('no such file or directory: ' + file, 2, { - continue: true - }); - return; - } - - var contents = file === '-' ? pipe : fs.readFileSync(file, 'utf8'); - var lines = contents.split('\n'); - var result = lines.map(function (line) { - return line.replace(regex, replacement); - }).join('\n'); - sed.push(result); - - if (options.inplace) { - fs.writeFileSync(file, result, 'utf8'); - } - }); - return sed.join('\n'); - } - - sed = _sed; - return sed; -} - -var set; -var hasRequiredSet; - -function requireSet() { - if (hasRequiredSet) return set; - hasRequiredSet = 1; - var common = requireCommon(); - common.register('set', _set, { - allowGlobbing: false, - wrapOutput: false - }); - - function _set(options) { - if (!options) { - var args = [].slice.call(arguments, 0); - if (args.length < 2) common.error('must provide an argument'); - options = args[1]; - } - - var negate = options[0] === '+'; - - if (negate) { - options = '-' + options.slice(1); - } - - options = common.parseOptions(options, { - 'e': 'fatal', - 'v': 'verbose', - 'f': 'noglob' - }); - - if (negate) { - Object.keys(options).forEach(function (key) { - options[key] = !options[key]; - }); - } - - Object.keys(options).forEach(function (key) { - if (negate !== options[key]) { - common.config[key] = options[key]; - } - }); - return; - } - - set = _set; - return set; -} - -var $trimEnd = stringTrim.end; -var forcedStringTrimMethod = stringTrimForced; - -// `String.prototype.{ trimEnd, trimRight }` method -// https://tc39.es/ecma262/#sec-string.prototype.trimend -// https://tc39.es/ecma262/#String.prototype.trimright -var stringTrimEnd = forcedStringTrimMethod('trimEnd') ? function trimEnd() { - return $trimEnd(this); -// eslint-disable-next-line es-x/no-string-prototype-trimstart-trimend -- safe -} : ''.trimEnd; - -var $$1 = _export; -var trimEnd$1 = stringTrimEnd; - -// `String.prototype.trimRight` method -// https://tc39.es/ecma262/#sec-string.prototype.trimend -// eslint-disable-next-line es-x/no-string-prototype-trimleft-trimright -- safe -$$1({ target: 'String', proto: true, name: 'trimEnd', forced: ''.trimRight !== trimEnd$1 }, { - trimRight: trimEnd$1 -}); - -// TODO: Remove this line from `core-js@4` - -var $ = _export; -var trimEnd = stringTrimEnd; - -// `String.prototype.trimEnd` method -// https://tc39.es/ecma262/#sec-string.prototype.trimend -// eslint-disable-next-line es-x/no-string-prototype-trimstart-trimend -- safe -$({ target: 'String', proto: true, name: 'trimEnd', forced: ''.trimEnd !== trimEnd }, { - trimEnd: trimEnd -}); - -var sort; -var hasRequiredSort; - -function requireSort() { - if (hasRequiredSort) return sort; - hasRequiredSort = 1; - var common = requireCommon(); - var fs = require$$1__default["default"]; - common.register('sort', _sort, { - canReceivePipe: true, - cmdOptions: { - 'r': 'reverse', - 'n': 'numerical' - } - }); - - function parseNumber(str) { - var match = str.match(/^\s*(\d*)\s*(.*)$/); - return { - num: Number(match[1]), - value: match[2] - }; - } - - function unixCmp(a, b) { - var aLower = a.toLowerCase(); - var bLower = b.toLowerCase(); - return aLower === bLower ? -1 * a.localeCompare(b) : aLower.localeCompare(bLower); - } - - function numericalCmp(a, b) { - var objA = parseNumber(a); - var objB = parseNumber(b); - - if (objA.hasOwnProperty('num') && objB.hasOwnProperty('num')) { - return objA.num !== objB.num ? objA.num - objB.num : unixCmp(objA.value, objB.value); - } else { - return unixCmp(objA.value, objB.value); - } - } - - function _sort(options, files) { - var pipe = common.readFromPipe(); - if (!files && !pipe) common.error('no files given'); - files = [].slice.call(arguments, 1); - - if (pipe) { - files.unshift('-'); - } - - var lines = files.reduce(function (accum, file) { - if (file !== '-') { - if (!fs.existsSync(file)) { - common.error('no such file or directory: ' + file, { - continue: true - }); - return accum; - } else if (common.statFollowLinks(file).isDirectory()) { - common.error('read failed: ' + file + ': Is a directory', { - continue: true - }); - return accum; - } - } - - var contents = file === '-' ? pipe : fs.readFileSync(file, 'utf8'); - return accum.concat(contents.trimRight().split('\n')); - }, []); - var sorted = lines.sort(options.numerical ? numericalCmp : unixCmp); - - if (options.reverse) { - sorted = sorted.reverse(); - } - - return sorted.join('\n') + '\n'; - } - - sort = _sort; - return sort; -} - -var tail; -var hasRequiredTail; - -function requireTail() { - if (hasRequiredTail) return tail; - hasRequiredTail = 1; - var common = requireCommon(); - var fs = require$$1__default["default"]; - common.register('tail', _tail, { - canReceivePipe: true, - cmdOptions: { - 'n': 'numLines' - } - }); - - function _tail(options, files) { - var tail = []; - var pipe = common.readFromPipe(); - if (!files && !pipe) common.error('no paths given'); - var idx = 1; - - if (options.numLines === true) { - idx = 2; - options.numLines = Number(arguments[1]); - } else if (options.numLines === false) { - options.numLines = 10; - } - - options.numLines = -1 * Math.abs(options.numLines); - files = [].slice.call(arguments, idx); - - if (pipe) { - files.unshift('-'); - } - - var shouldAppendNewline = false; - files.forEach(function (file) { - if (file !== '-') { - if (!fs.existsSync(file)) { - common.error('no such file or directory: ' + file, { - continue: true - }); - return; - } else if (common.statFollowLinks(file).isDirectory()) { - common.error("error reading '" + file + "': Is a directory", { - continue: true - }); - return; - } - } - - var contents = file === '-' ? pipe : fs.readFileSync(file, 'utf8'); - var lines = contents.split('\n'); - - if (lines[lines.length - 1] === '') { - lines.pop(); - shouldAppendNewline = true; - } else { - shouldAppendNewline = false; - } - - tail = tail.concat(lines.slice(options.numLines)); - }); - - if (shouldAppendNewline) { - tail.push(''); - } - - return tail.join('\n'); - } - - tail = _tail; - return tail; -} - -var test; -var hasRequiredTest; - -function requireTest() { - if (hasRequiredTest) return test; - hasRequiredTest = 1; - var common = requireCommon(); - var fs = require$$1__default["default"]; - common.register('test', _test, { - cmdOptions: { - 'b': 'block', - 'c': 'character', - 'd': 'directory', - 'e': 'exists', - 'f': 'file', - 'L': 'link', - 'p': 'pipe', - 'S': 'socket' - }, - wrapOutput: false, - allowGlobbing: false - }); - - function _test(options, path) { - if (!path) common.error('no path given'); - var canInterpret = false; - Object.keys(options).forEach(function (key) { - if (options[key] === true) { - canInterpret = true; - } - }); - if (!canInterpret) common.error('could not interpret expression'); - - if (options.link) { - try { - return common.statNoFollowLinks(path).isSymbolicLink(); - } catch (e) { - return false; - } - } - - if (!fs.existsSync(path)) return false; - if (options.exists) return true; - var stats = common.statFollowLinks(path); - if (options.block) return stats.isBlockDevice(); - if (options.character) return stats.isCharacterDevice(); - if (options.directory) return stats.isDirectory(); - if (options.file) return stats.isFile(); - if (options.pipe) return stats.isFIFO(); - if (options.socket) return stats.isSocket(); - return false; - } - - test = _test; - return test; -} - -var to; -var hasRequiredTo; - -function requireTo() { - if (hasRequiredTo) return to; - hasRequiredTo = 1; - var common = requireCommon(); - var fs = require$$1__default["default"]; - var path = require$$2__default["default"]; - common.register('to', _to, { - pipeOnly: true, - wrapOutput: false - }); - - function _to(options, file) { - if (!file) common.error('wrong arguments'); - - if (!fs.existsSync(path.dirname(file))) { - common.error('no such file or directory: ' + path.dirname(file)); - } - - try { - fs.writeFileSync(file, this.stdout || this.toString(), 'utf8'); - return this; - } catch (e) { - common.error('could not write to file (code ' + e.code + '): ' + file, { - continue: true - }); - } - } - - to = _to; - return to; -} - -var toEnd; -var hasRequiredToEnd; - -function requireToEnd() { - if (hasRequiredToEnd) return toEnd; - hasRequiredToEnd = 1; - var common = requireCommon(); - var fs = require$$1__default["default"]; - var path = require$$2__default["default"]; - common.register('toEnd', _toEnd, { - pipeOnly: true, - wrapOutput: false - }); - - function _toEnd(options, file) { - if (!file) common.error('wrong arguments'); - - if (!fs.existsSync(path.dirname(file))) { - common.error('no such file or directory: ' + path.dirname(file)); - } - - try { - fs.appendFileSync(file, this.stdout || this.toString(), 'utf8'); - return this; - } catch (e) { - common.error('could not append to file (code ' + e.code + '): ' + file, { - continue: true - }); - } - } - - toEnd = _toEnd; - return toEnd; -} - -var touch; -var hasRequiredTouch; - -function requireTouch() { - if (hasRequiredTouch) return touch; - hasRequiredTouch = 1; - var common = requireCommon(); - var fs = require$$1__default["default"]; - common.register('touch', _touch, { - cmdOptions: { - 'a': 'atime_only', - 'c': 'no_create', - 'd': 'date', - 'm': 'mtime_only', - 'r': 'reference' - } - }); - - function _touch(opts, files) { - if (!files) { - common.error('no files given'); - } else if (typeof files === 'string') { - files = [].slice.call(arguments, 1); - } else { - common.error('file arg should be a string file path or an Array of string file paths'); - } - - files.forEach(function (f) { - touchFile(opts, f); - }); - return ''; - } - - function touchFile(opts, file) { - var stat = tryStatFile(file); - - if (stat && stat.isDirectory()) { - return; - } - - if (!stat && opts.no_create) { - return; - } - - fs.closeSync(fs.openSync(file, 'a')); - var now = new Date(); - var mtime = opts.date || now; - var atime = opts.date || now; - - if (opts.reference) { - var refStat = tryStatFile(opts.reference); - - if (!refStat) { - common.error('failed to get attributess of ' + opts.reference); - } - - mtime = refStat.mtime; - atime = refStat.atime; - } else if (opts.date) { - mtime = opts.date; - atime = opts.date; - } - - if (opts.atime_only && opts.mtime_only) ; else if (opts.atime_only) { - mtime = stat.mtime; - } else if (opts.mtime_only) { - atime = stat.atime; - } - - fs.utimesSync(file, atime, mtime); - } - - touch = _touch; - - function tryStatFile(filePath) { - try { - return common.statFollowLinks(filePath); - } catch (e) { - return null; - } - } - - return touch; -} - -var uniq; -var hasRequiredUniq; - -function requireUniq() { - if (hasRequiredUniq) return uniq; - hasRequiredUniq = 1; - var common = requireCommon(); - var fs = require$$1__default["default"]; - - function lpad(c, str) { - var res = '' + str; - - if (res.length < c) { - res = Array(c - res.length + 1).join(' ') + res; - } - - return res; - } - - common.register('uniq', _uniq, { - canReceivePipe: true, - cmdOptions: { - 'i': 'ignoreCase', - 'c': 'count', - 'd': 'duplicates' - } - }); - - function _uniq(options, input, output) { - var pipe = common.readFromPipe(); - - if (!pipe) { - if (!input) common.error('no input given'); - - if (!fs.existsSync(input)) { - common.error(input + ': No such file or directory'); - } else if (common.statFollowLinks(input).isDirectory()) { - common.error("error reading '" + input + "'"); - } - } - - if (output && fs.existsSync(output) && common.statFollowLinks(output).isDirectory()) { - common.error(output + ': Is a directory'); - } - - var lines = (input ? fs.readFileSync(input, 'utf8') : pipe).trimRight().split('\n'); - - var compare = function compare(a, b) { - return options.ignoreCase ? a.toLocaleLowerCase().localeCompare(b.toLocaleLowerCase()) : a.localeCompare(b); - }; - - var uniqed = lines.reduceRight(function (res, e) { - if (res.length === 0) { - return [{ - count: 1, - ln: e - }]; - } else if (compare(res[0].ln, e) === 0) { - return [{ - count: res[0].count + 1, - ln: e - }].concat(res.slice(1)); - } else { - return [{ - count: 1, - ln: e - }].concat(res); - } - }, []).filter(function (obj) { - return options.duplicates ? obj.count > 1 : true; - }).map(function (obj) { - return (options.count ? lpad(7, obj.count) + ' ' : '') + obj.ln; - }).join('\n') + '\n'; - - if (output) { - new common.ShellString(uniqed).to(output); - return ''; - } else { - return uniqed; - } - } - - uniq = _uniq; - return uniq; -} - -var which; -var hasRequiredWhich; - -function requireWhich() { - if (hasRequiredWhich) return which; - hasRequiredWhich = 1; - var common = requireCommon(); - var fs = require$$1__default["default"]; - var path = require$$2__default["default"]; - common.register('which', _which, { - allowGlobbing: false, - cmdOptions: { - 'a': 'all' - } - }); - var XP_DEFAULT_PATHEXT = '.com;.exe;.bat;.cmd;.vbs;.vbe;.js;.jse;.wsf;.wsh'; - var FILE_EXECUTABLE_MODE = 1; - - function isWindowsPlatform() { - return process.platform === 'win32'; - } - - function splitPath(p) { - return p ? p.split(path.delimiter) : []; - } - - function isExecutable(pathName) { - try { - fs.accessSync(pathName, FILE_EXECUTABLE_MODE); - } catch (err) { - return false; - } - - return true; - } - - function checkPath(pathName) { - return fs.existsSync(pathName) && !common.statFollowLinks(pathName).isDirectory() && (isWindowsPlatform() || isExecutable(pathName)); - } - - function _which(options, cmd) { - if (!cmd) common.error('must specify command'); - var isWindows = isWindowsPlatform(); - var pathArray = splitPath(process.env.PATH); - var queryMatches = []; - - if (cmd.indexOf('/') === -1) { - var pathExtArray = ['']; - - if (isWindows) { - var pathExtEnv = process.env.PATHEXT || XP_DEFAULT_PATHEXT; - pathExtArray = splitPath(pathExtEnv.toUpperCase()); - } - - for (var k = 0; k < pathArray.length; k++) { - if (queryMatches.length > 0 && !options.all) break; - var attempt = path.resolve(pathArray[k], cmd); - - if (isWindows) { - attempt = attempt.toUpperCase(); - } - - var match = attempt.match(/\.[^<>:"/\|?*.]+$/); - - if (match && pathExtArray.indexOf(match[0]) >= 0) { - if (checkPath(attempt)) { - queryMatches.push(attempt); - break; - } - } else { - for (var i = 0; i < pathExtArray.length; i++) { - var ext = pathExtArray[i]; - var newAttempt = attempt + ext; - - if (checkPath(newAttempt)) { - queryMatches.push(newAttempt); - break; - } - } - } - } - } else if (checkPath(cmd)) { - queryMatches.push(path.resolve(cmd)); - } - - if (queryMatches.length > 0) { - return options.all ? queryMatches : queryMatches[0]; - } - - return options.all ? [] : null; - } - - which = _which; - return which; -} - -var dynamicModules; - -function getDynamicModules() { - return dynamicModules || (dynamicModules = { - "/node_modules/shelljs/src/cat.js": requireCat, - "/node_modules/shelljs/src/cd.js": requireCd, - "/node_modules/shelljs/src/chmod.js": requireChmod, - "/node_modules/shelljs/src/common.js": requireCommon, - "/node_modules/shelljs/src/cp.js": requireCp, - "/node_modules/shelljs/src/dirs.js": requireDirs, - "/node_modules/shelljs/src/echo.js": requireEcho, - "/node_modules/shelljs/src/error.js": requireError, - "/node_modules/shelljs/src/exec-child.js": requireExecChild, - "/node_modules/shelljs/src/exec.js": requireExec, - "/node_modules/shelljs/src/find.js": requireFind, - "/node_modules/shelljs/src/grep.js": requireGrep, - "/node_modules/shelljs/src/head.js": requireHead, - "/node_modules/shelljs/src/ln.js": requireLn, - "/node_modules/shelljs/src/ls.js": requireLs, - "/node_modules/shelljs/src/mkdir.js": requireMkdir, - "/node_modules/shelljs/src/mv.js": requireMv, - "/node_modules/shelljs/src/popd.js": requirePopd, - "/node_modules/shelljs/src/pushd.js": requirePushd, - "/node_modules/shelljs/src/pwd.js": requirePwd, - "/node_modules/shelljs/src/rm.js": requireRm, - "/node_modules/shelljs/src/sed.js": requireSed, - "/node_modules/shelljs/src/set.js": requireSet, - "/node_modules/shelljs/src/sort.js": requireSort, - "/node_modules/shelljs/src/tail.js": requireTail, - "/node_modules/shelljs/src/tempdir.js": requireTempdir, - "/node_modules/shelljs/src/test.js": requireTest, - "/node_modules/shelljs/src/to.js": requireTo, - "/node_modules/shelljs/src/toEnd.js": requireToEnd, - "/node_modules/shelljs/src/touch.js": requireTouch, - "/node_modules/shelljs/src/uniq.js": requireUniq, - "/node_modules/shelljs/src/which.js": requireWhich - }); -} - -function createCommonjsRequire(originalModuleDir) { - function handleRequire(path) { - var resolvedPath = commonjsResolve(path, originalModuleDir); - if (resolvedPath !== null) { - return getDynamicModules()[resolvedPath](); - } - throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); - } - handleRequire.resolve = function (path) { - var resolvedPath = commonjsResolve(path, originalModuleDir); - if (resolvedPath !== null) { - return resolvedPath; - } - return require.resolve(path); - }; - return handleRequire; -} - -function commonjsResolve (path, originalModuleDir) { - var shouldTryNodeModules = isPossibleNodeModulesPath(path); - path = normalize(path); - var relPath; - if (path[0] === '/') { - originalModuleDir = ''; - } - var modules = getDynamicModules(); - var checkedExtensions = ['', '.js', '.json']; - while (true) { - if (!shouldTryNodeModules) { - relPath = normalize(originalModuleDir + '/' + path); - } else { - relPath = normalize(originalModuleDir + '/node_modules/' + path); - } - - if (relPath.endsWith('/..')) { - break; // Travelled too far up, avoid infinite loop - } - - for (var extensionIndex = 0; extensionIndex < checkedExtensions.length; extensionIndex++) { - var resolvedPath = relPath + checkedExtensions[extensionIndex]; - if (modules[resolvedPath]) { - return resolvedPath; - } - } - if (!shouldTryNodeModules) break; - var nextDir = normalize(originalModuleDir + '/..'); - if (nextDir === originalModuleDir) break; - originalModuleDir = nextDir; - } - return null; -} - -function isPossibleNodeModulesPath (modulePath) { - var c0 = modulePath[0]; - if (c0 === '/' || c0 === '\\') return false; - var c1 = modulePath[1], c2 = modulePath[2]; - if ((c0 === '.' && (!c1 || c1 === '/' || c1 === '\\')) || - (c0 === '.' && c1 === '.' && (!c2 || c2 === '/' || c2 === '\\'))) return false; - if (c1 === ':' && (c2 === '/' || c2 === '\\')) return false; - return true; -} - -function normalize (path) { - path = path.replace(/\\/g, '/'); - var parts = path.split('/'); - var slashed = parts[0] === ''; - for (var i = 1; i < parts.length; i++) { - if (parts[i] === '.' || parts[i] === '') { - parts.splice(i--, 1); - } - } - for (var i = 1; i < parts.length; i++) { - if (parts[i] !== '..') continue; - if (i > 0 && parts[i - 1] !== '..' && parts[i - 1] !== '.') { - parts.splice(--i, 2); - i--; - } - } - path = parts.join('/'); - if (slashed && path[0] !== '/') path = '/' + path; - else if (path.length === 0) path = '.'; - return path; -} - -var shell$2 = {}; - -var commands = ['cat', 'cd', 'chmod', 'cp', 'dirs', 'echo', 'exec', 'find', 'grep', 'head', 'ln', 'ls', 'mkdir', 'mv', 'pwd', 'rm', 'sed', 'set', 'sort', 'tail', 'tempdir', 'test', 'to', 'toEnd', 'touch', 'uniq', 'which']; - -var hasRequiredShell; - -function requireShell() { - if (hasRequiredShell) return shell$2; - hasRequiredShell = 1; - var common = requireCommon(); - commands.forEach(function (command) { - createCommonjsRequire("/node_modules/shelljs")('./src/' + command); - }); - shell$2.exit = process.exit; - shell$2.error = requireError(); - shell$2.ShellString = common.ShellString; - shell$2.env = process.env; - shell$2.config = common.config; - return shell$2; -} - -var shell$1 = requireShell(); -var common = requireCommon(); -Object.keys(shell$1).forEach(function (cmd) { - commonjsGlobal[cmd] = shell$1[cmd]; -}); - -var _to = requireTo(); - -String.prototype.to = common.wrap('to', _to); - -var _toEnd = requireToEnd(); - -String.prototype.toEnd = common.wrap('toEnd', _toEnd); - -commonjsGlobal.config.fatal = true; -commonjsGlobal.target = {}; -var args = process.argv.slice(2), - targetArgs, - dashesLoc = args.indexOf('--'); - -if (dashesLoc > -1) { - targetArgs = args.slice(dashesLoc + 1, args.length); - args = args.slice(0, dashesLoc); -} - -setTimeout(function () { - var t; - - if (args.length === 1 && args[0] === '--help') { - console.log('Available targets:'); - - for (t in commonjsGlobal.target) console.log(' ' + t); - - return; - } - - for (t in commonjsGlobal.target) { - (function (t, oldTarget) { - commonjsGlobal.target[t] = function () { - if (!oldTarget.done) { - oldTarget.done = true; - oldTarget.result = oldTarget.apply(oldTarget, arguments); - } - - return oldTarget.result; - }; - })(t, commonjsGlobal.target[t]); - } - - if (args.length > 0) { - args.forEach(function (arg) { - if (arg in commonjsGlobal.target) commonjsGlobal.target[arg](targetArgs);else { - console.log('no such target: ' + arg); - } - }); - } else if ('all' in commonjsGlobal.target) { - commonjsGlobal.target.all(targetArgs); - } -}, 0); - -const shell = global; -const target = new Proxy(global.target, { - set: function set(obj, prop, value) { - return Reflect.set(...arguments); - }, - get: function get(obj, prop, receiver) { - print(`make ${prop}`); - return Reflect.get(...arguments); - } -}); -const SOURCES = ["packages", "codemods", "eslint"]; -const EslintArgs = ["eslint", "scripts", "benchmark", ...SOURCES, "*.{js,cjs,mjs,ts}", "--format", "codeframe", "--ext", ".js,.cjs,.mjs,.ts"]; -const YARN_PATH = shell.which("yarn").stdout; -const NODE_PATH = process.execPath; -shell.config.verbose = true; - -function print(...msgs) { - console.log.apply(console, msgs); -} - -function exec(executable, args, cwd, inheritStdio = true) { - print(`${executable.replaceAll(YARN_PATH, "yarn").replaceAll(NODE_PATH, "node")} ${args.join(" ")}`); - - try { - return require$$0$1.execFileSync(executable, args, { - stdio: inheritStdio ? "inherit" : undefined, - cwd: cwd && require$$2__default["default"].resolve(cwd), - env: process.env - }); - } catch (error) { - if (inheritStdio && error.status != 0) { - console.error(new Error(`\ncommand: ${executable} ${args.join(" ")}\ncode: ${error.status}`)); - process.exit(error.status); - } - - throw error; - } -} - -function yarn(args, cwd, inheritStdio) { - return exec(YARN_PATH, args, cwd, inheritStdio); -} - -function node(args, cwd, inheritStdio) { - return exec(NODE_PATH, args, cwd, inheritStdio); -} - -function env(fun, env) { - const envBak = process.env; - process.env = Object.assign(Object.assign({}, envBak), env); - fun(); - process.env = envBak; -} - -target["clean-all"] = function () { - ["node_modules", "package-lock.json", ".changelog"].forEach(path => { - shell.rm("-rf", path); - }); - SOURCES.forEach(source => { - shell.rm("-rf", `${source}/*/test/tmp`); - shell.rm("-rf", `${source}/*/package-lock.json`); - }); - target["clean"](); - target["clean-lib"](); -}; - -target["clean"] = function () { - target["test-clean"](); - [".npmrc", "coverage", "packages/*/npm-debug*", "node_modules/.cache"].forEach(path => { - shell.rm("-rf", path); - }); -}; - -target["test-clean"] = function () { - SOURCES.forEach(source => { - shell.rm("-rf", `${source}/*/test/tmp`); - shell.rm("-rf", `${source}/*/test-fixtures.json`); - }); -}; - -target["clean-lib"] = function () { - SOURCES.forEach(source => { - shell.rm("-rf", `${source}/*/lib`); - }); -}; - -target["clean-runtime-helpers"] = function () { - ["packages/babel-runtime/helpers/**/*.js", "packages/babel-runtime-corejs2/helpers/**/*.js", "packages/babel-runtime-corejs3/helpers/**/*.js", "packages/babel-runtime/helpers/**/*.mjs", "packages/babel-runtime-corejs2/helpers/**/*.mjs", "packages/babel-runtime-corejs3/helpers/**/*.mjs", "packages/babel-runtime-corejs2/core-js"].forEach(path => { - shell.rm("-rf", path); - }); -}; - -target["use-cjs"] = function () { - node(["scripts/set-module-type.js", "script"]); - target["bootstrap"](); -}; - -target["use-esm"] = function () { - node(["scripts/set-module-type.js", "module"]); - target["bootstrap"](); -}; - -target["bootstrap-only"] = function () { - target["clean-all"](); - yarn(["install"]); -}; - -target["bootstrap"] = function () { - target["bootstrap-only"](); - target["generate-tsconfig"](); - target["build"](); -}; - -target["build"] = function () { - target["build-no-bundle"](); - - if (process.env.BABEL_COVERAGE != "true") { - target["build-standalone"](); - } -}; - -target["build-standalone"] = function () { - yarn(["gulp", "build-babel-standalone"]); -}; - -target["build-bundle"] = function () { - target["clean"](); - target["clean-lib"](); - node(["scripts/set-module-type.js"]); - yarn(["gulp", "build"]); - target["build-flow-typings"](); - target["build-dist"](); -}; - -target["build-no-bundle"] = function () { - target["clean"](); - target["clean-lib"](); - node(["scripts/set-module-type.js"]); - env(() => { - yarn(["gulp", "build-dev"]); - }, { - BABEL_ENV: "development" - }); - target["build-flow-typings"](); - target["build-dist"](); -}; - -target["build-flow-typings"] = function () { - require$$1.writeFileSync("packages/babel-types/lib/index.js.flow", node(["packages/babel-types/scripts/generators/flow.js"], undefined, false)); -}; - -target["build-dist"] = function () { - target["build-plugin-transform-runtime-dist"](); -}; - -target["build-plugin-transform-runtime-dist"] = function () { - node(["scripts/build-dist.js"], "packages/babel-plugin-transform-runtime"); -}; - -target["prepublish"] = function () { - target["bootstrap-only"](); - target["prepublish-build"](); - env(() => { - target["test"](); - }, { - IS_PUBLISH: "true" - }); - node(["scripts/set-module-type.js", "clean"]); -}; - -target["prepublish-build"] = function () { - target["clean-lib"](); - target["clean-runtime-helpers"](); - env(() => { - target["build-bundle"](); - }, { - NODE_ENV: "production", - BABEL_ENV: "production", - STRIP_BABEL_8_FLAG: "true" - }); - env(() => { - target["prepublish-build-standalone"](); - target["clone-license"](); - target["prepublish-prepare-dts"](); - }, { - STRIP_BABEL_8_FLAG: "true" - }); -}; - -target["prepublish-build-standalone"] = function () { - env(() => { - target["build-standalone"](); - }, { - BABEL_ENV: "production", - IS_PUBLISH: "true" - }); -}; - -target["prepublish-prepare-dts"] = function () { - target["tscheck"](); - yarn(["gulp", "bundle-dts"]); - target["build-typescript-legacy-typings"](); -}; - -target["tscheck"] = function () { - target["generate-tsconfig"](); - shell.rm("-rf", "dts"); - yarn(["tsc", "-b", "."]); -}; - -target["generate-tsconfig"] = function () { - node(["scripts/generators/tsconfig.js"]); - node(["scripts/generators/archived-libs-typings.js"]); -}; - -target["generate-type-helpers"] = function () { - yarn(["gulp", "generate-type-helpers"]); -}; - -target["build-typescript-legacy-typings"] = function () { - require$$1.writeFileSync("packages/babel-types/lib/index-legacy.d.ts", node(["packages/babel-types/scripts/generators/typescript-legacy.js"], undefined, false)); -}; - -target["clone-license"] = function () { - node(["scripts/clone-license.js"]); -}; - -target["lint"] = function () { - env(() => { - yarn(EslintArgs); - }, { - BABEL_ENV: "test" - }); -}; - -target["fix"] = function () { - target["fix-json"](); - target["fix-js"](); -}; - -target["fix-js"] = function () { - yarn([...EslintArgs, "--fix"]); -}; - -target["fix-json"] = function () { - yarn(["prettier", `{${SOURCES.join(",")}}/*/test/fixtures/**/options.json`, "--write", "--loglevel", "warn"]); -}; - -target["watch"] = function () { - target["build-no-bundle"](); - env(() => { - yarn(["gulp", "watch"]); - }, { - BABEL_ENV: "development", - WATCH_SKIP_BUILD: "true" - }); -}; - -target["test"] = function () { - target["lint"](); - target["test-only"](); -}; - -target["test-only"] = function (args = []) { - yarn(["jest", ...args]); -}; - -target["new-version-checklist"] = function () { -}; - -target["new-version"] = function () { - target["new-version-checklist"](); - exec("git", ["pull", "--rebase"]); - yarn(["release-tool", "version", "-f", "@babel/standalone"]); -}; - -target["new-version"] = function () { - target["new-version-checklist"](); - exec("git", ["pull", "--rebase"]); - yarn(["release-tool", "version", "-f", "@babel/standalone"]); -}; + "use strict";var e=require("os"),t=require("fs"),r=require("path"),n=require("events"),i=require("assert"),o=require("util"),s=require("child_process");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=c(e),u=c(t),l=c(r),f=c(n),h=c(i),p=c(o),d=c(s),v="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},y=function(e){return e&&e.Math==Math&&e},g=y("object"==typeof globalThis&&globalThis)||y("object"==typeof window&&window)||y("object"==typeof self&&self)||y("object"==typeof v&&v)||function(){return this}()||Function("return this")(),m={},b=function(e){try{return!!e()}catch(e){return!0}},w=!b((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),E=!b((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")})),S=E,x=Function.prototype.call,O=S?x.bind(x):function(){return x.apply(x,arguments)},k={},j={}.propertyIsEnumerable,_=Object.getOwnPropertyDescriptor,A=_&&!j.call({1:2},1);k.f=A?function(e){var t=_(this,e);return!!t&&t.enumerable}:j;var R,I,F=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}},L=E,T=Function.prototype,P=T.bind,D=T.call,C=L&&P.bind(D,D),N=L?function(e){return e&&C(e)}:function(e){return e&&function(){return D.apply(e,arguments)}},M=N,G=M({}.toString),$=M("".slice),B=function(e){return $(G(e),8,-1)},q=b,U=B,W=Object,z=N("".split),X=q((function(){return!W("z").propertyIsEnumerable(0)}))?function(e){return"String"==U(e)?z(e,""):W(e)}:W,Y=TypeError,K=function(e){if(null==e)throw Y("Can't call method on "+e);return e},H=X,V=K,Q=function(e){return H(V(e))},J=function(e){return"function"==typeof e},Z=J,ee=function(e){return"object"==typeof e?null!==e:Z(e)},te=g,re=J,ne=function(e){return re(e)?e:void 0},ie=function(e,t){return arguments.length<2?ne(te[e]):te[e]&&te[e][t]},oe=N({}.isPrototypeOf),se=ie("navigator","userAgent")||"",ce=g,ae=se,ue=ce.process,le=ce.Deno,fe=ue&&ue.versions||le&&le.version,he=fe&&fe.v8;he&&(I=(R=he.split("."))[0]>0&&R[0]<4?1:+(R[0]+R[1])),!I&&ae&&(!(R=ae.match(/Edge\/(\d+)/))||R[1]>=74)&&(R=ae.match(/Chrome\/(\d+)/))&&(I=+R[1]);var pe=I,de=pe,ve=b,ye=!!Object.getOwnPropertySymbols&&!ve((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&de&&de<41})),ge=ye&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,me=ie,be=J,we=oe,Ee=Object,Se=ge?function(e){return"symbol"==typeof e}:function(e){var t=me("Symbol");return be(t)&&we(t.prototype,Ee(e))},xe=String,Oe=function(e){try{return xe(e)}catch(e){return"Object"}},ke=J,je=Oe,_e=TypeError,Ae=function(e){if(ke(e))return e;throw _e(je(e)+" is not a function")},Re=Ae,Ie=function(e,t){var r=e[t];return null==r?void 0:Re(r)},Fe=O,Le=J,Te=ee,Pe=TypeError,De={exports:{}},Ce=g,Ne=Object.defineProperty,Me=function(e,t){try{Ne(Ce,e,{value:t,configurable:!0,writable:!0})}catch(r){Ce[e]=t}return t},Ge=Me,$e=g["__core-js_shared__"]||Ge("__core-js_shared__",{}),Be=$e;(De.exports=function(e,t){return Be[e]||(Be[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.23.4",mode:"global",copyright:"© 2014-2022 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.23.4/LICENSE",source:"https://github.com/zloirock/core-js"});var qe=K,Ue=Object,We=function(e){return Ue(qe(e))},ze=We,Xe=N({}.hasOwnProperty),Ye=Object.hasOwn||function(e,t){return Xe(ze(e),t)},Ke=N,He=0,Ve=Math.random(),Qe=Ke(1..toString),Je=function(e){return"Symbol("+(void 0===e?"":e)+")_"+Qe(++He+Ve,36)},Ze=g,et=De.exports,tt=Ye,rt=Je,nt=ye,it=ge,ot=et("wks"),st=Ze.Symbol,ct=st&&st.for,at=it?st:st&&st.withoutSetter||rt,ut=function(e){if(!tt(ot,e)||!nt&&"string"!=typeof ot[e]){var t="Symbol."+e;nt&&tt(st,e)?ot[e]=st[e]:ot[e]=it&&ct?ct(t):at(t)}return ot[e]},lt=O,ft=ee,ht=Se,pt=Ie,dt=function(e,t){var r,n;if("string"===t&&Le(r=e.toString)&&!Te(n=Fe(r,e)))return n;if(Le(r=e.valueOf)&&!Te(n=Fe(r,e)))return n;if("string"!==t&&Le(r=e.toString)&&!Te(n=Fe(r,e)))return n;throw Pe("Can't convert object to primitive value")},vt=TypeError,yt=ut("toPrimitive"),gt=function(e,t){if(!ft(e)||ht(e))return e;var r,n=pt(e,yt);if(n){if(void 0===t&&(t="default"),r=lt(n,e,t),!ft(r)||ht(r))return r;throw vt("Can't convert object to primitive value")}return void 0===t&&(t="number"),dt(e,t)},mt=Se,bt=function(e){var t=gt(e,"string");return mt(t)?t:t+""},wt=ee,Et=g.document,St=wt(Et)&&wt(Et.createElement),xt=function(e){return St?Et.createElement(e):{}},Ot=xt,kt=!w&&!b((function(){return 7!=Object.defineProperty(Ot("div"),"a",{get:function(){return 7}}).a})),jt=w,_t=O,At=k,Rt=F,It=Q,Ft=bt,Lt=Ye,Tt=kt,Pt=Object.getOwnPropertyDescriptor;m.f=jt?Pt:function(e,t){if(e=It(e),t=Ft(t),Tt)try{return Pt(e,t)}catch(e){}if(Lt(e,t))return Rt(!_t(At.f,e,t),e[t])};var Dt={},Ct=w&&b((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Nt=ee,Mt=String,Gt=TypeError,$t=function(e){if(Nt(e))return e;throw Gt(Mt(e)+" is not an object")},Bt=w,qt=kt,Ut=Ct,Wt=$t,zt=bt,Xt=TypeError,Yt=Object.defineProperty,Kt=Object.getOwnPropertyDescriptor;Dt.f=Bt?Ut?function(e,t,r){if(Wt(e),t=zt(t),Wt(r),"function"==typeof e&&"prototype"===t&&"value"in r&&"writable"in r&&!r.writable){var n=Kt(e,t);n&&n.writable&&(e[t]=r.value,r={configurable:"configurable"in r?r.configurable:n.configurable,enumerable:"enumerable"in r?r.enumerable:n.enumerable,writable:!1})}return Yt(e,t,r)}:Yt:function(e,t,r){if(Wt(e),t=zt(t),Wt(r),qt)try{return Yt(e,t,r)}catch(e){}if("get"in r||"set"in r)throw Xt("Accessors not supported");return"value"in r&&(e[t]=r.value),e};var Ht=Dt,Vt=F,Qt=w?function(e,t,r){return Ht.f(e,t,Vt(1,r))}:function(e,t,r){return e[t]=r,e},Jt={exports:{}},Zt=w,er=Ye,tr=Function.prototype,rr=Zt&&Object.getOwnPropertyDescriptor,nr=er(tr,"name"),ir={EXISTS:nr,PROPER:nr&&"something"===function(){}.name,CONFIGURABLE:nr&&(!Zt||Zt&&rr(tr,"name").configurable)},or=J,sr=$e,cr=N(Function.toString);or(sr.inspectSource)||(sr.inspectSource=function(e){return cr(e)});var ar,ur,lr,fr=sr.inspectSource,hr=J,pr=fr,dr=g.WeakMap,vr=hr(dr)&&/native code/.test(pr(dr)),yr=De.exports,gr=Je,mr=yr("keys"),br=function(e){return mr[e]||(mr[e]=gr(e))},wr={},Er=vr,Sr=g,xr=N,Or=ee,kr=Qt,jr=Ye,_r=$e,Ar=br,Rr=wr,Ir=Sr.TypeError,Fr=Sr.WeakMap;if(Er||_r.state){var Lr=_r.state||(_r.state=new Fr),Tr=xr(Lr.get),Pr=xr(Lr.has),Dr=xr(Lr.set);ar=function(e,t){if(Pr(Lr,e))throw new Ir("Object already initialized");return t.facade=e,Dr(Lr,e,t),t},ur=function(e){return Tr(Lr,e)||{}},lr=function(e){return Pr(Lr,e)}}else{var Cr=Ar("state");Rr[Cr]=!0,ar=function(e,t){if(jr(e,Cr))throw new Ir("Object already initialized");return t.facade=e,kr(e,Cr,t),t},ur=function(e){return jr(e,Cr)?e[Cr]:{}},lr=function(e){return jr(e,Cr)}}var Nr={set:ar,get:ur,has:lr,enforce:function(e){return lr(e)?ur(e):ar(e,{})},getterFor:function(e){return function(t){var r;if(!Or(t)||(r=ur(t)).type!==e)throw Ir("Incompatible receiver, "+e+" required");return r}}},Mr=b,Gr=J,$r=Ye,Br=w,qr=ir.CONFIGURABLE,Ur=fr,Wr=Nr.enforce,zr=Nr.get,Xr=Object.defineProperty,Yr=Br&&!Mr((function(){return 8!==Xr((function(){}),"length",{value:8}).length})),Kr=String(String).split("String"),Hr=Jt.exports=function(e,t,r){"Symbol("===String(t).slice(0,7)&&(t="["+String(t).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),r&&r.getter&&(t="get "+t),r&&r.setter&&(t="set "+t),(!$r(e,"name")||qr&&e.name!==t)&&(Br?Xr(e,"name",{value:t,configurable:!0}):e.name=t),Yr&&r&&$r(r,"arity")&&e.length!==r.arity&&Xr(e,"length",{value:r.arity});try{r&&$r(r,"constructor")&&r.constructor?Br&&Xr(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(e){}var n=Wr(e);return $r(n,"source")||(n.source=Kr.join("string"==typeof t?t:"")),e};Function.prototype.toString=Hr((function(){return Gr(this)&&zr(this).source||Ur(this)}),"toString");var Vr=J,Qr=Dt,Jr=Jt.exports,Zr=Me,en=function(e,t,r,n){n||(n={});var i=n.enumerable,o=void 0!==n.name?n.name:t;if(Vr(r)&&Jr(r,o,n),n.global)i?e[t]=r:Zr(t,r);else{try{n.unsafe?e[t]&&(i=!0):delete e[t]}catch(e){}i?e[t]=r:Qr.f(e,t,{value:r,enumerable:!1,configurable:!n.nonConfigurable,writable:!n.nonWritable})}return e},tn={},rn=Math.ceil,nn=Math.floor,on=Math.trunc||function(e){var t=+e;return(t>0?nn:rn)(t)},sn=function(e){var t=+e;return t!=t||0===t?0:on(t)},cn=sn,an=Math.max,un=Math.min,ln=function(e,t){var r=cn(e);return r<0?an(r+t,0):un(r,t)},fn=sn,hn=Math.min,pn=function(e){return e>0?hn(fn(e),9007199254740991):0},dn=pn,vn=function(e){return dn(e.length)},yn=Q,gn=ln,mn=vn,bn=function(e){return function(t,r,n){var i,o=yn(t),s=mn(o),c=gn(n,s);if(e&&r!=r){for(;s>c;)if((i=o[c++])!=i)return!0}else for(;s>c;c++)if((e||c in o)&&o[c]===r)return e||c||0;return!e&&-1}},wn={includes:bn(!0),indexOf:bn(!1)},En=Ye,Sn=Q,xn=wn.indexOf,On=wr,kn=N([].push),jn=function(e,t){var r,n=Sn(e),i=0,o=[];for(r in n)!En(On,r)&&En(n,r)&&kn(o,r);for(;t.length>i;)En(n,r=t[i++])&&(~xn(o,r)||kn(o,r));return o},_n=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],An=jn,Rn=_n.concat("length","prototype");tn.f=Object.getOwnPropertyNames||function(e){return An(e,Rn)};var In={};In.f=Object.getOwnPropertySymbols;var Fn=ie,Ln=tn,Tn=In,Pn=$t,Dn=N([].concat),Cn=Fn("Reflect","ownKeys")||function(e){var t=Ln.f(Pn(e)),r=Tn.f;return r?Dn(t,r(e)):t},Nn=Ye,Mn=Cn,Gn=m,$n=Dt,Bn=function(e,t,r){for(var n=Mn(t),i=$n.f,o=Gn.f,s=0;ss;)gi.f(e,r=i[s++],n[r]);return e};var Ei,Si=ie("document","documentElement"),xi=$t,Oi=fi,ki=_n,ji=wr,_i=Si,Ai=xt,Ri=br("IE_PROTO"),Ii=function(){},Fi=function(e){return"