@datadog/webpack-plugin 2.0.2-dev-6 → 2.0.2-dev-8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1,16 @@
1
- import fs$l, { promises } from 'fs';
1
+ import fs$j, { promises } from 'fs';
2
2
  import require$$0 from 'tty';
3
3
  import require$$1 from 'util';
4
4
  import require$$0$1 from 'os';
5
5
  import { spawn } from 'child_process';
6
6
  import { EventEmitter as EventEmitter$1 } from 'node:events';
7
7
  import { URL as URL$1, fileURLToPath } from 'url';
8
- import require$$1$1, { resolve as resolve$1, extname, isAbsolute as isAbsolute$1, normalize } from 'path';
9
- import require$$4 from 'events';
10
- import require$$6 from 'assert';
8
+ import require$$1$1, { resolve as resolve$1, extname, isAbsolute, normalize } from 'path';
11
9
  import { File, Buffer as Buffer$1 } from 'buffer';
12
10
  import require$$0$3, { Readable } from 'stream';
13
11
  import { createGzip } from 'zlib';
14
12
  import require$$0$2 from 'constants';
13
+ import require$$5 from 'assert';
15
14
  import { request } from 'https';
16
15
  import { performance } from 'perf_hooks';
17
16
  import webpack from 'webpack';
@@ -203,11 +202,11 @@ function requireMs () {
203
202
  return ms;
204
203
  }
205
204
 
206
- var common$2;
205
+ var common$1;
207
206
  var hasRequiredCommon$1;
208
207
 
209
208
  function requireCommon$1 () {
210
- if (hasRequiredCommon$1) return common$2;
209
+ if (hasRequiredCommon$1) return common$1;
211
210
  hasRequiredCommon$1 = 1;
212
211
  /**
213
212
  * This is the common logic for both the Node.js and web browser
@@ -473,8 +472,8 @@ function requireCommon$1 () {
473
472
  return createDebug;
474
473
  }
475
474
 
476
- common$2 = setup;
477
- return common$2;
475
+ common$1 = setup;
476
+ return common$1;
478
477
  }
479
478
 
480
479
  /* eslint-env browser */
@@ -1201,7 +1200,7 @@ var srcExports$1 = src$1.exports;
1201
1200
  return (mod && mod.__esModule) ? mod : { "default": mod };
1202
1201
  };
1203
1202
  Object.defineProperty(exports, "__esModule", { value: true });
1204
- const fs_1 = fs$l;
1203
+ const fs_1 = fs$j;
1205
1204
  const debug_1 = __importDefault(srcExports$1);
1206
1205
  const log = debug_1.default('@kwsites/file-exists');
1207
1206
  function check(path, isFile, isDirectory) {
@@ -1266,11 +1265,11 @@ var src = {exports: {}};
1266
1265
 
1267
1266
  var browser = {exports: {}};
1268
1267
 
1269
- var common$1;
1268
+ var common;
1270
1269
  var hasRequiredCommon;
1271
1270
 
1272
1271
  function requireCommon () {
1273
- if (hasRequiredCommon) return common$1;
1272
+ if (hasRequiredCommon) return common;
1274
1273
  hasRequiredCommon = 1;
1275
1274
  /**
1276
1275
  * This is the common logic for both the Node.js and web browser
@@ -1544,8 +1543,8 @@ function requireCommon () {
1544
1543
  return createDebug;
1545
1544
  }
1546
1545
 
1547
- common$1 = setup;
1548
- return common$1;
1546
+ common = setup;
1547
+ return common;
1549
1548
  }
1550
1549
 
1551
1550
  /* eslint-env browser */
@@ -6768,18 +6767,20 @@ class TrackedFilesMatcher {
6768
6767
  }
6769
6768
  // Looks up the sources declared in the sourcemap and return a list of related tracked files.
6770
6769
  matchSourcemap(srcmapPath, onSourcesNotFound) {
6771
- const buff = fs$l.readFileSync(srcmapPath, "utf8");
6770
+ const buff = fs$j.readFileSync(srcmapPath, "utf8");
6772
6771
  const srcmapObj = JSON.parse(buff);
6773
6772
  if (!srcmapObj.sources) {
6773
+ onSourcesNotFound(`Missing 'sources' field in sourcemap.`);
6774
6774
  return void 0;
6775
6775
  }
6776
6776
  const sources = srcmapObj.sources;
6777
- if (!sources || sources.length === 0) {
6777
+ if (sources.length === 0) {
6778
+ onSourcesNotFound(`Empty 'sources' field in sourcemap.`);
6778
6779
  return void 0;
6779
6780
  }
6780
6781
  const filtered = this.matchSources(sources);
6781
6782
  if (filtered.length === 0) {
6782
- onSourcesNotFound();
6783
+ onSourcesNotFound(`Sources not in the tracked files.`);
6783
6784
  return void 0;
6784
6785
  }
6785
6786
  return filtered;
@@ -6918,54 +6919,6 @@ const getGitPlugin = (options, context) => {
6918
6919
  };
6919
6920
  };
6920
6921
 
6921
- const getGlobalContextPlugin = (opts, meta) => {
6922
- const globalContext = {
6923
- auth: opts.auth,
6924
- cwd: process.cwd(),
6925
- version: meta.version,
6926
- bundler: {
6927
- name: meta.framework
6928
- }
6929
- };
6930
- const globalContextPlugin = {
6931
- name: "global-context-plugin",
6932
- enforce: "pre",
6933
- esbuild: {
6934
- setup(build) {
6935
- globalContext.bundler.config = build.initialOptions;
6936
- }
6937
- },
6938
- webpack(compiler) {
6939
- globalContext.bundler.config = compiler.options;
6940
- },
6941
- vite: {
6942
- options(options) {
6943
- globalContext.bundler.config = options;
6944
- }
6945
- },
6946
- rollup: {
6947
- options(options) {
6948
- globalContext.bundler.config = options;
6949
- }
6950
- },
6951
- rspack(compiler) {
6952
- globalContext.bundler.config = compiler.options;
6953
- },
6954
- farm: {
6955
- configResolved(config) {
6956
- globalContext.bundler.config = config;
6957
- }
6958
- }
6959
- };
6960
- return { globalContext, globalContextPlugin };
6961
- };
6962
-
6963
- const getInternalPlugins = (options, meta) => {
6964
- const { globalContext, globalContextPlugin } = getGlobalContextPlugin(options, meta);
6965
- const gitPlugin = getGitPlugin(options, globalContext);
6966
- return { globalContext, internalPlugins: [globalContextPlugin, gitPlugin] };
6967
- };
6968
-
6969
6922
  var chalk$1 = {exports: {}};
6970
6923
 
6971
6924
  var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
@@ -8865,7 +8818,7 @@ const log = (text, level, type = "debug", name) => {
8865
8818
  color = chalk.cyan;
8866
8819
  logFn = console.log;
8867
8820
  }
8868
- const prefix = name ? `[${chalk.bold(name)}|${type}] ` : "";
8821
+ const prefix = name ? `[${type}|${name}] ` : "";
8869
8822
  if (level === "debug" || level === "info" && ["info", "error", "warn"].includes(type) || level === "warn" && ["error", "warn"].includes(type) || level === "error" && type === "error") {
8870
8823
  const content = typeof text === "string" ? text : JSON.stringify(text, null, 2);
8871
8824
  logFn(`${color(prefix)}${content}`);
@@ -8873,6 +8826,82 @@ const log = (text, level, type = "debug", name) => {
8873
8826
  };
8874
8827
  const getLogger = (level = "warn", name) => (text, type = "debug") => log(text, level, type, name);
8875
8828
 
8829
+ const PLUGIN_NAME$2 = "global-context-plugin";
8830
+ const getGlobalContextPlugin = (opts, meta) => {
8831
+ const log = getLogger(opts.logLevel, "internal-global-context");
8832
+ const globalContext = {
8833
+ auth: opts.auth,
8834
+ cwd: process.cwd(),
8835
+ version: meta.version,
8836
+ outputDir: process.cwd(),
8837
+ bundler: {
8838
+ name: meta.framework
8839
+ }
8840
+ };
8841
+ const globalContextPlugin = {
8842
+ name: PLUGIN_NAME$2,
8843
+ enforce: "pre",
8844
+ esbuild: {
8845
+ setup(build) {
8846
+ globalContext.bundler.config = build.initialOptions;
8847
+ if (build.initialOptions.outdir) {
8848
+ globalContext.outputDir = build.initialOptions.outdir;
8849
+ }
8850
+ build.initialOptions.metafile = true;
8851
+ build.onEnd((result) => {
8852
+ if (!result.metafile) {
8853
+ log("Missing metafile from build result.", "warn");
8854
+ return;
8855
+ }
8856
+ const files = [];
8857
+ for (const [output] of Object.entries(result.metafile.outputs)) {
8858
+ files.push({ filepath: require$$1$1.join(globalContext.outputDir, output) });
8859
+ }
8860
+ globalContext.outputFiles = files;
8861
+ });
8862
+ }
8863
+ },
8864
+ webpack(compiler) {
8865
+ globalContext.bundler.config = compiler.options;
8866
+ if (compiler.options.output?.path) {
8867
+ globalContext.outputDir = compiler.options.output.path;
8868
+ }
8869
+ compiler.hooks.emit.tap(PLUGIN_NAME$2, (compilation) => {
8870
+ const files = [];
8871
+ for (const filename of Object.keys(compilation.assets)) {
8872
+ files.push({ filepath: require$$1$1.join(globalContext.outputDir, filename) });
8873
+ }
8874
+ globalContext.outputFiles = files;
8875
+ });
8876
+ },
8877
+ vite: {
8878
+ options(options) {
8879
+ globalContext.bundler.config = options;
8880
+ }
8881
+ },
8882
+ rollup: {
8883
+ options(options) {
8884
+ globalContext.bundler.config = options;
8885
+ }
8886
+ },
8887
+ rspack(compiler) {
8888
+ globalContext.bundler.config = compiler.options;
8889
+ },
8890
+ farm: {
8891
+ configResolved(config) {
8892
+ globalContext.bundler.config = config;
8893
+ }
8894
+ }
8895
+ };
8896
+ return { globalContext, globalContextPlugin };
8897
+ };
8898
+
8899
+ const getInternalPlugins = (options, meta) => {
8900
+ const { globalContext, globalContextPlugin } = getGlobalContextPlugin(options, meta);
8901
+ const gitPlugin = getGitPlugin(options, globalContext);
8902
+ return { globalContext, internalPlugins: [globalContextPlugin, gitPlugin] };
8903
+ };
8904
+
8876
8905
  const CONFIG_KEY$1 = "rum";
8877
8906
  const PLUGIN_NAME$1 = "datadog-rum-plugin";
8878
8907
 
@@ -9039,3477 +9068,169 @@ if (typeof module !== "undefined") {
9039
9068
  catch (e) { }
9040
9069
  }
9041
9070
 
9042
- var old$1 = {};
9043
-
9044
- // Copyright Joyent, Inc. and other Node contributors.
9045
- //
9046
- // Permission is hereby granted, free of charge, to any person obtaining a
9047
- // copy of this software and associated documentation files (the
9048
- // "Software"), to deal in the Software without restriction, including
9049
- // without limitation the rights to use, copy, modify, merge, publish,
9050
- // distribute, sublicense, and/or sell copies of the Software, and to permit
9051
- // persons to whom the Software is furnished to do so, subject to the
9052
- // following conditions:
9053
- //
9054
- // The above copyright notice and this permission notice shall be included
9055
- // in all copies or substantial portions of the Software.
9056
- //
9057
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
9058
- // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
9059
- // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
9060
- // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
9061
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
9062
- // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
9063
- // USE OR OTHER DEALINGS IN THE SOFTWARE.
9064
-
9065
- var pathModule = require$$1$1;
9066
- var isWindows$1 = process.platform === 'win32';
9067
- var fs$k = fs$l;
9068
-
9069
- // JavaScript implementation of realpath, ported from node pre-v6
9070
-
9071
- var DEBUG = process.env.NODE_DEBUG && /fs/.test(process.env.NODE_DEBUG);
9072
-
9073
- function rethrow() {
9074
- // Only enable in debug mode. A backtrace uses ~1000 bytes of heap space and
9075
- // is fairly slow to generate.
9076
- var callback;
9077
- if (DEBUG) {
9078
- var backtrace = new Error;
9079
- callback = debugCallback;
9080
- } else
9081
- callback = missingCallback;
9082
-
9083
- return callback;
9084
-
9085
- function debugCallback(err) {
9086
- if (err) {
9087
- backtrace.message = err.message;
9088
- err = backtrace;
9089
- missingCallback(err);
9090
- }
9091
- }
9092
-
9093
- function missingCallback(err) {
9094
- if (err) {
9095
- if (process.throwDeprecation)
9096
- throw err; // Forgot a callback but don't know where? Use NODE_DEBUG=fs
9097
- else if (!process.noDeprecation) {
9098
- var msg = 'fs: missing callback ' + (err.stack || err.message);
9099
- if (process.traceDeprecation)
9100
- console.trace(msg);
9101
- else
9102
- console.error(msg);
9103
- }
9104
- }
9071
+ const decomposePath = (options, context, sourcemapFilePath) => {
9072
+ if (require$$1$1.extname(sourcemapFilePath) !== ".map") {
9073
+ throw new Error(`The file ${chalk.green.bold(sourcemapFilePath)} is not a sourcemap.`);
9105
9074
  }
9106
- }
9075
+ const minifiedFilePath = sourcemapFilePath.replace(/\.map$/, "");
9076
+ const relativePath = minifiedFilePath.replace(context.outputDir, "");
9077
+ const minifiedUrl = options.minifiedPathPrefix ? require$$1$1.join(options.minifiedPathPrefix, relativePath) : relativePath;
9078
+ return {
9079
+ minifiedFilePath,
9080
+ minifiedUrl,
9081
+ relativePath
9082
+ };
9083
+ };
9084
+ const getSourcemapsFiles = (options, context) => {
9085
+ if (!context.outputFiles || context.outputFiles.length === 0) {
9086
+ throw new Error("No output files found.");
9087
+ }
9088
+ const sourcemapFilesList = context.outputFiles.filter((file) => file.filepath.endsWith(".map")).map((file) => file.filepath);
9089
+ const sourcemapFiles = sourcemapFilesList.map((sourcemapFilePath) => {
9090
+ return {
9091
+ ...decomposePath(options, context, sourcemapFilePath),
9092
+ sourcemapFilePath,
9093
+ minifiedPathPrefix: options.minifiedPathPrefix
9094
+ };
9095
+ });
9096
+ return sourcemapFiles;
9097
+ };
9107
9098
 
9108
- function maybeCallback(cb) {
9109
- return typeof cb === 'function' ? cb : rethrow();
9110
- }
9099
+ var retry$4 = {};
9111
9100
 
9112
- pathModule.normalize;
9101
+ function RetryOperation(timeouts, options) {
9102
+ // Compatibility for the old (timeouts, retryForever) signature
9103
+ if (typeof options === 'boolean') {
9104
+ options = { forever: options };
9105
+ }
9113
9106
 
9114
- // Regexp that finds the next partion of a (partial) path
9115
- // result is [base_with_slash, base], e.g. ['somedir/', 'somedir']
9116
- if (isWindows$1) {
9117
- var nextPartRe = /(.*?)(?:[\/\\]+|$)/g;
9118
- } else {
9119
- var nextPartRe = /(.*?)(?:[\/]+|$)/g;
9120
- }
9107
+ this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
9108
+ this._timeouts = timeouts;
9109
+ this._options = options || {};
9110
+ this._maxRetryTime = options && options.maxRetryTime || Infinity;
9111
+ this._fn = null;
9112
+ this._errors = [];
9113
+ this._attempts = 1;
9114
+ this._operationTimeout = null;
9115
+ this._operationTimeoutCb = null;
9116
+ this._timeout = null;
9117
+ this._operationStart = null;
9118
+ this._timer = null;
9121
9119
 
9122
- // Regex to find the device root, including trailing slash. E.g. 'c:\\'.
9123
- if (isWindows$1) {
9124
- var splitRootRe = /^(?:[a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/][^\\\/]+)?[\\\/]*/;
9125
- } else {
9126
- var splitRootRe = /^[\/]*/;
9120
+ if (this._options.forever) {
9121
+ this._cachedTimeouts = this._timeouts.slice(0);
9122
+ }
9127
9123
  }
9124
+ var retry_operation = RetryOperation;
9128
9125
 
9129
- old$1.realpathSync = function realpathSync(p, cache) {
9130
- // make p is absolute
9131
- p = pathModule.resolve(p);
9126
+ RetryOperation.prototype.reset = function() {
9127
+ this._attempts = 1;
9128
+ this._timeouts = this._originalTimeouts.slice(0);
9129
+ };
9132
9130
 
9133
- if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
9134
- return cache[p];
9131
+ RetryOperation.prototype.stop = function() {
9132
+ if (this._timeout) {
9133
+ clearTimeout(this._timeout);
9134
+ }
9135
+ if (this._timer) {
9136
+ clearTimeout(this._timer);
9135
9137
  }
9136
9138
 
9137
- var original = p,
9138
- seenLinks = {},
9139
- knownHard = {};
9139
+ this._timeouts = [];
9140
+ this._cachedTimeouts = null;
9141
+ };
9140
9142
 
9141
- // current character position in p
9142
- var pos;
9143
- // the partial path so far, including a trailing slash if any
9144
- var current;
9145
- // the partial path without a trailing slash (except when pointing at a root)
9146
- var base;
9147
- // the partial path scanned in the previous round, with slash
9148
- var previous;
9143
+ RetryOperation.prototype.retry = function(err) {
9144
+ if (this._timeout) {
9145
+ clearTimeout(this._timeout);
9146
+ }
9149
9147
 
9150
- start();
9148
+ if (!err) {
9149
+ return false;
9150
+ }
9151
+ var currentTime = new Date().getTime();
9152
+ if (err && currentTime - this._operationStart >= this._maxRetryTime) {
9153
+ this._errors.push(err);
9154
+ this._errors.unshift(new Error('RetryOperation timeout occurred'));
9155
+ return false;
9156
+ }
9151
9157
 
9152
- function start() {
9153
- // Skip over roots
9154
- var m = splitRootRe.exec(p);
9155
- pos = m[0].length;
9156
- current = m[0];
9157
- base = m[0];
9158
- previous = '';
9158
+ this._errors.push(err);
9159
9159
 
9160
- // On windows, check that the root exists. On unix there is no need.
9161
- if (isWindows$1 && !knownHard[base]) {
9162
- fs$k.lstatSync(base);
9163
- knownHard[base] = true;
9160
+ var timeout = this._timeouts.shift();
9161
+ if (timeout === undefined) {
9162
+ if (this._cachedTimeouts) {
9163
+ // retry forever, only keep last error
9164
+ this._errors.splice(0, this._errors.length - 1);
9165
+ timeout = this._cachedTimeouts.slice(-1);
9166
+ } else {
9167
+ return false;
9164
9168
  }
9165
9169
  }
9166
9170
 
9167
- // walk down the path, swapping out linked pathparts for their real
9168
- // values
9169
- // NB: p.length changes.
9170
- while (pos < p.length) {
9171
- // find the next part
9172
- nextPartRe.lastIndex = pos;
9173
- var result = nextPartRe.exec(p);
9174
- previous = current;
9175
- current += result[0];
9176
- base = previous + result[1];
9177
- pos = nextPartRe.lastIndex;
9178
-
9179
- // continue if not a symlink
9180
- if (knownHard[base] || (cache && cache[base] === base)) {
9181
- continue;
9182
- }
9171
+ var self = this;
9172
+ this._timer = setTimeout(function() {
9173
+ self._attempts++;
9183
9174
 
9184
- var resolvedLink;
9185
- if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
9186
- // some known symbolic link. no need to stat again.
9187
- resolvedLink = cache[base];
9188
- } else {
9189
- var stat = fs$k.lstatSync(base);
9190
- if (!stat.isSymbolicLink()) {
9191
- knownHard[base] = true;
9192
- if (cache) cache[base] = base;
9193
- continue;
9194
- }
9175
+ if (self._operationTimeoutCb) {
9176
+ self._timeout = setTimeout(function() {
9177
+ self._operationTimeoutCb(self._attempts);
9178
+ }, self._operationTimeout);
9195
9179
 
9196
- // read the link if it wasn't read before
9197
- // dev/ino always return 0 on windows, so skip the check.
9198
- var linkTarget = null;
9199
- if (!isWindows$1) {
9200
- var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
9201
- if (seenLinks.hasOwnProperty(id)) {
9202
- linkTarget = seenLinks[id];
9203
- }
9204
- }
9205
- if (linkTarget === null) {
9206
- fs$k.statSync(base);
9207
- linkTarget = fs$k.readlinkSync(base);
9180
+ if (self._options.unref) {
9181
+ self._timeout.unref();
9208
9182
  }
9209
- resolvedLink = pathModule.resolve(previous, linkTarget);
9210
- // track this, if given a cache.
9211
- if (cache) cache[base] = resolvedLink;
9212
- if (!isWindows$1) seenLinks[id] = linkTarget;
9213
9183
  }
9214
9184
 
9215
- // resolve the link, then start over
9216
- p = pathModule.resolve(resolvedLink, p.slice(pos));
9217
- start();
9218
- }
9185
+ self._fn(self._attempts);
9186
+ }, timeout);
9219
9187
 
9220
- if (cache) cache[original] = p;
9188
+ if (this._options.unref) {
9189
+ this._timer.unref();
9190
+ }
9221
9191
 
9222
- return p;
9192
+ return true;
9223
9193
  };
9224
9194
 
9195
+ RetryOperation.prototype.attempt = function(fn, timeoutOps) {
9196
+ this._fn = fn;
9225
9197
 
9226
- old$1.realpath = function realpath(p, cache, cb) {
9227
- if (typeof cb !== 'function') {
9228
- cb = maybeCallback(cache);
9229
- cache = null;
9198
+ if (timeoutOps) {
9199
+ if (timeoutOps.timeout) {
9200
+ this._operationTimeout = timeoutOps.timeout;
9201
+ }
9202
+ if (timeoutOps.cb) {
9203
+ this._operationTimeoutCb = timeoutOps.cb;
9204
+ }
9230
9205
  }
9231
9206
 
9232
- // make p is absolute
9233
- p = pathModule.resolve(p);
9234
-
9235
- if (cache && Object.prototype.hasOwnProperty.call(cache, p)) {
9236
- return process.nextTick(cb.bind(null, null, cache[p]));
9207
+ var self = this;
9208
+ if (this._operationTimeoutCb) {
9209
+ this._timeout = setTimeout(function() {
9210
+ self._operationTimeoutCb();
9211
+ }, self._operationTimeout);
9237
9212
  }
9238
9213
 
9239
- var original = p,
9240
- seenLinks = {},
9241
- knownHard = {};
9242
-
9243
- // current character position in p
9244
- var pos;
9245
- // the partial path so far, including a trailing slash if any
9246
- var current;
9247
- // the partial path without a trailing slash (except when pointing at a root)
9248
- var base;
9249
- // the partial path scanned in the previous round, with slash
9250
- var previous;
9214
+ this._operationStart = new Date().getTime();
9251
9215
 
9252
- start();
9216
+ this._fn(this._attempts);
9217
+ };
9253
9218
 
9254
- function start() {
9255
- // Skip over roots
9256
- var m = splitRootRe.exec(p);
9257
- pos = m[0].length;
9258
- current = m[0];
9259
- base = m[0];
9260
- previous = '';
9219
+ RetryOperation.prototype.try = function(fn) {
9220
+ console.log('Using RetryOperation.try() is deprecated');
9221
+ this.attempt(fn);
9222
+ };
9261
9223
 
9262
- // On windows, check that the root exists. On unix there is no need.
9263
- if (isWindows$1 && !knownHard[base]) {
9264
- fs$k.lstat(base, function(err) {
9265
- if (err) return cb(err);
9266
- knownHard[base] = true;
9267
- LOOP();
9268
- });
9269
- } else {
9270
- process.nextTick(LOOP);
9271
- }
9272
- }
9224
+ RetryOperation.prototype.start = function(fn) {
9225
+ console.log('Using RetryOperation.start() is deprecated');
9226
+ this.attempt(fn);
9227
+ };
9273
9228
 
9274
- // walk down the path, swapping out linked pathparts for their real
9275
- // values
9276
- function LOOP() {
9277
- // stop if scanned past end of path
9278
- if (pos >= p.length) {
9279
- if (cache) cache[original] = p;
9280
- return cb(null, p);
9281
- }
9229
+ RetryOperation.prototype.start = RetryOperation.prototype.try;
9282
9230
 
9283
- // find the next part
9284
- nextPartRe.lastIndex = pos;
9285
- var result = nextPartRe.exec(p);
9286
- previous = current;
9287
- current += result[0];
9288
- base = previous + result[1];
9289
- pos = nextPartRe.lastIndex;
9290
-
9291
- // continue if not a symlink
9292
- if (knownHard[base] || (cache && cache[base] === base)) {
9293
- return process.nextTick(LOOP);
9294
- }
9295
-
9296
- if (cache && Object.prototype.hasOwnProperty.call(cache, base)) {
9297
- // known symbolic link. no need to stat again.
9298
- return gotResolvedLink(cache[base]);
9299
- }
9300
-
9301
- return fs$k.lstat(base, gotStat);
9302
- }
9303
-
9304
- function gotStat(err, stat) {
9305
- if (err) return cb(err);
9306
-
9307
- // if not a symlink, skip to the next path part
9308
- if (!stat.isSymbolicLink()) {
9309
- knownHard[base] = true;
9310
- if (cache) cache[base] = base;
9311
- return process.nextTick(LOOP);
9312
- }
9313
-
9314
- // stat & read the link if not read before
9315
- // call gotTarget as soon as the link target is known
9316
- // dev/ino always return 0 on windows, so skip the check.
9317
- if (!isWindows$1) {
9318
- var id = stat.dev.toString(32) + ':' + stat.ino.toString(32);
9319
- if (seenLinks.hasOwnProperty(id)) {
9320
- return gotTarget(null, seenLinks[id], base);
9321
- }
9322
- }
9323
- fs$k.stat(base, function(err) {
9324
- if (err) return cb(err);
9325
-
9326
- fs$k.readlink(base, function(err, target) {
9327
- if (!isWindows$1) seenLinks[id] = target;
9328
- gotTarget(err, target);
9329
- });
9330
- });
9331
- }
9332
-
9333
- function gotTarget(err, target, base) {
9334
- if (err) return cb(err);
9335
-
9336
- var resolvedLink = pathModule.resolve(previous, target);
9337
- if (cache) cache[base] = resolvedLink;
9338
- gotResolvedLink(resolvedLink);
9339
- }
9340
-
9341
- function gotResolvedLink(resolvedLink) {
9342
- // resolve the link, then start over
9343
- p = pathModule.resolve(resolvedLink, p.slice(pos));
9344
- start();
9345
- }
9346
- };
9347
-
9348
- var fs_realpath = realpath;
9349
- realpath.realpath = realpath;
9350
- realpath.sync = realpathSync;
9351
- realpath.realpathSync = realpathSync;
9352
- realpath.monkeypatch = monkeypatch;
9353
- realpath.unmonkeypatch = unmonkeypatch;
9354
-
9355
- var fs$j = fs$l;
9356
- var origRealpath = fs$j.realpath;
9357
- var origRealpathSync = fs$j.realpathSync;
9358
-
9359
- var version$2 = process.version;
9360
- var ok = /^v[0-5]\./.test(version$2);
9361
- var old = old$1;
9362
-
9363
- function newError (er) {
9364
- return er && er.syscall === 'realpath' && (
9365
- er.code === 'ELOOP' ||
9366
- er.code === 'ENOMEM' ||
9367
- er.code === 'ENAMETOOLONG'
9368
- )
9369
- }
9370
-
9371
- function realpath (p, cache, cb) {
9372
- if (ok) {
9373
- return origRealpath(p, cache, cb)
9374
- }
9375
-
9376
- if (typeof cache === 'function') {
9377
- cb = cache;
9378
- cache = null;
9379
- }
9380
- origRealpath(p, cache, function (er, result) {
9381
- if (newError(er)) {
9382
- old.realpath(p, cache, cb);
9383
- } else {
9384
- cb(er, result);
9385
- }
9386
- });
9387
- }
9388
-
9389
- function realpathSync (p, cache) {
9390
- if (ok) {
9391
- return origRealpathSync(p, cache)
9392
- }
9393
-
9394
- try {
9395
- return origRealpathSync(p, cache)
9396
- } catch (er) {
9397
- if (newError(er)) {
9398
- return old.realpathSync(p, cache)
9399
- } else {
9400
- throw er
9401
- }
9402
- }
9403
- }
9404
-
9405
- function monkeypatch () {
9406
- fs$j.realpath = realpath;
9407
- fs$j.realpathSync = realpathSync;
9408
- }
9409
-
9410
- function unmonkeypatch () {
9411
- fs$j.realpath = origRealpath;
9412
- fs$j.realpathSync = origRealpathSync;
9413
- }
9414
-
9415
- var concatMap$1 = function (xs, fn) {
9416
- var res = [];
9417
- for (var i = 0; i < xs.length; i++) {
9418
- var x = fn(xs[i], i);
9419
- if (isArray$1(x)) res.push.apply(res, x);
9420
- else res.push(x);
9421
- }
9422
- return res;
9423
- };
9424
-
9425
- var isArray$1 = Array.isArray || function (xs) {
9426
- return Object.prototype.toString.call(xs) === '[object Array]';
9427
- };
9428
-
9429
- var balancedMatch = balanced$1;
9430
- function balanced$1(a, b, str) {
9431
- if (a instanceof RegExp) a = maybeMatch(a, str);
9432
- if (b instanceof RegExp) b = maybeMatch(b, str);
9433
-
9434
- var r = range(a, b, str);
9435
-
9436
- return r && {
9437
- start: r[0],
9438
- end: r[1],
9439
- pre: str.slice(0, r[0]),
9440
- body: str.slice(r[0] + a.length, r[1]),
9441
- post: str.slice(r[1] + b.length)
9442
- };
9443
- }
9444
-
9445
- function maybeMatch(reg, str) {
9446
- var m = str.match(reg);
9447
- return m ? m[0] : null;
9448
- }
9449
-
9450
- balanced$1.range = range;
9451
- function range(a, b, str) {
9452
- var begs, beg, left, right, result;
9453
- var ai = str.indexOf(a);
9454
- var bi = str.indexOf(b, ai + 1);
9455
- var i = ai;
9456
-
9457
- if (ai >= 0 && bi > 0) {
9458
- begs = [];
9459
- left = str.length;
9460
-
9461
- while (i >= 0 && !result) {
9462
- if (i == ai) {
9463
- begs.push(i);
9464
- ai = str.indexOf(a, i + 1);
9465
- } else if (begs.length == 1) {
9466
- result = [ begs.pop(), bi ];
9467
- } else {
9468
- beg = begs.pop();
9469
- if (beg < left) {
9470
- left = beg;
9471
- right = bi;
9472
- }
9473
-
9474
- bi = str.indexOf(b, i + 1);
9475
- }
9476
-
9477
- i = ai < bi && ai >= 0 ? ai : bi;
9478
- }
9479
-
9480
- if (begs.length) {
9481
- result = [ left, right ];
9482
- }
9483
- }
9484
-
9485
- return result;
9486
- }
9487
-
9488
- var concatMap = concatMap$1;
9489
- var balanced = balancedMatch;
9490
-
9491
- var braceExpansion = expandTop;
9492
-
9493
- var escSlash = '\0SLASH'+Math.random()+'\0';
9494
- var escOpen = '\0OPEN'+Math.random()+'\0';
9495
- var escClose = '\0CLOSE'+Math.random()+'\0';
9496
- var escComma = '\0COMMA'+Math.random()+'\0';
9497
- var escPeriod = '\0PERIOD'+Math.random()+'\0';
9498
-
9499
- function numeric(str) {
9500
- return parseInt(str, 10) == str
9501
- ? parseInt(str, 10)
9502
- : str.charCodeAt(0);
9503
- }
9504
-
9505
- function escapeBraces(str) {
9506
- return str.split('\\\\').join(escSlash)
9507
- .split('\\{').join(escOpen)
9508
- .split('\\}').join(escClose)
9509
- .split('\\,').join(escComma)
9510
- .split('\\.').join(escPeriod);
9511
- }
9512
-
9513
- function unescapeBraces(str) {
9514
- return str.split(escSlash).join('\\')
9515
- .split(escOpen).join('{')
9516
- .split(escClose).join('}')
9517
- .split(escComma).join(',')
9518
- .split(escPeriod).join('.');
9519
- }
9520
-
9521
-
9522
- // Basically just str.split(","), but handling cases
9523
- // where we have nested braced sections, which should be
9524
- // treated as individual members, like {a,{b,c},d}
9525
- function parseCommaParts(str) {
9526
- if (!str)
9527
- return [''];
9528
-
9529
- var parts = [];
9530
- var m = balanced('{', '}', str);
9531
-
9532
- if (!m)
9533
- return str.split(',');
9534
-
9535
- var pre = m.pre;
9536
- var body = m.body;
9537
- var post = m.post;
9538
- var p = pre.split(',');
9539
-
9540
- p[p.length-1] += '{' + body + '}';
9541
- var postParts = parseCommaParts(post);
9542
- if (post.length) {
9543
- p[p.length-1] += postParts.shift();
9544
- p.push.apply(p, postParts);
9545
- }
9546
-
9547
- parts.push.apply(parts, p);
9548
-
9549
- return parts;
9550
- }
9551
-
9552
- function expandTop(str) {
9553
- if (!str)
9554
- return [];
9555
-
9556
- // I don't know why Bash 4.3 does this, but it does.
9557
- // Anything starting with {} will have the first two bytes preserved
9558
- // but *only* at the top level, so {},a}b will not expand to anything,
9559
- // but a{},b}c will be expanded to [a}c,abc].
9560
- // One could argue that this is a bug in Bash, but since the goal of
9561
- // this module is to match Bash's rules, we escape a leading {}
9562
- if (str.substr(0, 2) === '{}') {
9563
- str = '\\{\\}' + str.substr(2);
9564
- }
9565
-
9566
- return expand$1(escapeBraces(str), true).map(unescapeBraces);
9567
- }
9568
-
9569
- function embrace(str) {
9570
- return '{' + str + '}';
9571
- }
9572
- function isPadded(el) {
9573
- return /^-?0\d/.test(el);
9574
- }
9575
-
9576
- function lte(i, y) {
9577
- return i <= y;
9578
- }
9579
- function gte(i, y) {
9580
- return i >= y;
9581
- }
9582
-
9583
- function expand$1(str, isTop) {
9584
- var expansions = [];
9585
-
9586
- var m = balanced('{', '}', str);
9587
- if (!m || /\$$/.test(m.pre)) return [str];
9588
-
9589
- var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
9590
- var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
9591
- var isSequence = isNumericSequence || isAlphaSequence;
9592
- var isOptions = m.body.indexOf(',') >= 0;
9593
- if (!isSequence && !isOptions) {
9594
- // {a},b}
9595
- if (m.post.match(/,.*\}/)) {
9596
- str = m.pre + '{' + m.body + escClose + m.post;
9597
- return expand$1(str);
9598
- }
9599
- return [str];
9600
- }
9601
-
9602
- var n;
9603
- if (isSequence) {
9604
- n = m.body.split(/\.\./);
9605
- } else {
9606
- n = parseCommaParts(m.body);
9607
- if (n.length === 1) {
9608
- // x{{a,b}}y ==> x{a}y x{b}y
9609
- n = expand$1(n[0], false).map(embrace);
9610
- if (n.length === 1) {
9611
- var post = m.post.length
9612
- ? expand$1(m.post, false)
9613
- : [''];
9614
- return post.map(function(p) {
9615
- return m.pre + n[0] + p;
9616
- });
9617
- }
9618
- }
9619
- }
9620
-
9621
- // at this point, n is the parts, and we know it's not a comma set
9622
- // with a single entry.
9623
-
9624
- // no need to expand pre, since it is guaranteed to be free of brace-sets
9625
- var pre = m.pre;
9626
- var post = m.post.length
9627
- ? expand$1(m.post, false)
9628
- : [''];
9629
-
9630
- var N;
9631
-
9632
- if (isSequence) {
9633
- var x = numeric(n[0]);
9634
- var y = numeric(n[1]);
9635
- var width = Math.max(n[0].length, n[1].length);
9636
- var incr = n.length == 3
9637
- ? Math.abs(numeric(n[2]))
9638
- : 1;
9639
- var test = lte;
9640
- var reverse = y < x;
9641
- if (reverse) {
9642
- incr *= -1;
9643
- test = gte;
9644
- }
9645
- var pad = n.some(isPadded);
9646
-
9647
- N = [];
9648
-
9649
- for (var i = x; test(i, y); i += incr) {
9650
- var c;
9651
- if (isAlphaSequence) {
9652
- c = String.fromCharCode(i);
9653
- if (c === '\\')
9654
- c = '';
9655
- } else {
9656
- c = String(i);
9657
- if (pad) {
9658
- var need = width - c.length;
9659
- if (need > 0) {
9660
- var z = new Array(need + 1).join('0');
9661
- if (i < 0)
9662
- c = '-' + z + c.slice(1);
9663
- else
9664
- c = z + c;
9665
- }
9666
- }
9667
- }
9668
- N.push(c);
9669
- }
9670
- } else {
9671
- N = concatMap(n, function(el) { return expand$1(el, false) });
9672
- }
9673
-
9674
- for (var j = 0; j < N.length; j++) {
9675
- for (var k = 0; k < post.length; k++) {
9676
- var expansion = pre + N[j] + post[k];
9677
- if (!isTop || isSequence || expansion)
9678
- expansions.push(expansion);
9679
- }
9680
- }
9681
-
9682
- return expansions;
9683
- }
9684
-
9685
- var minimatch_1 = minimatch$1;
9686
- minimatch$1.Minimatch = Minimatch$1;
9687
-
9688
- var path$i = { sep: '/' };
9689
- try {
9690
- path$i = require('path');
9691
- } catch (er) {}
9692
-
9693
- var GLOBSTAR = minimatch$1.GLOBSTAR = Minimatch$1.GLOBSTAR = {};
9694
- var expand = braceExpansion;
9695
-
9696
- var plTypes = {
9697
- '!': { open: '(?:(?!(?:', close: '))[^/]*?)'},
9698
- '?': { open: '(?:', close: ')?' },
9699
- '+': { open: '(?:', close: ')+' },
9700
- '*': { open: '(?:', close: ')*' },
9701
- '@': { open: '(?:', close: ')' }
9702
- };
9703
-
9704
- // any single thing other than /
9705
- // don't need to escape / when using new RegExp()
9706
- var qmark = '[^/]';
9707
-
9708
- // * => any number of characters
9709
- var star = qmark + '*?';
9710
-
9711
- // ** when dots are allowed. Anything goes, except .. and .
9712
- // not (^ or / followed by one or two dots followed by $ or /),
9713
- // followed by anything, any number of times.
9714
- var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?';
9715
-
9716
- // not a ^ or / followed by a dot,
9717
- // followed by anything, any number of times.
9718
- var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?';
9719
-
9720
- // characters that need to be escaped in RegExp.
9721
- var reSpecials = charSet('().*{}+?[]^$\\!');
9722
-
9723
- // "abc" -> { a:true, b:true, c:true }
9724
- function charSet (s) {
9725
- return s.split('').reduce(function (set, c) {
9726
- set[c] = true;
9727
- return set
9728
- }, {})
9729
- }
9730
-
9731
- // normalizes slashes.
9732
- var slashSplit = /\/+/;
9733
-
9734
- minimatch$1.filter = filter;
9735
- function filter (pattern, options) {
9736
- options = options || {};
9737
- return function (p, i, list) {
9738
- return minimatch$1(p, pattern, options)
9739
- }
9740
- }
9741
-
9742
- function ext (a, b) {
9743
- a = a || {};
9744
- b = b || {};
9745
- var t = {};
9746
- Object.keys(b).forEach(function (k) {
9747
- t[k] = b[k];
9748
- });
9749
- Object.keys(a).forEach(function (k) {
9750
- t[k] = a[k];
9751
- });
9752
- return t
9753
- }
9754
-
9755
- minimatch$1.defaults = function (def) {
9756
- if (!def || !Object.keys(def).length) return minimatch$1
9757
-
9758
- var orig = minimatch$1;
9759
-
9760
- var m = function minimatch (p, pattern, options) {
9761
- return orig.minimatch(p, pattern, ext(def, options))
9762
- };
9763
-
9764
- m.Minimatch = function Minimatch (pattern, options) {
9765
- return new orig.Minimatch(pattern, ext(def, options))
9766
- };
9767
-
9768
- return m
9769
- };
9770
-
9771
- Minimatch$1.defaults = function (def) {
9772
- if (!def || !Object.keys(def).length) return Minimatch$1
9773
- return minimatch$1.defaults(def).Minimatch
9774
- };
9775
-
9776
- function minimatch$1 (p, pattern, options) {
9777
- if (typeof pattern !== 'string') {
9778
- throw new TypeError('glob pattern string required')
9779
- }
9780
-
9781
- if (!options) options = {};
9782
-
9783
- // shortcut: comments match nothing.
9784
- if (!options.nocomment && pattern.charAt(0) === '#') {
9785
- return false
9786
- }
9787
-
9788
- // "" only matches ""
9789
- if (pattern.trim() === '') return p === ''
9790
-
9791
- return new Minimatch$1(pattern, options).match(p)
9792
- }
9793
-
9794
- function Minimatch$1 (pattern, options) {
9795
- if (!(this instanceof Minimatch$1)) {
9796
- return new Minimatch$1(pattern, options)
9797
- }
9798
-
9799
- if (typeof pattern !== 'string') {
9800
- throw new TypeError('glob pattern string required')
9801
- }
9802
-
9803
- if (!options) options = {};
9804
- pattern = pattern.trim();
9805
-
9806
- // windows support: need to use /, not \
9807
- if (path$i.sep !== '/') {
9808
- pattern = pattern.split(path$i.sep).join('/');
9809
- }
9810
-
9811
- this.options = options;
9812
- this.set = [];
9813
- this.pattern = pattern;
9814
- this.regexp = null;
9815
- this.negate = false;
9816
- this.comment = false;
9817
- this.empty = false;
9818
-
9819
- // make the set of regexps etc.
9820
- this.make();
9821
- }
9822
-
9823
- Minimatch$1.prototype.debug = function () {};
9824
-
9825
- Minimatch$1.prototype.make = make;
9826
- function make () {
9827
- // don't do it more than once.
9828
- if (this._made) return
9829
-
9830
- var pattern = this.pattern;
9831
- var options = this.options;
9832
-
9833
- // empty patterns and comments match nothing.
9834
- if (!options.nocomment && pattern.charAt(0) === '#') {
9835
- this.comment = true;
9836
- return
9837
- }
9838
- if (!pattern) {
9839
- this.empty = true;
9840
- return
9841
- }
9842
-
9843
- // step 1: figure out negation, etc.
9844
- this.parseNegate();
9845
-
9846
- // step 2: expand braces
9847
- var set = this.globSet = this.braceExpand();
9848
-
9849
- if (options.debug) this.debug = console.error;
9850
-
9851
- this.debug(this.pattern, set);
9852
-
9853
- // step 3: now we have a set, so turn each one into a series of path-portion
9854
- // matching patterns.
9855
- // These will be regexps, except in the case of "**", which is
9856
- // set to the GLOBSTAR object for globstar behavior,
9857
- // and will not contain any / characters
9858
- set = this.globParts = set.map(function (s) {
9859
- return s.split(slashSplit)
9860
- });
9861
-
9862
- this.debug(this.pattern, set);
9863
-
9864
- // glob --> regexps
9865
- set = set.map(function (s, si, set) {
9866
- return s.map(this.parse, this)
9867
- }, this);
9868
-
9869
- this.debug(this.pattern, set);
9870
-
9871
- // filter out everything that didn't compile properly.
9872
- set = set.filter(function (s) {
9873
- return s.indexOf(false) === -1
9874
- });
9875
-
9876
- this.debug(this.pattern, set);
9877
-
9878
- this.set = set;
9879
- }
9880
-
9881
- Minimatch$1.prototype.parseNegate = parseNegate;
9882
- function parseNegate () {
9883
- var pattern = this.pattern;
9884
- var negate = false;
9885
- var options = this.options;
9886
- var negateOffset = 0;
9887
-
9888
- if (options.nonegate) return
9889
-
9890
- for (var i = 0, l = pattern.length
9891
- ; i < l && pattern.charAt(i) === '!'
9892
- ; i++) {
9893
- negate = !negate;
9894
- negateOffset++;
9895
- }
9896
-
9897
- if (negateOffset) this.pattern = pattern.substr(negateOffset);
9898
- this.negate = negate;
9899
- }
9900
-
9901
- // Brace expansion:
9902
- // a{b,c}d -> abd acd
9903
- // a{b,}c -> abc ac
9904
- // a{0..3}d -> a0d a1d a2d a3d
9905
- // a{b,c{d,e}f}g -> abg acdfg acefg
9906
- // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
9907
- //
9908
- // Invalid sets are not expanded.
9909
- // a{2..}b -> a{2..}b
9910
- // a{b}c -> a{b}c
9911
- minimatch$1.braceExpand = function (pattern, options) {
9912
- return braceExpand(pattern, options)
9913
- };
9914
-
9915
- Minimatch$1.prototype.braceExpand = braceExpand;
9916
-
9917
- function braceExpand (pattern, options) {
9918
- if (!options) {
9919
- if (this instanceof Minimatch$1) {
9920
- options = this.options;
9921
- } else {
9922
- options = {};
9923
- }
9924
- }
9925
-
9926
- pattern = typeof pattern === 'undefined'
9927
- ? this.pattern : pattern;
9928
-
9929
- if (typeof pattern === 'undefined') {
9930
- throw new TypeError('undefined pattern')
9931
- }
9932
-
9933
- if (options.nobrace ||
9934
- !pattern.match(/\{.*\}/)) {
9935
- // shortcut. no need to expand.
9936
- return [pattern]
9937
- }
9938
-
9939
- return expand(pattern)
9940
- }
9941
-
9942
- // parse a component of the expanded set.
9943
- // At this point, no pattern may contain "/" in it
9944
- // so we're going to return a 2d array, where each entry is the full
9945
- // pattern, split on '/', and then turned into a regular expression.
9946
- // A regexp is made at the end which joins each array with an
9947
- // escaped /, and another full one which joins each regexp with |.
9948
- //
9949
- // Following the lead of Bash 4.1, note that "**" only has special meaning
9950
- // when it is the *only* thing in a path portion. Otherwise, any series
9951
- // of * is equivalent to a single *. Globstar behavior is enabled by
9952
- // default, and can be disabled by setting options.noglobstar.
9953
- Minimatch$1.prototype.parse = parse;
9954
- var SUBPARSE = {};
9955
- function parse (pattern, isSub) {
9956
- if (pattern.length > 1024 * 64) {
9957
- throw new TypeError('pattern is too long')
9958
- }
9959
-
9960
- var options = this.options;
9961
-
9962
- // shortcuts
9963
- if (!options.noglobstar && pattern === '**') return GLOBSTAR
9964
- if (pattern === '') return ''
9965
-
9966
- var re = '';
9967
- var hasMagic = !!options.nocase;
9968
- var escaping = false;
9969
- // ? => one single character
9970
- var patternListStack = [];
9971
- var negativeLists = [];
9972
- var stateChar;
9973
- var inClass = false;
9974
- var reClassStart = -1;
9975
- var classStart = -1;
9976
- // . and .. never match anything that doesn't start with .,
9977
- // even when options.dot is set.
9978
- var patternStart = pattern.charAt(0) === '.' ? '' // anything
9979
- // not (start or / followed by . or .. followed by / or end)
9980
- : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))'
9981
- : '(?!\\.)';
9982
- var self = this;
9983
-
9984
- function clearStateChar () {
9985
- if (stateChar) {
9986
- // we had some state-tracking character
9987
- // that wasn't consumed by this pass.
9988
- switch (stateChar) {
9989
- case '*':
9990
- re += star;
9991
- hasMagic = true;
9992
- break
9993
- case '?':
9994
- re += qmark;
9995
- hasMagic = true;
9996
- break
9997
- default:
9998
- re += '\\' + stateChar;
9999
- break
10000
- }
10001
- self.debug('clearStateChar %j %j', stateChar, re);
10002
- stateChar = false;
10003
- }
10004
- }
10005
-
10006
- for (var i = 0, len = pattern.length, c
10007
- ; (i < len) && (c = pattern.charAt(i))
10008
- ; i++) {
10009
- this.debug('%s\t%s %s %j', pattern, i, re, c);
10010
-
10011
- // skip over any that are escaped.
10012
- if (escaping && reSpecials[c]) {
10013
- re += '\\' + c;
10014
- escaping = false;
10015
- continue
10016
- }
10017
-
10018
- switch (c) {
10019
- case '/':
10020
- // completely not allowed, even escaped.
10021
- // Should already be path-split by now.
10022
- return false
10023
-
10024
- case '\\':
10025
- clearStateChar();
10026
- escaping = true;
10027
- continue
10028
-
10029
- // the various stateChar values
10030
- // for the "extglob" stuff.
10031
- case '?':
10032
- case '*':
10033
- case '+':
10034
- case '@':
10035
- case '!':
10036
- this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c);
10037
-
10038
- // all of those are literals inside a class, except that
10039
- // the glob [!a] means [^a] in regexp
10040
- if (inClass) {
10041
- this.debug(' in class');
10042
- if (c === '!' && i === classStart + 1) c = '^';
10043
- re += c;
10044
- continue
10045
- }
10046
-
10047
- // if we already have a stateChar, then it means
10048
- // that there was something like ** or +? in there.
10049
- // Handle the stateChar, then proceed with this one.
10050
- self.debug('call clearStateChar %j', stateChar);
10051
- clearStateChar();
10052
- stateChar = c;
10053
- // if extglob is disabled, then +(asdf|foo) isn't a thing.
10054
- // just clear the statechar *now*, rather than even diving into
10055
- // the patternList stuff.
10056
- if (options.noext) clearStateChar();
10057
- continue
10058
-
10059
- case '(':
10060
- if (inClass) {
10061
- re += '(';
10062
- continue
10063
- }
10064
-
10065
- if (!stateChar) {
10066
- re += '\\(';
10067
- continue
10068
- }
10069
-
10070
- patternListStack.push({
10071
- type: stateChar,
10072
- start: i - 1,
10073
- reStart: re.length,
10074
- open: plTypes[stateChar].open,
10075
- close: plTypes[stateChar].close
10076
- });
10077
- // negation is (?:(?!js)[^/]*)
10078
- re += stateChar === '!' ? '(?:(?!(?:' : '(?:';
10079
- this.debug('plType %j %j', stateChar, re);
10080
- stateChar = false;
10081
- continue
10082
-
10083
- case ')':
10084
- if (inClass || !patternListStack.length) {
10085
- re += '\\)';
10086
- continue
10087
- }
10088
-
10089
- clearStateChar();
10090
- hasMagic = true;
10091
- var pl = patternListStack.pop();
10092
- // negation is (?:(?!js)[^/]*)
10093
- // The others are (?:<pattern>)<type>
10094
- re += pl.close;
10095
- if (pl.type === '!') {
10096
- negativeLists.push(pl);
10097
- }
10098
- pl.reEnd = re.length;
10099
- continue
10100
-
10101
- case '|':
10102
- if (inClass || !patternListStack.length || escaping) {
10103
- re += '\\|';
10104
- escaping = false;
10105
- continue
10106
- }
10107
-
10108
- clearStateChar();
10109
- re += '|';
10110
- continue
10111
-
10112
- // these are mostly the same in regexp and glob
10113
- case '[':
10114
- // swallow any state-tracking char before the [
10115
- clearStateChar();
10116
-
10117
- if (inClass) {
10118
- re += '\\' + c;
10119
- continue
10120
- }
10121
-
10122
- inClass = true;
10123
- classStart = i;
10124
- reClassStart = re.length;
10125
- re += c;
10126
- continue
10127
-
10128
- case ']':
10129
- // a right bracket shall lose its special
10130
- // meaning and represent itself in
10131
- // a bracket expression if it occurs
10132
- // first in the list. -- POSIX.2 2.8.3.2
10133
- if (i === classStart + 1 || !inClass) {
10134
- re += '\\' + c;
10135
- escaping = false;
10136
- continue
10137
- }
10138
-
10139
- // handle the case where we left a class open.
10140
- // "[z-a]" is valid, equivalent to "\[z-a\]"
10141
- if (inClass) {
10142
- // split where the last [ was, make sure we don't have
10143
- // an invalid re. if so, re-walk the contents of the
10144
- // would-be class to re-translate any characters that
10145
- // were passed through as-is
10146
- // TODO: It would probably be faster to determine this
10147
- // without a try/catch and a new RegExp, but it's tricky
10148
- // to do safely. For now, this is safe and works.
10149
- var cs = pattern.substring(classStart + 1, i);
10150
- try {
10151
- RegExp('[' + cs + ']');
10152
- } catch (er) {
10153
- // not a valid class!
10154
- var sp = this.parse(cs, SUBPARSE);
10155
- re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]';
10156
- hasMagic = hasMagic || sp[1];
10157
- inClass = false;
10158
- continue
10159
- }
10160
- }
10161
-
10162
- // finish up the class.
10163
- hasMagic = true;
10164
- inClass = false;
10165
- re += c;
10166
- continue
10167
-
10168
- default:
10169
- // swallow any state char that wasn't consumed
10170
- clearStateChar();
10171
-
10172
- if (escaping) {
10173
- // no need
10174
- escaping = false;
10175
- } else if (reSpecials[c]
10176
- && !(c === '^' && inClass)) {
10177
- re += '\\';
10178
- }
10179
-
10180
- re += c;
10181
-
10182
- } // switch
10183
- } // for
10184
-
10185
- // handle the case where we left a class open.
10186
- // "[abc" is valid, equivalent to "\[abc"
10187
- if (inClass) {
10188
- // split where the last [ was, and escape it
10189
- // this is a huge pita. We now have to re-walk
10190
- // the contents of the would-be class to re-translate
10191
- // any characters that were passed through as-is
10192
- cs = pattern.substr(classStart + 1);
10193
- sp = this.parse(cs, SUBPARSE);
10194
- re = re.substr(0, reClassStart) + '\\[' + sp[0];
10195
- hasMagic = hasMagic || sp[1];
10196
- }
10197
-
10198
- // handle the case where we had a +( thing at the *end*
10199
- // of the pattern.
10200
- // each pattern list stack adds 3 chars, and we need to go through
10201
- // and escape any | chars that were passed through as-is for the regexp.
10202
- // Go through and escape them, taking care not to double-escape any
10203
- // | chars that were already escaped.
10204
- for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
10205
- var tail = re.slice(pl.reStart + pl.open.length);
10206
- this.debug('setting tail', re, pl);
10207
- // maybe some even number of \, then maybe 1 \, followed by a |
10208
- tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) {
10209
- if (!$2) {
10210
- // the | isn't already escaped, so escape it.
10211
- $2 = '\\';
10212
- }
10213
-
10214
- // need to escape all those slashes *again*, without escaping the
10215
- // one that we need for escaping the | character. As it works out,
10216
- // escaping an even number of slashes can be done by simply repeating
10217
- // it exactly after itself. That's why this trick works.
10218
- //
10219
- // I am sorry that you have to see this.
10220
- return $1 + $1 + $2 + '|'
10221
- });
10222
-
10223
- this.debug('tail=%j\n %s', tail, tail, pl, re);
10224
- var t = pl.type === '*' ? star
10225
- : pl.type === '?' ? qmark
10226
- : '\\' + pl.type;
10227
-
10228
- hasMagic = true;
10229
- re = re.slice(0, pl.reStart) + t + '\\(' + tail;
10230
- }
10231
-
10232
- // handle trailing things that only matter at the very end.
10233
- clearStateChar();
10234
- if (escaping) {
10235
- // trailing \\
10236
- re += '\\\\';
10237
- }
10238
-
10239
- // only need to apply the nodot start if the re starts with
10240
- // something that could conceivably capture a dot
10241
- var addPatternStart = false;
10242
- switch (re.charAt(0)) {
10243
- case '.':
10244
- case '[':
10245
- case '(': addPatternStart = true;
10246
- }
10247
-
10248
- // Hack to work around lack of negative lookbehind in JS
10249
- // A pattern like: *.!(x).!(y|z) needs to ensure that a name
10250
- // like 'a.xyz.yz' doesn't match. So, the first negative
10251
- // lookahead, has to look ALL the way ahead, to the end of
10252
- // the pattern.
10253
- for (var n = negativeLists.length - 1; n > -1; n--) {
10254
- var nl = negativeLists[n];
10255
-
10256
- var nlBefore = re.slice(0, nl.reStart);
10257
- var nlFirst = re.slice(nl.reStart, nl.reEnd - 8);
10258
- var nlLast = re.slice(nl.reEnd - 8, nl.reEnd);
10259
- var nlAfter = re.slice(nl.reEnd);
10260
-
10261
- nlLast += nlAfter;
10262
-
10263
- // Handle nested stuff like *(*.js|!(*.json)), where open parens
10264
- // mean that we should *not* include the ) in the bit that is considered
10265
- // "after" the negated section.
10266
- var openParensBefore = nlBefore.split('(').length - 1;
10267
- var cleanAfter = nlAfter;
10268
- for (i = 0; i < openParensBefore; i++) {
10269
- cleanAfter = cleanAfter.replace(/\)[+*?]?/, '');
10270
- }
10271
- nlAfter = cleanAfter;
10272
-
10273
- var dollar = '';
10274
- if (nlAfter === '' && isSub !== SUBPARSE) {
10275
- dollar = '$';
10276
- }
10277
- var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast;
10278
- re = newRe;
10279
- }
10280
-
10281
- // if the re is not "" at this point, then we need to make sure
10282
- // it doesn't match against an empty path part.
10283
- // Otherwise a/* will match a/, which it should not.
10284
- if (re !== '' && hasMagic) {
10285
- re = '(?=.)' + re;
10286
- }
10287
-
10288
- if (addPatternStart) {
10289
- re = patternStart + re;
10290
- }
10291
-
10292
- // parsing just a piece of a larger pattern.
10293
- if (isSub === SUBPARSE) {
10294
- return [re, hasMagic]
10295
- }
10296
-
10297
- // skip the regexp for non-magical patterns
10298
- // unescape anything in it, though, so that it'll be
10299
- // an exact match against a file etc.
10300
- if (!hasMagic) {
10301
- return globUnescape(pattern)
10302
- }
10303
-
10304
- var flags = options.nocase ? 'i' : '';
10305
- try {
10306
- var regExp = new RegExp('^' + re + '$', flags);
10307
- } catch (er) {
10308
- // If it was an invalid regular expression, then it can't match
10309
- // anything. This trick looks for a character after the end of
10310
- // the string, which is of course impossible, except in multi-line
10311
- // mode, but it's not a /m regex.
10312
- return new RegExp('$.')
10313
- }
10314
-
10315
- regExp._glob = pattern;
10316
- regExp._src = re;
10317
-
10318
- return regExp
10319
- }
10320
-
10321
- minimatch$1.makeRe = function (pattern, options) {
10322
- return new Minimatch$1(pattern, options || {}).makeRe()
10323
- };
10324
-
10325
- Minimatch$1.prototype.makeRe = makeRe;
10326
- function makeRe () {
10327
- if (this.regexp || this.regexp === false) return this.regexp
10328
-
10329
- // at this point, this.set is a 2d array of partial
10330
- // pattern strings, or "**".
10331
- //
10332
- // It's better to use .match(). This function shouldn't
10333
- // be used, really, but it's pretty convenient sometimes,
10334
- // when you just want to work with a regex.
10335
- var set = this.set;
10336
-
10337
- if (!set.length) {
10338
- this.regexp = false;
10339
- return this.regexp
10340
- }
10341
- var options = this.options;
10342
-
10343
- var twoStar = options.noglobstar ? star
10344
- : options.dot ? twoStarDot
10345
- : twoStarNoDot;
10346
- var flags = options.nocase ? 'i' : '';
10347
-
10348
- var re = set.map(function (pattern) {
10349
- return pattern.map(function (p) {
10350
- return (p === GLOBSTAR) ? twoStar
10351
- : (typeof p === 'string') ? regExpEscape(p)
10352
- : p._src
10353
- }).join('\\\/')
10354
- }).join('|');
10355
-
10356
- // must match entire pattern
10357
- // ending in a * or ** will make it less strict.
10358
- re = '^(?:' + re + ')$';
10359
-
10360
- // can match anything, as long as it's not this.
10361
- if (this.negate) re = '^(?!' + re + ').*$';
10362
-
10363
- try {
10364
- this.regexp = new RegExp(re, flags);
10365
- } catch (ex) {
10366
- this.regexp = false;
10367
- }
10368
- return this.regexp
10369
- }
10370
-
10371
- minimatch$1.match = function (list, pattern, options) {
10372
- options = options || {};
10373
- var mm = new Minimatch$1(pattern, options);
10374
- list = list.filter(function (f) {
10375
- return mm.match(f)
10376
- });
10377
- if (mm.options.nonull && !list.length) {
10378
- list.push(pattern);
10379
- }
10380
- return list
10381
- };
10382
-
10383
- Minimatch$1.prototype.match = match;
10384
- function match (f, partial) {
10385
- this.debug('match', f, this.pattern);
10386
- // short-circuit in the case of busted things.
10387
- // comments, etc.
10388
- if (this.comment) return false
10389
- if (this.empty) return f === ''
10390
-
10391
- if (f === '/' && partial) return true
10392
-
10393
- var options = this.options;
10394
-
10395
- // windows: need to use /, not \
10396
- if (path$i.sep !== '/') {
10397
- f = f.split(path$i.sep).join('/');
10398
- }
10399
-
10400
- // treat the test path as a set of pathparts.
10401
- f = f.split(slashSplit);
10402
- this.debug(this.pattern, 'split', f);
10403
-
10404
- // just ONE of the pattern sets in this.set needs to match
10405
- // in order for it to be valid. If negating, then just one
10406
- // match means that we have failed.
10407
- // Either way, return on the first hit.
10408
-
10409
- var set = this.set;
10410
- this.debug(this.pattern, 'set', set);
10411
-
10412
- // Find the basename of the path by looking for the last non-empty segment
10413
- var filename;
10414
- var i;
10415
- for (i = f.length - 1; i >= 0; i--) {
10416
- filename = f[i];
10417
- if (filename) break
10418
- }
10419
-
10420
- for (i = 0; i < set.length; i++) {
10421
- var pattern = set[i];
10422
- var file = f;
10423
- if (options.matchBase && pattern.length === 1) {
10424
- file = [filename];
10425
- }
10426
- var hit = this.matchOne(file, pattern, partial);
10427
- if (hit) {
10428
- if (options.flipNegate) return true
10429
- return !this.negate
10430
- }
10431
- }
10432
-
10433
- // didn't get any hits. this is success if it's a negative
10434
- // pattern, failure otherwise.
10435
- if (options.flipNegate) return false
10436
- return this.negate
10437
- }
10438
-
10439
- // set partial to true to test if, for example,
10440
- // "/a/b" matches the start of "/*/b/*/d"
10441
- // Partial means, if you run out of file before you run
10442
- // out of pattern, then that's fine, as long as all
10443
- // the parts match.
10444
- Minimatch$1.prototype.matchOne = function (file, pattern, partial) {
10445
- var options = this.options;
10446
-
10447
- this.debug('matchOne',
10448
- { 'this': this, file: file, pattern: pattern });
10449
-
10450
- this.debug('matchOne', file.length, pattern.length);
10451
-
10452
- for (var fi = 0,
10453
- pi = 0,
10454
- fl = file.length,
10455
- pl = pattern.length
10456
- ; (fi < fl) && (pi < pl)
10457
- ; fi++, pi++) {
10458
- this.debug('matchOne loop');
10459
- var p = pattern[pi];
10460
- var f = file[fi];
10461
-
10462
- this.debug(pattern, p, f);
10463
-
10464
- // should be impossible.
10465
- // some invalid regexp stuff in the set.
10466
- if (p === false) return false
10467
-
10468
- if (p === GLOBSTAR) {
10469
- this.debug('GLOBSTAR', [pattern, p, f]);
10470
-
10471
- // "**"
10472
- // a/**/b/**/c would match the following:
10473
- // a/b/x/y/z/c
10474
- // a/x/y/z/b/c
10475
- // a/b/x/b/x/c
10476
- // a/b/c
10477
- // To do this, take the rest of the pattern after
10478
- // the **, and see if it would match the file remainder.
10479
- // If so, return success.
10480
- // If not, the ** "swallows" a segment, and try again.
10481
- // This is recursively awful.
10482
- //
10483
- // a/**/b/**/c matching a/b/x/y/z/c
10484
- // - a matches a
10485
- // - doublestar
10486
- // - matchOne(b/x/y/z/c, b/**/c)
10487
- // - b matches b
10488
- // - doublestar
10489
- // - matchOne(x/y/z/c, c) -> no
10490
- // - matchOne(y/z/c, c) -> no
10491
- // - matchOne(z/c, c) -> no
10492
- // - matchOne(c, c) yes, hit
10493
- var fr = fi;
10494
- var pr = pi + 1;
10495
- if (pr === pl) {
10496
- this.debug('** at the end');
10497
- // a ** at the end will just swallow the rest.
10498
- // We have found a match.
10499
- // however, it will not swallow /.x, unless
10500
- // options.dot is set.
10501
- // . and .. are *never* matched by **, for explosively
10502
- // exponential reasons.
10503
- for (; fi < fl; fi++) {
10504
- if (file[fi] === '.' || file[fi] === '..' ||
10505
- (!options.dot && file[fi].charAt(0) === '.')) return false
10506
- }
10507
- return true
10508
- }
10509
-
10510
- // ok, let's see if we can swallow whatever we can.
10511
- while (fr < fl) {
10512
- var swallowee = file[fr];
10513
-
10514
- this.debug('\nglobstar while', file, fr, pattern, pr, swallowee);
10515
-
10516
- // XXX remove this slice. Just pass the start index.
10517
- if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
10518
- this.debug('globstar found match!', fr, fl, swallowee);
10519
- // found a match.
10520
- return true
10521
- } else {
10522
- // can't swallow "." or ".." ever.
10523
- // can only swallow ".foo" when explicitly asked.
10524
- if (swallowee === '.' || swallowee === '..' ||
10525
- (!options.dot && swallowee.charAt(0) === '.')) {
10526
- this.debug('dot detected!', file, fr, pattern, pr);
10527
- break
10528
- }
10529
-
10530
- // ** swallows a segment, and continue.
10531
- this.debug('globstar swallow a segment, and continue');
10532
- fr++;
10533
- }
10534
- }
10535
-
10536
- // no match was found.
10537
- // However, in partial mode, we can't say this is necessarily over.
10538
- // If there's more *pattern* left, then
10539
- if (partial) {
10540
- // ran out of file
10541
- this.debug('\n>>> no match, partial?', file, fr, pattern, pr);
10542
- if (fr === fl) return true
10543
- }
10544
- return false
10545
- }
10546
-
10547
- // something other than **
10548
- // non-magic patterns just have to match exactly
10549
- // patterns with magic have been turned into regexps.
10550
- var hit;
10551
- if (typeof p === 'string') {
10552
- if (options.nocase) {
10553
- hit = f.toLowerCase() === p.toLowerCase();
10554
- } else {
10555
- hit = f === p;
10556
- }
10557
- this.debug('string match', p, f, hit);
10558
- } else {
10559
- hit = f.match(p);
10560
- this.debug('pattern match', p, f, hit);
10561
- }
10562
-
10563
- if (!hit) return false
10564
- }
10565
-
10566
- // Note: ending in / means that we'll get a final ""
10567
- // at the end of the pattern. This can only match a
10568
- // corresponding "" at the end of the file.
10569
- // If the file ends in /, then it can only match a
10570
- // a pattern that ends in /, unless the pattern just
10571
- // doesn't have any more for it. But, a/b/ should *not*
10572
- // match "a/b/*", even though "" matches against the
10573
- // [^/]*? pattern, except in partial mode, where it might
10574
- // simply not be reached yet.
10575
- // However, a/b/ should still satisfy a/*
10576
-
10577
- // now either we fell off the end of the pattern, or we're done.
10578
- if (fi === fl && pi === pl) {
10579
- // ran out of pattern and filename at the same time.
10580
- // an exact hit!
10581
- return true
10582
- } else if (fi === fl) {
10583
- // ran out of file, but still had pattern left.
10584
- // this is ok if we're doing the match as part of
10585
- // a glob fs traversal.
10586
- return partial
10587
- } else if (pi === pl) {
10588
- // ran out of pattern, still have file left.
10589
- // this is only acceptable if we're on the very last
10590
- // empty segment of a file with a trailing slash.
10591
- // a/* should match a/b/
10592
- var emptyFileEnd = (fi === fl - 1) && (file[fi] === '');
10593
- return emptyFileEnd
10594
- }
10595
-
10596
- // should be unreachable.
10597
- throw new Error('wtf?')
10598
- };
10599
-
10600
- // replace stuff like \* with *
10601
- function globUnescape (s) {
10602
- return s.replace(/\\(.)/g, '$1')
10603
- }
10604
-
10605
- function regExpEscape (s) {
10606
- return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')
10607
- }
10608
-
10609
- var inherits = {exports: {}};
10610
-
10611
- var inherits_browser = {exports: {}};
10612
-
10613
- var hasRequiredInherits_browser;
10614
-
10615
- function requireInherits_browser () {
10616
- if (hasRequiredInherits_browser) return inherits_browser.exports;
10617
- hasRequiredInherits_browser = 1;
10618
- if (typeof Object.create === 'function') {
10619
- // implementation from standard node.js 'util' module
10620
- inherits_browser.exports = function inherits(ctor, superCtor) {
10621
- if (superCtor) {
10622
- ctor.super_ = superCtor;
10623
- ctor.prototype = Object.create(superCtor.prototype, {
10624
- constructor: {
10625
- value: ctor,
10626
- enumerable: false,
10627
- writable: true,
10628
- configurable: true
10629
- }
10630
- });
10631
- }
10632
- };
10633
- } else {
10634
- // old school shim for old browsers
10635
- inherits_browser.exports = function inherits(ctor, superCtor) {
10636
- if (superCtor) {
10637
- ctor.super_ = superCtor;
10638
- var TempCtor = function () {};
10639
- TempCtor.prototype = superCtor.prototype;
10640
- ctor.prototype = new TempCtor();
10641
- ctor.prototype.constructor = ctor;
10642
- }
10643
- };
10644
- }
10645
- return inherits_browser.exports;
10646
- }
10647
-
10648
- try {
10649
- var util$1 = require('util');
10650
- /* istanbul ignore next */
10651
- if (typeof util$1.inherits !== 'function') throw '';
10652
- inherits.exports = util$1.inherits;
10653
- } catch (e) {
10654
- /* istanbul ignore next */
10655
- inherits.exports = requireInherits_browser();
10656
- }
10657
-
10658
- var inheritsExports = inherits.exports;
10659
-
10660
- var pathIsAbsolute = {exports: {}};
10661
-
10662
- function posix(path) {
10663
- return path.charAt(0) === '/';
10664
- }
10665
-
10666
- function win32$1(path) {
10667
- // https://github.com/nodejs/node/blob/b3fcc245fb25539909ef1d5eaa01dbf92e168633/lib/path.js#L56
10668
- var splitDeviceRe = /^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/;
10669
- var result = splitDeviceRe.exec(path);
10670
- var device = result[1] || '';
10671
- var isUnc = Boolean(device && device.charAt(1) !== ':');
10672
-
10673
- // UNC paths are always absolute
10674
- return Boolean(result[2] || isUnc);
10675
- }
10676
-
10677
- pathIsAbsolute.exports = process.platform === 'win32' ? win32$1 : posix;
10678
- pathIsAbsolute.exports.posix = posix;
10679
- pathIsAbsolute.exports.win32 = win32$1;
10680
-
10681
- var pathIsAbsoluteExports = pathIsAbsolute.exports;
10682
-
10683
- var common = {};
10684
-
10685
- common.alphasort = alphasort;
10686
- common.alphasorti = alphasorti;
10687
- common.setopts = setopts;
10688
- common.ownProp = ownProp;
10689
- common.makeAbs = makeAbs;
10690
- common.finish = finish;
10691
- common.mark = mark;
10692
- common.isIgnored = isIgnored;
10693
- common.childrenIgnored = childrenIgnored;
10694
-
10695
- function ownProp (obj, field) {
10696
- return Object.prototype.hasOwnProperty.call(obj, field)
10697
- }
10698
-
10699
- var path$h = require$$1$1;
10700
- var minimatch = minimatch_1;
10701
- var isAbsolute = pathIsAbsoluteExports;
10702
- var Minimatch = minimatch.Minimatch;
10703
-
10704
- function alphasorti (a, b) {
10705
- return a.toLowerCase().localeCompare(b.toLowerCase())
10706
- }
10707
-
10708
- function alphasort (a, b) {
10709
- return a.localeCompare(b)
10710
- }
10711
-
10712
- function setupIgnores (self, options) {
10713
- self.ignore = options.ignore || [];
10714
-
10715
- if (!Array.isArray(self.ignore))
10716
- self.ignore = [self.ignore];
10717
-
10718
- if (self.ignore.length) {
10719
- self.ignore = self.ignore.map(ignoreMap);
10720
- }
10721
- }
10722
-
10723
- // ignore patterns are always in dot:true mode.
10724
- function ignoreMap (pattern) {
10725
- var gmatcher = null;
10726
- if (pattern.slice(-3) === '/**') {
10727
- var gpattern = pattern.replace(/(\/\*\*)+$/, '');
10728
- gmatcher = new Minimatch(gpattern, { dot: true });
10729
- }
10730
-
10731
- return {
10732
- matcher: new Minimatch(pattern, { dot: true }),
10733
- gmatcher: gmatcher
10734
- }
10735
- }
10736
-
10737
- function setopts (self, pattern, options) {
10738
- if (!options)
10739
- options = {};
10740
-
10741
- // base-matching: just use globstar for that.
10742
- if (options.matchBase && -1 === pattern.indexOf("/")) {
10743
- if (options.noglobstar) {
10744
- throw new Error("base matching requires globstar")
10745
- }
10746
- pattern = "**/" + pattern;
10747
- }
10748
-
10749
- self.silent = !!options.silent;
10750
- self.pattern = pattern;
10751
- self.strict = options.strict !== false;
10752
- self.realpath = !!options.realpath;
10753
- self.realpathCache = options.realpathCache || Object.create(null);
10754
- self.follow = !!options.follow;
10755
- self.dot = !!options.dot;
10756
- self.mark = !!options.mark;
10757
- self.nodir = !!options.nodir;
10758
- if (self.nodir)
10759
- self.mark = true;
10760
- self.sync = !!options.sync;
10761
- self.nounique = !!options.nounique;
10762
- self.nonull = !!options.nonull;
10763
- self.nosort = !!options.nosort;
10764
- self.nocase = !!options.nocase;
10765
- self.stat = !!options.stat;
10766
- self.noprocess = !!options.noprocess;
10767
- self.absolute = !!options.absolute;
10768
-
10769
- self.maxLength = options.maxLength || Infinity;
10770
- self.cache = options.cache || Object.create(null);
10771
- self.statCache = options.statCache || Object.create(null);
10772
- self.symlinks = options.symlinks || Object.create(null);
10773
-
10774
- setupIgnores(self, options);
10775
-
10776
- self.changedCwd = false;
10777
- var cwd = process.cwd();
10778
- if (!ownProp(options, "cwd"))
10779
- self.cwd = cwd;
10780
- else {
10781
- self.cwd = path$h.resolve(options.cwd);
10782
- self.changedCwd = self.cwd !== cwd;
10783
- }
10784
-
10785
- self.root = options.root || path$h.resolve(self.cwd, "/");
10786
- self.root = path$h.resolve(self.root);
10787
- if (process.platform === "win32")
10788
- self.root = self.root.replace(/\\/g, "/");
10789
-
10790
- // TODO: is an absolute `cwd` supposed to be resolved against `root`?
10791
- // e.g. { cwd: '/test', root: __dirname } === path.join(__dirname, '/test')
10792
- self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd);
10793
- if (process.platform === "win32")
10794
- self.cwdAbs = self.cwdAbs.replace(/\\/g, "/");
10795
- self.nomount = !!options.nomount;
10796
-
10797
- // disable comments and negation in Minimatch.
10798
- // Note that they are not supported in Glob itself anyway.
10799
- options.nonegate = true;
10800
- options.nocomment = true;
10801
-
10802
- self.minimatch = new Minimatch(pattern, options);
10803
- self.options = self.minimatch.options;
10804
- }
10805
-
10806
- function finish (self) {
10807
- var nou = self.nounique;
10808
- var all = nou ? [] : Object.create(null);
10809
-
10810
- for (var i = 0, l = self.matches.length; i < l; i ++) {
10811
- var matches = self.matches[i];
10812
- if (!matches || Object.keys(matches).length === 0) {
10813
- if (self.nonull) {
10814
- // do like the shell, and spit out the literal glob
10815
- var literal = self.minimatch.globSet[i];
10816
- if (nou)
10817
- all.push(literal);
10818
- else
10819
- all[literal] = true;
10820
- }
10821
- } else {
10822
- // had matches
10823
- var m = Object.keys(matches);
10824
- if (nou)
10825
- all.push.apply(all, m);
10826
- else
10827
- m.forEach(function (m) {
10828
- all[m] = true;
10829
- });
10830
- }
10831
- }
10832
-
10833
- if (!nou)
10834
- all = Object.keys(all);
10835
-
10836
- if (!self.nosort)
10837
- all = all.sort(self.nocase ? alphasorti : alphasort);
10838
-
10839
- // at *some* point we statted all of these
10840
- if (self.mark) {
10841
- for (var i = 0; i < all.length; i++) {
10842
- all[i] = self._mark(all[i]);
10843
- }
10844
- if (self.nodir) {
10845
- all = all.filter(function (e) {
10846
- var notDir = !(/\/$/.test(e));
10847
- var c = self.cache[e] || self.cache[makeAbs(self, e)];
10848
- if (notDir && c)
10849
- notDir = c !== 'DIR' && !Array.isArray(c);
10850
- return notDir
10851
- });
10852
- }
10853
- }
10854
-
10855
- if (self.ignore.length)
10856
- all = all.filter(function(m) {
10857
- return !isIgnored(self, m)
10858
- });
10859
-
10860
- self.found = all;
10861
- }
10862
-
10863
- function mark (self, p) {
10864
- var abs = makeAbs(self, p);
10865
- var c = self.cache[abs];
10866
- var m = p;
10867
- if (c) {
10868
- var isDir = c === 'DIR' || Array.isArray(c);
10869
- var slash = p.slice(-1) === '/';
10870
-
10871
- if (isDir && !slash)
10872
- m += '/';
10873
- else if (!isDir && slash)
10874
- m = m.slice(0, -1);
10875
-
10876
- if (m !== p) {
10877
- var mabs = makeAbs(self, m);
10878
- self.statCache[mabs] = self.statCache[abs];
10879
- self.cache[mabs] = self.cache[abs];
10880
- }
10881
- }
10882
-
10883
- return m
10884
- }
10885
-
10886
- // lotta situps...
10887
- function makeAbs (self, f) {
10888
- var abs = f;
10889
- if (f.charAt(0) === '/') {
10890
- abs = path$h.join(self.root, f);
10891
- } else if (isAbsolute(f) || f === '') {
10892
- abs = f;
10893
- } else if (self.changedCwd) {
10894
- abs = path$h.resolve(self.cwd, f);
10895
- } else {
10896
- abs = path$h.resolve(f);
10897
- }
10898
-
10899
- if (process.platform === 'win32')
10900
- abs = abs.replace(/\\/g, '/');
10901
-
10902
- return abs
10903
- }
10904
-
10905
-
10906
- // Return true, if pattern ends with globstar '**', for the accompanying parent directory.
10907
- // Ex:- If node_modules/** is the pattern, add 'node_modules' to ignore list along with it's contents
10908
- function isIgnored (self, path) {
10909
- if (!self.ignore.length)
10910
- return false
10911
-
10912
- return self.ignore.some(function(item) {
10913
- return item.matcher.match(path) || !!(item.gmatcher && item.gmatcher.match(path))
10914
- })
10915
- }
10916
-
10917
- function childrenIgnored (self, path) {
10918
- if (!self.ignore.length)
10919
- return false
10920
-
10921
- return self.ignore.some(function(item) {
10922
- return !!(item.gmatcher && item.gmatcher.match(path))
10923
- })
10924
- }
10925
-
10926
- var sync;
10927
- var hasRequiredSync;
10928
-
10929
- function requireSync () {
10930
- if (hasRequiredSync) return sync;
10931
- hasRequiredSync = 1;
10932
- sync = globSync;
10933
- globSync.GlobSync = GlobSync;
10934
-
10935
- var fs = fs$l;
10936
- var rp = fs_realpath;
10937
- var minimatch = minimatch_1;
10938
- minimatch.Minimatch;
10939
- requireGlob().Glob;
10940
- var path = require$$1$1;
10941
- var assert = require$$6;
10942
- var isAbsolute = pathIsAbsoluteExports;
10943
- var common$1 = common;
10944
- common$1.alphasort;
10945
- common$1.alphasorti;
10946
- var setopts = common$1.setopts;
10947
- var ownProp = common$1.ownProp;
10948
- var childrenIgnored = common$1.childrenIgnored;
10949
- var isIgnored = common$1.isIgnored;
10950
-
10951
- function globSync (pattern, options) {
10952
- if (typeof options === 'function' || arguments.length === 3)
10953
- throw new TypeError('callback provided to sync glob\n'+
10954
- 'See: https://github.com/isaacs/node-glob/issues/167')
10955
-
10956
- return new GlobSync(pattern, options).found
10957
- }
10958
-
10959
- function GlobSync (pattern, options) {
10960
- if (!pattern)
10961
- throw new Error('must provide pattern')
10962
-
10963
- if (typeof options === 'function' || arguments.length === 3)
10964
- throw new TypeError('callback provided to sync glob\n'+
10965
- 'See: https://github.com/isaacs/node-glob/issues/167')
10966
-
10967
- if (!(this instanceof GlobSync))
10968
- return new GlobSync(pattern, options)
10969
-
10970
- setopts(this, pattern, options);
10971
-
10972
- if (this.noprocess)
10973
- return this
10974
-
10975
- var n = this.minimatch.set.length;
10976
- this.matches = new Array(n);
10977
- for (var i = 0; i < n; i ++) {
10978
- this._process(this.minimatch.set[i], i, false);
10979
- }
10980
- this._finish();
10981
- }
10982
-
10983
- GlobSync.prototype._finish = function () {
10984
- assert(this instanceof GlobSync);
10985
- if (this.realpath) {
10986
- var self = this;
10987
- this.matches.forEach(function (matchset, index) {
10988
- var set = self.matches[index] = Object.create(null);
10989
- for (var p in matchset) {
10990
- try {
10991
- p = self._makeAbs(p);
10992
- var real = rp.realpathSync(p, self.realpathCache);
10993
- set[real] = true;
10994
- } catch (er) {
10995
- if (er.syscall === 'stat')
10996
- set[self._makeAbs(p)] = true;
10997
- else
10998
- throw er
10999
- }
11000
- }
11001
- });
11002
- }
11003
- common$1.finish(this);
11004
- };
11005
-
11006
-
11007
- GlobSync.prototype._process = function (pattern, index, inGlobStar) {
11008
- assert(this instanceof GlobSync);
11009
-
11010
- // Get the first [n] parts of pattern that are all strings.
11011
- var n = 0;
11012
- while (typeof pattern[n] === 'string') {
11013
- n ++;
11014
- }
11015
- // now n is the index of the first one that is *not* a string.
11016
-
11017
- // See if there's anything else
11018
- var prefix;
11019
- switch (n) {
11020
- // if not, then this is rather simple
11021
- case pattern.length:
11022
- this._processSimple(pattern.join('/'), index);
11023
- return
11024
-
11025
- case 0:
11026
- // pattern *starts* with some non-trivial item.
11027
- // going to readdir(cwd), but not include the prefix in matches.
11028
- prefix = null;
11029
- break
11030
-
11031
- default:
11032
- // pattern has some string bits in the front.
11033
- // whatever it starts with, whether that's 'absolute' like /foo/bar,
11034
- // or 'relative' like '../baz'
11035
- prefix = pattern.slice(0, n).join('/');
11036
- break
11037
- }
11038
-
11039
- var remain = pattern.slice(n);
11040
-
11041
- // get the list of entries.
11042
- var read;
11043
- if (prefix === null)
11044
- read = '.';
11045
- else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) {
11046
- if (!prefix || !isAbsolute(prefix))
11047
- prefix = '/' + prefix;
11048
- read = prefix;
11049
- } else
11050
- read = prefix;
11051
-
11052
- var abs = this._makeAbs(read);
11053
-
11054
- //if ignored, skip processing
11055
- if (childrenIgnored(this, read))
11056
- return
11057
-
11058
- var isGlobStar = remain[0] === minimatch.GLOBSTAR;
11059
- if (isGlobStar)
11060
- this._processGlobStar(prefix, read, abs, remain, index, inGlobStar);
11061
- else
11062
- this._processReaddir(prefix, read, abs, remain, index, inGlobStar);
11063
- };
11064
-
11065
-
11066
- GlobSync.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar) {
11067
- var entries = this._readdir(abs, inGlobStar);
11068
-
11069
- // if the abs isn't a dir, then nothing can match!
11070
- if (!entries)
11071
- return
11072
-
11073
- // It will only match dot entries if it starts with a dot, or if
11074
- // dot is set. Stuff like @(.foo|.bar) isn't allowed.
11075
- var pn = remain[0];
11076
- var negate = !!this.minimatch.negate;
11077
- var rawGlob = pn._glob;
11078
- var dotOk = this.dot || rawGlob.charAt(0) === '.';
11079
-
11080
- var matchedEntries = [];
11081
- for (var i = 0; i < entries.length; i++) {
11082
- var e = entries[i];
11083
- if (e.charAt(0) !== '.' || dotOk) {
11084
- var m;
11085
- if (negate && !prefix) {
11086
- m = !e.match(pn);
11087
- } else {
11088
- m = e.match(pn);
11089
- }
11090
- if (m)
11091
- matchedEntries.push(e);
11092
- }
11093
- }
11094
-
11095
- var len = matchedEntries.length;
11096
- // If there are no matched entries, then nothing matches.
11097
- if (len === 0)
11098
- return
11099
-
11100
- // if this is the last remaining pattern bit, then no need for
11101
- // an additional stat *unless* the user has specified mark or
11102
- // stat explicitly. We know they exist, since readdir returned
11103
- // them.
11104
-
11105
- if (remain.length === 1 && !this.mark && !this.stat) {
11106
- if (!this.matches[index])
11107
- this.matches[index] = Object.create(null);
11108
-
11109
- for (var i = 0; i < len; i ++) {
11110
- var e = matchedEntries[i];
11111
- if (prefix) {
11112
- if (prefix.slice(-1) !== '/')
11113
- e = prefix + '/' + e;
11114
- else
11115
- e = prefix + e;
11116
- }
11117
-
11118
- if (e.charAt(0) === '/' && !this.nomount) {
11119
- e = path.join(this.root, e);
11120
- }
11121
- this._emitMatch(index, e);
11122
- }
11123
- // This was the last one, and no stats were needed
11124
- return
11125
- }
11126
-
11127
- // now test all matched entries as stand-ins for that part
11128
- // of the pattern.
11129
- remain.shift();
11130
- for (var i = 0; i < len; i ++) {
11131
- var e = matchedEntries[i];
11132
- var newPattern;
11133
- if (prefix)
11134
- newPattern = [prefix, e];
11135
- else
11136
- newPattern = [e];
11137
- this._process(newPattern.concat(remain), index, inGlobStar);
11138
- }
11139
- };
11140
-
11141
-
11142
- GlobSync.prototype._emitMatch = function (index, e) {
11143
- if (isIgnored(this, e))
11144
- return
11145
-
11146
- var abs = this._makeAbs(e);
11147
-
11148
- if (this.mark)
11149
- e = this._mark(e);
11150
-
11151
- if (this.absolute) {
11152
- e = abs;
11153
- }
11154
-
11155
- if (this.matches[index][e])
11156
- return
11157
-
11158
- if (this.nodir) {
11159
- var c = this.cache[abs];
11160
- if (c === 'DIR' || Array.isArray(c))
11161
- return
11162
- }
11163
-
11164
- this.matches[index][e] = true;
11165
-
11166
- if (this.stat)
11167
- this._stat(e);
11168
- };
11169
-
11170
-
11171
- GlobSync.prototype._readdirInGlobStar = function (abs) {
11172
- // follow all symlinked directories forever
11173
- // just proceed as if this is a non-globstar situation
11174
- if (this.follow)
11175
- return this._readdir(abs, false)
11176
-
11177
- var entries;
11178
- var lstat;
11179
- try {
11180
- lstat = fs.lstatSync(abs);
11181
- } catch (er) {
11182
- if (er.code === 'ENOENT') {
11183
- // lstat failed, doesn't exist
11184
- return null
11185
- }
11186
- }
11187
-
11188
- var isSym = lstat && lstat.isSymbolicLink();
11189
- this.symlinks[abs] = isSym;
11190
-
11191
- // If it's not a symlink or a dir, then it's definitely a regular file.
11192
- // don't bother doing a readdir in that case.
11193
- if (!isSym && lstat && !lstat.isDirectory())
11194
- this.cache[abs] = 'FILE';
11195
- else
11196
- entries = this._readdir(abs, false);
11197
-
11198
- return entries
11199
- };
11200
-
11201
- GlobSync.prototype._readdir = function (abs, inGlobStar) {
11202
-
11203
- if (inGlobStar && !ownProp(this.symlinks, abs))
11204
- return this._readdirInGlobStar(abs)
11205
-
11206
- if (ownProp(this.cache, abs)) {
11207
- var c = this.cache[abs];
11208
- if (!c || c === 'FILE')
11209
- return null
11210
-
11211
- if (Array.isArray(c))
11212
- return c
11213
- }
11214
-
11215
- try {
11216
- return this._readdirEntries(abs, fs.readdirSync(abs))
11217
- } catch (er) {
11218
- this._readdirError(abs, er);
11219
- return null
11220
- }
11221
- };
11222
-
11223
- GlobSync.prototype._readdirEntries = function (abs, entries) {
11224
- // if we haven't asked to stat everything, then just
11225
- // assume that everything in there exists, so we can avoid
11226
- // having to stat it a second time.
11227
- if (!this.mark && !this.stat) {
11228
- for (var i = 0; i < entries.length; i ++) {
11229
- var e = entries[i];
11230
- if (abs === '/')
11231
- e = abs + e;
11232
- else
11233
- e = abs + '/' + e;
11234
- this.cache[e] = true;
11235
- }
11236
- }
11237
-
11238
- this.cache[abs] = entries;
11239
-
11240
- // mark and cache dir-ness
11241
- return entries
11242
- };
11243
-
11244
- GlobSync.prototype._readdirError = function (f, er) {
11245
- // handle errors, and cache the information
11246
- switch (er.code) {
11247
- case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205
11248
- case 'ENOTDIR': // totally normal. means it *does* exist.
11249
- var abs = this._makeAbs(f);
11250
- this.cache[abs] = 'FILE';
11251
- if (abs === this.cwdAbs) {
11252
- var error = new Error(er.code + ' invalid cwd ' + this.cwd);
11253
- error.path = this.cwd;
11254
- error.code = er.code;
11255
- throw error
11256
- }
11257
- break
11258
-
11259
- case 'ENOENT': // not terribly unusual
11260
- case 'ELOOP':
11261
- case 'ENAMETOOLONG':
11262
- case 'UNKNOWN':
11263
- this.cache[this._makeAbs(f)] = false;
11264
- break
11265
-
11266
- default: // some unusual error. Treat as failure.
11267
- this.cache[this._makeAbs(f)] = false;
11268
- if (this.strict)
11269
- throw er
11270
- if (!this.silent)
11271
- console.error('glob error', er);
11272
- break
11273
- }
11274
- };
11275
-
11276
- GlobSync.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar) {
11277
-
11278
- var entries = this._readdir(abs, inGlobStar);
11279
-
11280
- // no entries means not a dir, so it can never have matches
11281
- // foo.txt/** doesn't match foo.txt
11282
- if (!entries)
11283
- return
11284
-
11285
- // test without the globstar, and with every child both below
11286
- // and replacing the globstar.
11287
- var remainWithoutGlobStar = remain.slice(1);
11288
- var gspref = prefix ? [ prefix ] : [];
11289
- var noGlobStar = gspref.concat(remainWithoutGlobStar);
11290
-
11291
- // the noGlobStar pattern exits the inGlobStar state
11292
- this._process(noGlobStar, index, false);
11293
-
11294
- var len = entries.length;
11295
- var isSym = this.symlinks[abs];
11296
-
11297
- // If it's a symlink, and we're in a globstar, then stop
11298
- if (isSym && inGlobStar)
11299
- return
11300
-
11301
- for (var i = 0; i < len; i++) {
11302
- var e = entries[i];
11303
- if (e.charAt(0) === '.' && !this.dot)
11304
- continue
11305
-
11306
- // these two cases enter the inGlobStar state
11307
- var instead = gspref.concat(entries[i], remainWithoutGlobStar);
11308
- this._process(instead, index, true);
11309
-
11310
- var below = gspref.concat(entries[i], remain);
11311
- this._process(below, index, true);
11312
- }
11313
- };
11314
-
11315
- GlobSync.prototype._processSimple = function (prefix, index) {
11316
- // XXX review this. Shouldn't it be doing the mounting etc
11317
- // before doing stat? kinda weird?
11318
- var exists = this._stat(prefix);
11319
-
11320
- if (!this.matches[index])
11321
- this.matches[index] = Object.create(null);
11322
-
11323
- // If it doesn't exist, then just mark the lack of results
11324
- if (!exists)
11325
- return
11326
-
11327
- if (prefix && isAbsolute(prefix) && !this.nomount) {
11328
- var trail = /[\/\\]$/.test(prefix);
11329
- if (prefix.charAt(0) === '/') {
11330
- prefix = path.join(this.root, prefix);
11331
- } else {
11332
- prefix = path.resolve(this.root, prefix);
11333
- if (trail)
11334
- prefix += '/';
11335
- }
11336
- }
11337
-
11338
- if (process.platform === 'win32')
11339
- prefix = prefix.replace(/\\/g, '/');
11340
-
11341
- // Mark this as a match
11342
- this._emitMatch(index, prefix);
11343
- };
11344
-
11345
- // Returns either 'DIR', 'FILE', or false
11346
- GlobSync.prototype._stat = function (f) {
11347
- var abs = this._makeAbs(f);
11348
- var needDir = f.slice(-1) === '/';
11349
-
11350
- if (f.length > this.maxLength)
11351
- return false
11352
-
11353
- if (!this.stat && ownProp(this.cache, abs)) {
11354
- var c = this.cache[abs];
11355
-
11356
- if (Array.isArray(c))
11357
- c = 'DIR';
11358
-
11359
- // It exists, but maybe not how we need it
11360
- if (!needDir || c === 'DIR')
11361
- return c
11362
-
11363
- if (needDir && c === 'FILE')
11364
- return false
11365
-
11366
- // otherwise we have to stat, because maybe c=true
11367
- // if we know it exists, but not what it is.
11368
- }
11369
- var stat = this.statCache[abs];
11370
- if (!stat) {
11371
- var lstat;
11372
- try {
11373
- lstat = fs.lstatSync(abs);
11374
- } catch (er) {
11375
- if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) {
11376
- this.statCache[abs] = false;
11377
- return false
11378
- }
11379
- }
11380
-
11381
- if (lstat && lstat.isSymbolicLink()) {
11382
- try {
11383
- stat = fs.statSync(abs);
11384
- } catch (er) {
11385
- stat = lstat;
11386
- }
11387
- } else {
11388
- stat = lstat;
11389
- }
11390
- }
11391
-
11392
- this.statCache[abs] = stat;
11393
-
11394
- var c = true;
11395
- if (stat)
11396
- c = stat.isDirectory() ? 'DIR' : 'FILE';
11397
-
11398
- this.cache[abs] = this.cache[abs] || c;
11399
-
11400
- if (needDir && c === 'FILE')
11401
- return false
11402
-
11403
- return c
11404
- };
11405
-
11406
- GlobSync.prototype._mark = function (p) {
11407
- return common$1.mark(this, p)
11408
- };
11409
-
11410
- GlobSync.prototype._makeAbs = function (f) {
11411
- return common$1.makeAbs(this, f)
11412
- };
11413
- return sync;
11414
- }
11415
-
11416
- // Returns a wrapper function that returns a wrapped callback
11417
- // The wrapper function should do some stuff, and return a
11418
- // presumably different callback function.
11419
- // This makes sure that own properties are retained, so that
11420
- // decorations and such are not lost along the way.
11421
- var wrappy_1 = wrappy$2;
11422
- function wrappy$2 (fn, cb) {
11423
- if (fn && cb) return wrappy$2(fn)(cb)
11424
-
11425
- if (typeof fn !== 'function')
11426
- throw new TypeError('need wrapper function')
11427
-
11428
- Object.keys(fn).forEach(function (k) {
11429
- wrapper[k] = fn[k];
11430
- });
11431
-
11432
- return wrapper
11433
-
11434
- function wrapper() {
11435
- var args = new Array(arguments.length);
11436
- for (var i = 0; i < args.length; i++) {
11437
- args[i] = arguments[i];
11438
- }
11439
- var ret = fn.apply(this, args);
11440
- var cb = args[args.length-1];
11441
- if (typeof ret === 'function' && ret !== cb) {
11442
- Object.keys(cb).forEach(function (k) {
11443
- ret[k] = cb[k];
11444
- });
11445
- }
11446
- return ret
11447
- }
11448
- }
11449
-
11450
- var once$2 = {exports: {}};
11451
-
11452
- var wrappy$1 = wrappy_1;
11453
- once$2.exports = wrappy$1(once$1);
11454
- once$2.exports.strict = wrappy$1(onceStrict);
11455
-
11456
- once$1.proto = once$1(function () {
11457
- Object.defineProperty(Function.prototype, 'once', {
11458
- value: function () {
11459
- return once$1(this)
11460
- },
11461
- configurable: true
11462
- });
11463
-
11464
- Object.defineProperty(Function.prototype, 'onceStrict', {
11465
- value: function () {
11466
- return onceStrict(this)
11467
- },
11468
- configurable: true
11469
- });
11470
- });
11471
-
11472
- function once$1 (fn) {
11473
- var f = function () {
11474
- if (f.called) return f.value
11475
- f.called = true;
11476
- return f.value = fn.apply(this, arguments)
11477
- };
11478
- f.called = false;
11479
- return f
11480
- }
11481
-
11482
- function onceStrict (fn) {
11483
- var f = function () {
11484
- if (f.called)
11485
- throw new Error(f.onceError)
11486
- f.called = true;
11487
- return f.value = fn.apply(this, arguments)
11488
- };
11489
- var name = fn.name || 'Function wrapped with `once`';
11490
- f.onceError = name + " shouldn't be called more than once";
11491
- f.called = false;
11492
- return f
11493
- }
11494
-
11495
- var onceExports = once$2.exports;
11496
-
11497
- var wrappy = wrappy_1;
11498
- var reqs = Object.create(null);
11499
- var once = onceExports;
11500
-
11501
- var inflight_1 = wrappy(inflight);
11502
-
11503
- function inflight (key, cb) {
11504
- if (reqs[key]) {
11505
- reqs[key].push(cb);
11506
- return null
11507
- } else {
11508
- reqs[key] = [cb];
11509
- return makeres(key)
11510
- }
11511
- }
11512
-
11513
- function makeres (key) {
11514
- return once(function RES () {
11515
- var cbs = reqs[key];
11516
- var len = cbs.length;
11517
- var args = slice(arguments);
11518
-
11519
- // XXX It's somewhat ambiguous whether a new callback added in this
11520
- // pass should be queued for later execution if something in the
11521
- // list of callbacks throws, or if it should just be discarded.
11522
- // However, it's such an edge case that it hardly matters, and either
11523
- // choice is likely as surprising as the other.
11524
- // As it happens, we do go ahead and schedule it for later execution.
11525
- try {
11526
- for (var i = 0; i < len; i++) {
11527
- cbs[i].apply(null, args);
11528
- }
11529
- } finally {
11530
- if (cbs.length > len) {
11531
- // added more in the interim.
11532
- // de-zalgo, just in case, but don't call again.
11533
- cbs.splice(0, len);
11534
- process.nextTick(function () {
11535
- RES.apply(null, args);
11536
- });
11537
- } else {
11538
- delete reqs[key];
11539
- }
11540
- }
11541
- })
11542
- }
11543
-
11544
- function slice (args) {
11545
- var length = args.length;
11546
- var array = [];
11547
-
11548
- for (var i = 0; i < length; i++) array[i] = args[i];
11549
- return array
11550
- }
11551
-
11552
- var glob_1;
11553
- var hasRequiredGlob;
11554
-
11555
- function requireGlob () {
11556
- if (hasRequiredGlob) return glob_1;
11557
- hasRequiredGlob = 1;
11558
- // Approach:
11559
- //
11560
- // 1. Get the minimatch set
11561
- // 2. For each pattern in the set, PROCESS(pattern, false)
11562
- // 3. Store matches per-set, then uniq them
11563
- //
11564
- // PROCESS(pattern, inGlobStar)
11565
- // Get the first [n] items from pattern that are all strings
11566
- // Join these together. This is PREFIX.
11567
- // If there is no more remaining, then stat(PREFIX) and
11568
- // add to matches if it succeeds. END.
11569
- //
11570
- // If inGlobStar and PREFIX is symlink and points to dir
11571
- // set ENTRIES = []
11572
- // else readdir(PREFIX) as ENTRIES
11573
- // If fail, END
11574
- //
11575
- // with ENTRIES
11576
- // If pattern[n] is GLOBSTAR
11577
- // // handle the case where the globstar match is empty
11578
- // // by pruning it out, and testing the resulting pattern
11579
- // PROCESS(pattern[0..n] + pattern[n+1 .. $], false)
11580
- // // handle other cases.
11581
- // for ENTRY in ENTRIES (not dotfiles)
11582
- // // attach globstar + tail onto the entry
11583
- // // Mark that this entry is a globstar match
11584
- // PROCESS(pattern[0..n] + ENTRY + pattern[n .. $], true)
11585
- //
11586
- // else // not globstar
11587
- // for ENTRY in ENTRIES (not dotfiles, unless pattern[n] is dot)
11588
- // Test ENTRY against pattern[n]
11589
- // If fails, continue
11590
- // If passes, PROCESS(pattern[0..n] + item + pattern[n+1 .. $])
11591
- //
11592
- // Caveat:
11593
- // Cache all stats and readdirs results to minimize syscall. Since all
11594
- // we ever care about is existence and directory-ness, we can just keep
11595
- // `true` for files, and [children,...] for directories, or `false` for
11596
- // things that don't exist.
11597
-
11598
- glob_1 = glob;
11599
-
11600
- var fs = fs$l;
11601
- var rp = fs_realpath;
11602
- var minimatch = minimatch_1;
11603
- minimatch.Minimatch;
11604
- var inherits = inheritsExports;
11605
- var EE = require$$4.EventEmitter;
11606
- var path = require$$1$1;
11607
- var assert = require$$6;
11608
- var isAbsolute = pathIsAbsoluteExports;
11609
- var globSync = requireSync();
11610
- var common$1 = common;
11611
- common$1.alphasort;
11612
- common$1.alphasorti;
11613
- var setopts = common$1.setopts;
11614
- var ownProp = common$1.ownProp;
11615
- var inflight = inflight_1;
11616
- var childrenIgnored = common$1.childrenIgnored;
11617
- var isIgnored = common$1.isIgnored;
11618
-
11619
- var once = onceExports;
11620
-
11621
- function glob (pattern, options, cb) {
11622
- if (typeof options === 'function') cb = options, options = {};
11623
- if (!options) options = {};
11624
-
11625
- if (options.sync) {
11626
- if (cb)
11627
- throw new TypeError('callback provided to sync glob')
11628
- return globSync(pattern, options)
11629
- }
11630
-
11631
- return new Glob(pattern, options, cb)
11632
- }
11633
-
11634
- glob.sync = globSync;
11635
- var GlobSync = glob.GlobSync = globSync.GlobSync;
11636
-
11637
- // old api surface
11638
- glob.glob = glob;
11639
-
11640
- function extend (origin, add) {
11641
- if (add === null || typeof add !== 'object') {
11642
- return origin
11643
- }
11644
-
11645
- var keys = Object.keys(add);
11646
- var i = keys.length;
11647
- while (i--) {
11648
- origin[keys[i]] = add[keys[i]];
11649
- }
11650
- return origin
11651
- }
11652
-
11653
- glob.hasMagic = function (pattern, options_) {
11654
- var options = extend({}, options_);
11655
- options.noprocess = true;
11656
-
11657
- var g = new Glob(pattern, options);
11658
- var set = g.minimatch.set;
11659
-
11660
- if (!pattern)
11661
- return false
11662
-
11663
- if (set.length > 1)
11664
- return true
11665
-
11666
- for (var j = 0; j < set[0].length; j++) {
11667
- if (typeof set[0][j] !== 'string')
11668
- return true
11669
- }
11670
-
11671
- return false
11672
- };
11673
-
11674
- glob.Glob = Glob;
11675
- inherits(Glob, EE);
11676
- function Glob (pattern, options, cb) {
11677
- if (typeof options === 'function') {
11678
- cb = options;
11679
- options = null;
11680
- }
11681
-
11682
- if (options && options.sync) {
11683
- if (cb)
11684
- throw new TypeError('callback provided to sync glob')
11685
- return new GlobSync(pattern, options)
11686
- }
11687
-
11688
- if (!(this instanceof Glob))
11689
- return new Glob(pattern, options, cb)
11690
-
11691
- setopts(this, pattern, options);
11692
- this._didRealPath = false;
11693
-
11694
- // process each pattern in the minimatch set
11695
- var n = this.minimatch.set.length;
11696
-
11697
- // The matches are stored as {<filename>: true,...} so that
11698
- // duplicates are automagically pruned.
11699
- // Later, we do an Object.keys() on these.
11700
- // Keep them as a list so we can fill in when nonull is set.
11701
- this.matches = new Array(n);
11702
-
11703
- if (typeof cb === 'function') {
11704
- cb = once(cb);
11705
- this.on('error', cb);
11706
- this.on('end', function (matches) {
11707
- cb(null, matches);
11708
- });
11709
- }
11710
-
11711
- var self = this;
11712
- this._processing = 0;
11713
-
11714
- this._emitQueue = [];
11715
- this._processQueue = [];
11716
- this.paused = false;
11717
-
11718
- if (this.noprocess)
11719
- return this
11720
-
11721
- if (n === 0)
11722
- return done()
11723
-
11724
- var sync = true;
11725
- for (var i = 0; i < n; i ++) {
11726
- this._process(this.minimatch.set[i], i, false, done);
11727
- }
11728
- sync = false;
11729
-
11730
- function done () {
11731
- --self._processing;
11732
- if (self._processing <= 0) {
11733
- if (sync) {
11734
- process.nextTick(function () {
11735
- self._finish();
11736
- });
11737
- } else {
11738
- self._finish();
11739
- }
11740
- }
11741
- }
11742
- }
11743
-
11744
- Glob.prototype._finish = function () {
11745
- assert(this instanceof Glob);
11746
- if (this.aborted)
11747
- return
11748
-
11749
- if (this.realpath && !this._didRealpath)
11750
- return this._realpath()
11751
-
11752
- common$1.finish(this);
11753
- this.emit('end', this.found);
11754
- };
11755
-
11756
- Glob.prototype._realpath = function () {
11757
- if (this._didRealpath)
11758
- return
11759
-
11760
- this._didRealpath = true;
11761
-
11762
- var n = this.matches.length;
11763
- if (n === 0)
11764
- return this._finish()
11765
-
11766
- var self = this;
11767
- for (var i = 0; i < this.matches.length; i++)
11768
- this._realpathSet(i, next);
11769
-
11770
- function next () {
11771
- if (--n === 0)
11772
- self._finish();
11773
- }
11774
- };
11775
-
11776
- Glob.prototype._realpathSet = function (index, cb) {
11777
- var matchset = this.matches[index];
11778
- if (!matchset)
11779
- return cb()
11780
-
11781
- var found = Object.keys(matchset);
11782
- var self = this;
11783
- var n = found.length;
11784
-
11785
- if (n === 0)
11786
- return cb()
11787
-
11788
- var set = this.matches[index] = Object.create(null);
11789
- found.forEach(function (p, i) {
11790
- // If there's a problem with the stat, then it means that
11791
- // one or more of the links in the realpath couldn't be
11792
- // resolved. just return the abs value in that case.
11793
- p = self._makeAbs(p);
11794
- rp.realpath(p, self.realpathCache, function (er, real) {
11795
- if (!er)
11796
- set[real] = true;
11797
- else if (er.syscall === 'stat')
11798
- set[p] = true;
11799
- else
11800
- self.emit('error', er); // srsly wtf right here
11801
-
11802
- if (--n === 0) {
11803
- self.matches[index] = set;
11804
- cb();
11805
- }
11806
- });
11807
- });
11808
- };
11809
-
11810
- Glob.prototype._mark = function (p) {
11811
- return common$1.mark(this, p)
11812
- };
11813
-
11814
- Glob.prototype._makeAbs = function (f) {
11815
- return common$1.makeAbs(this, f)
11816
- };
11817
-
11818
- Glob.prototype.abort = function () {
11819
- this.aborted = true;
11820
- this.emit('abort');
11821
- };
11822
-
11823
- Glob.prototype.pause = function () {
11824
- if (!this.paused) {
11825
- this.paused = true;
11826
- this.emit('pause');
11827
- }
11828
- };
11829
-
11830
- Glob.prototype.resume = function () {
11831
- if (this.paused) {
11832
- this.emit('resume');
11833
- this.paused = false;
11834
- if (this._emitQueue.length) {
11835
- var eq = this._emitQueue.slice(0);
11836
- this._emitQueue.length = 0;
11837
- for (var i = 0; i < eq.length; i ++) {
11838
- var e = eq[i];
11839
- this._emitMatch(e[0], e[1]);
11840
- }
11841
- }
11842
- if (this._processQueue.length) {
11843
- var pq = this._processQueue.slice(0);
11844
- this._processQueue.length = 0;
11845
- for (var i = 0; i < pq.length; i ++) {
11846
- var p = pq[i];
11847
- this._processing--;
11848
- this._process(p[0], p[1], p[2], p[3]);
11849
- }
11850
- }
11851
- }
11852
- };
11853
-
11854
- Glob.prototype._process = function (pattern, index, inGlobStar, cb) {
11855
- assert(this instanceof Glob);
11856
- assert(typeof cb === 'function');
11857
-
11858
- if (this.aborted)
11859
- return
11860
-
11861
- this._processing++;
11862
- if (this.paused) {
11863
- this._processQueue.push([pattern, index, inGlobStar, cb]);
11864
- return
11865
- }
11866
-
11867
- //console.error('PROCESS %d', this._processing, pattern)
11868
-
11869
- // Get the first [n] parts of pattern that are all strings.
11870
- var n = 0;
11871
- while (typeof pattern[n] === 'string') {
11872
- n ++;
11873
- }
11874
- // now n is the index of the first one that is *not* a string.
11875
-
11876
- // see if there's anything else
11877
- var prefix;
11878
- switch (n) {
11879
- // if not, then this is rather simple
11880
- case pattern.length:
11881
- this._processSimple(pattern.join('/'), index, cb);
11882
- return
11883
-
11884
- case 0:
11885
- // pattern *starts* with some non-trivial item.
11886
- // going to readdir(cwd), but not include the prefix in matches.
11887
- prefix = null;
11888
- break
11889
-
11890
- default:
11891
- // pattern has some string bits in the front.
11892
- // whatever it starts with, whether that's 'absolute' like /foo/bar,
11893
- // or 'relative' like '../baz'
11894
- prefix = pattern.slice(0, n).join('/');
11895
- break
11896
- }
11897
-
11898
- var remain = pattern.slice(n);
11899
-
11900
- // get the list of entries.
11901
- var read;
11902
- if (prefix === null)
11903
- read = '.';
11904
- else if (isAbsolute(prefix) || isAbsolute(pattern.join('/'))) {
11905
- if (!prefix || !isAbsolute(prefix))
11906
- prefix = '/' + prefix;
11907
- read = prefix;
11908
- } else
11909
- read = prefix;
11910
-
11911
- var abs = this._makeAbs(read);
11912
-
11913
- //if ignored, skip _processing
11914
- if (childrenIgnored(this, read))
11915
- return cb()
11916
-
11917
- var isGlobStar = remain[0] === minimatch.GLOBSTAR;
11918
- if (isGlobStar)
11919
- this._processGlobStar(prefix, read, abs, remain, index, inGlobStar, cb);
11920
- else
11921
- this._processReaddir(prefix, read, abs, remain, index, inGlobStar, cb);
11922
- };
11923
-
11924
- Glob.prototype._processReaddir = function (prefix, read, abs, remain, index, inGlobStar, cb) {
11925
- var self = this;
11926
- this._readdir(abs, inGlobStar, function (er, entries) {
11927
- return self._processReaddir2(prefix, read, abs, remain, index, inGlobStar, entries, cb)
11928
- });
11929
- };
11930
-
11931
- Glob.prototype._processReaddir2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
11932
-
11933
- // if the abs isn't a dir, then nothing can match!
11934
- if (!entries)
11935
- return cb()
11936
-
11937
- // It will only match dot entries if it starts with a dot, or if
11938
- // dot is set. Stuff like @(.foo|.bar) isn't allowed.
11939
- var pn = remain[0];
11940
- var negate = !!this.minimatch.negate;
11941
- var rawGlob = pn._glob;
11942
- var dotOk = this.dot || rawGlob.charAt(0) === '.';
11943
-
11944
- var matchedEntries = [];
11945
- for (var i = 0; i < entries.length; i++) {
11946
- var e = entries[i];
11947
- if (e.charAt(0) !== '.' || dotOk) {
11948
- var m;
11949
- if (negate && !prefix) {
11950
- m = !e.match(pn);
11951
- } else {
11952
- m = e.match(pn);
11953
- }
11954
- if (m)
11955
- matchedEntries.push(e);
11956
- }
11957
- }
11958
-
11959
- //console.error('prd2', prefix, entries, remain[0]._glob, matchedEntries)
11960
-
11961
- var len = matchedEntries.length;
11962
- // If there are no matched entries, then nothing matches.
11963
- if (len === 0)
11964
- return cb()
11965
-
11966
- // if this is the last remaining pattern bit, then no need for
11967
- // an additional stat *unless* the user has specified mark or
11968
- // stat explicitly. We know they exist, since readdir returned
11969
- // them.
11970
-
11971
- if (remain.length === 1 && !this.mark && !this.stat) {
11972
- if (!this.matches[index])
11973
- this.matches[index] = Object.create(null);
11974
-
11975
- for (var i = 0; i < len; i ++) {
11976
- var e = matchedEntries[i];
11977
- if (prefix) {
11978
- if (prefix !== '/')
11979
- e = prefix + '/' + e;
11980
- else
11981
- e = prefix + e;
11982
- }
11983
-
11984
- if (e.charAt(0) === '/' && !this.nomount) {
11985
- e = path.join(this.root, e);
11986
- }
11987
- this._emitMatch(index, e);
11988
- }
11989
- // This was the last one, and no stats were needed
11990
- return cb()
11991
- }
11992
-
11993
- // now test all matched entries as stand-ins for that part
11994
- // of the pattern.
11995
- remain.shift();
11996
- for (var i = 0; i < len; i ++) {
11997
- var e = matchedEntries[i];
11998
- if (prefix) {
11999
- if (prefix !== '/')
12000
- e = prefix + '/' + e;
12001
- else
12002
- e = prefix + e;
12003
- }
12004
- this._process([e].concat(remain), index, inGlobStar, cb);
12005
- }
12006
- cb();
12007
- };
12008
-
12009
- Glob.prototype._emitMatch = function (index, e) {
12010
- if (this.aborted)
12011
- return
12012
-
12013
- if (isIgnored(this, e))
12014
- return
12015
-
12016
- if (this.paused) {
12017
- this._emitQueue.push([index, e]);
12018
- return
12019
- }
12020
-
12021
- var abs = isAbsolute(e) ? e : this._makeAbs(e);
12022
-
12023
- if (this.mark)
12024
- e = this._mark(e);
12025
-
12026
- if (this.absolute)
12027
- e = abs;
12028
-
12029
- if (this.matches[index][e])
12030
- return
12031
-
12032
- if (this.nodir) {
12033
- var c = this.cache[abs];
12034
- if (c === 'DIR' || Array.isArray(c))
12035
- return
12036
- }
12037
-
12038
- this.matches[index][e] = true;
12039
-
12040
- var st = this.statCache[abs];
12041
- if (st)
12042
- this.emit('stat', e, st);
12043
-
12044
- this.emit('match', e);
12045
- };
12046
-
12047
- Glob.prototype._readdirInGlobStar = function (abs, cb) {
12048
- if (this.aborted)
12049
- return
12050
-
12051
- // follow all symlinked directories forever
12052
- // just proceed as if this is a non-globstar situation
12053
- if (this.follow)
12054
- return this._readdir(abs, false, cb)
12055
-
12056
- var lstatkey = 'lstat\0' + abs;
12057
- var self = this;
12058
- var lstatcb = inflight(lstatkey, lstatcb_);
12059
-
12060
- if (lstatcb)
12061
- fs.lstat(abs, lstatcb);
12062
-
12063
- function lstatcb_ (er, lstat) {
12064
- if (er && er.code === 'ENOENT')
12065
- return cb()
12066
-
12067
- var isSym = lstat && lstat.isSymbolicLink();
12068
- self.symlinks[abs] = isSym;
12069
-
12070
- // If it's not a symlink or a dir, then it's definitely a regular file.
12071
- // don't bother doing a readdir in that case.
12072
- if (!isSym && lstat && !lstat.isDirectory()) {
12073
- self.cache[abs] = 'FILE';
12074
- cb();
12075
- } else
12076
- self._readdir(abs, false, cb);
12077
- }
12078
- };
12079
-
12080
- Glob.prototype._readdir = function (abs, inGlobStar, cb) {
12081
- if (this.aborted)
12082
- return
12083
-
12084
- cb = inflight('readdir\0'+abs+'\0'+inGlobStar, cb);
12085
- if (!cb)
12086
- return
12087
-
12088
- //console.error('RD %j %j', +inGlobStar, abs)
12089
- if (inGlobStar && !ownProp(this.symlinks, abs))
12090
- return this._readdirInGlobStar(abs, cb)
12091
-
12092
- if (ownProp(this.cache, abs)) {
12093
- var c = this.cache[abs];
12094
- if (!c || c === 'FILE')
12095
- return cb()
12096
-
12097
- if (Array.isArray(c))
12098
- return cb(null, c)
12099
- }
12100
- fs.readdir(abs, readdirCb(this, abs, cb));
12101
- };
12102
-
12103
- function readdirCb (self, abs, cb) {
12104
- return function (er, entries) {
12105
- if (er)
12106
- self._readdirError(abs, er, cb);
12107
- else
12108
- self._readdirEntries(abs, entries, cb);
12109
- }
12110
- }
12111
-
12112
- Glob.prototype._readdirEntries = function (abs, entries, cb) {
12113
- if (this.aborted)
12114
- return
12115
-
12116
- // if we haven't asked to stat everything, then just
12117
- // assume that everything in there exists, so we can avoid
12118
- // having to stat it a second time.
12119
- if (!this.mark && !this.stat) {
12120
- for (var i = 0; i < entries.length; i ++) {
12121
- var e = entries[i];
12122
- if (abs === '/')
12123
- e = abs + e;
12124
- else
12125
- e = abs + '/' + e;
12126
- this.cache[e] = true;
12127
- }
12128
- }
12129
-
12130
- this.cache[abs] = entries;
12131
- return cb(null, entries)
12132
- };
12133
-
12134
- Glob.prototype._readdirError = function (f, er, cb) {
12135
- if (this.aborted)
12136
- return
12137
-
12138
- // handle errors, and cache the information
12139
- switch (er.code) {
12140
- case 'ENOTSUP': // https://github.com/isaacs/node-glob/issues/205
12141
- case 'ENOTDIR': // totally normal. means it *does* exist.
12142
- var abs = this._makeAbs(f);
12143
- this.cache[abs] = 'FILE';
12144
- if (abs === this.cwdAbs) {
12145
- var error = new Error(er.code + ' invalid cwd ' + this.cwd);
12146
- error.path = this.cwd;
12147
- error.code = er.code;
12148
- this.emit('error', error);
12149
- this.abort();
12150
- }
12151
- break
12152
-
12153
- case 'ENOENT': // not terribly unusual
12154
- case 'ELOOP':
12155
- case 'ENAMETOOLONG':
12156
- case 'UNKNOWN':
12157
- this.cache[this._makeAbs(f)] = false;
12158
- break
12159
-
12160
- default: // some unusual error. Treat as failure.
12161
- this.cache[this._makeAbs(f)] = false;
12162
- if (this.strict) {
12163
- this.emit('error', er);
12164
- // If the error is handled, then we abort
12165
- // if not, we threw out of here
12166
- this.abort();
12167
- }
12168
- if (!this.silent)
12169
- console.error('glob error', er);
12170
- break
12171
- }
12172
-
12173
- return cb()
12174
- };
12175
-
12176
- Glob.prototype._processGlobStar = function (prefix, read, abs, remain, index, inGlobStar, cb) {
12177
- var self = this;
12178
- this._readdir(abs, inGlobStar, function (er, entries) {
12179
- self._processGlobStar2(prefix, read, abs, remain, index, inGlobStar, entries, cb);
12180
- });
12181
- };
12182
-
12183
-
12184
- Glob.prototype._processGlobStar2 = function (prefix, read, abs, remain, index, inGlobStar, entries, cb) {
12185
- //console.error('pgs2', prefix, remain[0], entries)
12186
-
12187
- // no entries means not a dir, so it can never have matches
12188
- // foo.txt/** doesn't match foo.txt
12189
- if (!entries)
12190
- return cb()
12191
-
12192
- // test without the globstar, and with every child both below
12193
- // and replacing the globstar.
12194
- var remainWithoutGlobStar = remain.slice(1);
12195
- var gspref = prefix ? [ prefix ] : [];
12196
- var noGlobStar = gspref.concat(remainWithoutGlobStar);
12197
-
12198
- // the noGlobStar pattern exits the inGlobStar state
12199
- this._process(noGlobStar, index, false, cb);
12200
-
12201
- var isSym = this.symlinks[abs];
12202
- var len = entries.length;
12203
-
12204
- // If it's a symlink, and we're in a globstar, then stop
12205
- if (isSym && inGlobStar)
12206
- return cb()
12207
-
12208
- for (var i = 0; i < len; i++) {
12209
- var e = entries[i];
12210
- if (e.charAt(0) === '.' && !this.dot)
12211
- continue
12212
-
12213
- // these two cases enter the inGlobStar state
12214
- var instead = gspref.concat(entries[i], remainWithoutGlobStar);
12215
- this._process(instead, index, true, cb);
12216
-
12217
- var below = gspref.concat(entries[i], remain);
12218
- this._process(below, index, true, cb);
12219
- }
12220
-
12221
- cb();
12222
- };
12223
-
12224
- Glob.prototype._processSimple = function (prefix, index, cb) {
12225
- // XXX review this. Shouldn't it be doing the mounting etc
12226
- // before doing stat? kinda weird?
12227
- var self = this;
12228
- this._stat(prefix, function (er, exists) {
12229
- self._processSimple2(prefix, index, er, exists, cb);
12230
- });
12231
- };
12232
- Glob.prototype._processSimple2 = function (prefix, index, er, exists, cb) {
12233
-
12234
- //console.error('ps2', prefix, exists)
12235
-
12236
- if (!this.matches[index])
12237
- this.matches[index] = Object.create(null);
12238
-
12239
- // If it doesn't exist, then just mark the lack of results
12240
- if (!exists)
12241
- return cb()
12242
-
12243
- if (prefix && isAbsolute(prefix) && !this.nomount) {
12244
- var trail = /[\/\\]$/.test(prefix);
12245
- if (prefix.charAt(0) === '/') {
12246
- prefix = path.join(this.root, prefix);
12247
- } else {
12248
- prefix = path.resolve(this.root, prefix);
12249
- if (trail)
12250
- prefix += '/';
12251
- }
12252
- }
12253
-
12254
- if (process.platform === 'win32')
12255
- prefix = prefix.replace(/\\/g, '/');
12256
-
12257
- // Mark this as a match
12258
- this._emitMatch(index, prefix);
12259
- cb();
12260
- };
12261
-
12262
- // Returns either 'DIR', 'FILE', or false
12263
- Glob.prototype._stat = function (f, cb) {
12264
- var abs = this._makeAbs(f);
12265
- var needDir = f.slice(-1) === '/';
12266
-
12267
- if (f.length > this.maxLength)
12268
- return cb()
12269
-
12270
- if (!this.stat && ownProp(this.cache, abs)) {
12271
- var c = this.cache[abs];
12272
-
12273
- if (Array.isArray(c))
12274
- c = 'DIR';
12275
-
12276
- // It exists, but maybe not how we need it
12277
- if (!needDir || c === 'DIR')
12278
- return cb(null, c)
12279
-
12280
- if (needDir && c === 'FILE')
12281
- return cb()
12282
-
12283
- // otherwise we have to stat, because maybe c=true
12284
- // if we know it exists, but not what it is.
12285
- }
12286
- var stat = this.statCache[abs];
12287
- if (stat !== undefined) {
12288
- if (stat === false)
12289
- return cb(null, stat)
12290
- else {
12291
- var type = stat.isDirectory() ? 'DIR' : 'FILE';
12292
- if (needDir && type === 'FILE')
12293
- return cb()
12294
- else
12295
- return cb(null, type, stat)
12296
- }
12297
- }
12298
-
12299
- var self = this;
12300
- var statcb = inflight('stat\0' + abs, lstatcb_);
12301
- if (statcb)
12302
- fs.lstat(abs, statcb);
12303
-
12304
- function lstatcb_ (er, lstat) {
12305
- if (lstat && lstat.isSymbolicLink()) {
12306
- // If it's a symlink, then treat it as the target, unless
12307
- // the target does not exist, then treat it as a file.
12308
- return fs.stat(abs, function (er, stat) {
12309
- if (er)
12310
- self._stat2(f, abs, null, lstat, cb);
12311
- else
12312
- self._stat2(f, abs, er, stat, cb);
12313
- })
12314
- } else {
12315
- self._stat2(f, abs, er, lstat, cb);
12316
- }
12317
- }
12318
- };
12319
-
12320
- Glob.prototype._stat2 = function (f, abs, er, stat, cb) {
12321
- if (er && (er.code === 'ENOENT' || er.code === 'ENOTDIR')) {
12322
- this.statCache[abs] = false;
12323
- return cb()
12324
- }
12325
-
12326
- var needDir = f.slice(-1) === '/';
12327
- this.statCache[abs] = stat;
12328
-
12329
- if (abs.slice(-1) === '/' && stat && !stat.isDirectory())
12330
- return cb(null, false, stat)
12331
-
12332
- var c = true;
12333
- if (stat)
12334
- c = stat.isDirectory() ? 'DIR' : 'FILE';
12335
- this.cache[abs] = this.cache[abs] || c;
12336
-
12337
- if (needDir && c === 'FILE')
12338
- return cb()
12339
-
12340
- return cb(null, c, stat)
12341
- };
12342
- return glob_1;
12343
- }
12344
-
12345
- var globExports = requireGlob();
12346
- var glob = /*@__PURE__*/getDefaultExportFromCjs(globExports);
12347
-
12348
- const getGlobPattern = (basePath) => {
12349
- const newPath = require$$1$1.posix.normalize(basePath);
12350
- return require$$1$1.join(newPath, "**/*.@(js|mjs).map");
12351
- };
12352
- const decomposePath = (options, sourcemapFilePath) => {
12353
- if (require$$1$1.extname(sourcemapFilePath) !== ".map") {
12354
- throw new Error(`The file ${chalk.green.bold(sourcemapFilePath)} is not a sourcemap.`);
12355
- }
12356
- const minifiedFilePath = sourcemapFilePath.replace(/\.map$/, "");
12357
- const relativePath = minifiedFilePath.replace(options.basePath, "");
12358
- const minifiedUrl = options.minifiedPathPrefix ? require$$1$1.join(options.minifiedPathPrefix, relativePath) : relativePath;
12359
- return {
12360
- minifiedFilePath,
12361
- minifiedUrl,
12362
- relativePath
12363
- };
12364
- };
12365
- const getSourcemapsFiles = (options) => {
12366
- const globPattern = getGlobPattern(options.basePath);
12367
- const sourcemapFilesList = glob.sync(globPattern);
12368
- const sourcemapFiles = sourcemapFilesList.map((sourcemapFilePath) => {
12369
- return {
12370
- ...decomposePath(options, sourcemapFilePath),
12371
- sourcemapFilePath,
12372
- minifiedPathPrefix: options.minifiedPathPrefix
12373
- };
12374
- });
12375
- return sourcemapFiles;
12376
- };
12377
-
12378
- var retry$4 = {};
12379
-
12380
- function RetryOperation(timeouts, options) {
12381
- // Compatibility for the old (timeouts, retryForever) signature
12382
- if (typeof options === 'boolean') {
12383
- options = { forever: options };
12384
- }
12385
-
12386
- this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
12387
- this._timeouts = timeouts;
12388
- this._options = options || {};
12389
- this._maxRetryTime = options && options.maxRetryTime || Infinity;
12390
- this._fn = null;
12391
- this._errors = [];
12392
- this._attempts = 1;
12393
- this._operationTimeout = null;
12394
- this._operationTimeoutCb = null;
12395
- this._timeout = null;
12396
- this._operationStart = null;
12397
- this._timer = null;
12398
-
12399
- if (this._options.forever) {
12400
- this._cachedTimeouts = this._timeouts.slice(0);
12401
- }
12402
- }
12403
- var retry_operation = RetryOperation;
12404
-
12405
- RetryOperation.prototype.reset = function() {
12406
- this._attempts = 1;
12407
- this._timeouts = this._originalTimeouts.slice(0);
12408
- };
12409
-
12410
- RetryOperation.prototype.stop = function() {
12411
- if (this._timeout) {
12412
- clearTimeout(this._timeout);
12413
- }
12414
- if (this._timer) {
12415
- clearTimeout(this._timer);
12416
- }
12417
-
12418
- this._timeouts = [];
12419
- this._cachedTimeouts = null;
12420
- };
12421
-
12422
- RetryOperation.prototype.retry = function(err) {
12423
- if (this._timeout) {
12424
- clearTimeout(this._timeout);
12425
- }
12426
-
12427
- if (!err) {
12428
- return false;
12429
- }
12430
- var currentTime = new Date().getTime();
12431
- if (err && currentTime - this._operationStart >= this._maxRetryTime) {
12432
- this._errors.push(err);
12433
- this._errors.unshift(new Error('RetryOperation timeout occurred'));
12434
- return false;
12435
- }
12436
-
12437
- this._errors.push(err);
12438
-
12439
- var timeout = this._timeouts.shift();
12440
- if (timeout === undefined) {
12441
- if (this._cachedTimeouts) {
12442
- // retry forever, only keep last error
12443
- this._errors.splice(0, this._errors.length - 1);
12444
- timeout = this._cachedTimeouts.slice(-1);
12445
- } else {
12446
- return false;
12447
- }
12448
- }
12449
-
12450
- var self = this;
12451
- this._timer = setTimeout(function() {
12452
- self._attempts++;
12453
-
12454
- if (self._operationTimeoutCb) {
12455
- self._timeout = setTimeout(function() {
12456
- self._operationTimeoutCb(self._attempts);
12457
- }, self._operationTimeout);
12458
-
12459
- if (self._options.unref) {
12460
- self._timeout.unref();
12461
- }
12462
- }
12463
-
12464
- self._fn(self._attempts);
12465
- }, timeout);
12466
-
12467
- if (this._options.unref) {
12468
- this._timer.unref();
12469
- }
12470
-
12471
- return true;
12472
- };
12473
-
12474
- RetryOperation.prototype.attempt = function(fn, timeoutOps) {
12475
- this._fn = fn;
12476
-
12477
- if (timeoutOps) {
12478
- if (timeoutOps.timeout) {
12479
- this._operationTimeout = timeoutOps.timeout;
12480
- }
12481
- if (timeoutOps.cb) {
12482
- this._operationTimeoutCb = timeoutOps.cb;
12483
- }
12484
- }
12485
-
12486
- var self = this;
12487
- if (this._operationTimeoutCb) {
12488
- this._timeout = setTimeout(function() {
12489
- self._operationTimeoutCb();
12490
- }, self._operationTimeout);
12491
- }
12492
-
12493
- this._operationStart = new Date().getTime();
12494
-
12495
- this._fn(this._attempts);
12496
- };
12497
-
12498
- RetryOperation.prototype.try = function(fn) {
12499
- console.log('Using RetryOperation.try() is deprecated');
12500
- this.attempt(fn);
12501
- };
12502
-
12503
- RetryOperation.prototype.start = function(fn) {
12504
- console.log('Using RetryOperation.start() is deprecated');
12505
- this.attempt(fn);
12506
- };
12507
-
12508
- RetryOperation.prototype.start = RetryOperation.prototype.try;
12509
-
12510
- RetryOperation.prototype.errors = function() {
12511
- return this._errors;
12512
- };
9231
+ RetryOperation.prototype.errors = function() {
9232
+ return this._errors;
9233
+ };
12513
9234
 
12514
9235
  RetryOperation.prototype.attempts = function() {
12515
9236
  return this._attempts;
@@ -13558,9 +10279,9 @@ const getPayload = async (sourcemap, metadata, prefix, git) => {
13558
10279
  {
13559
10280
  files: git.trackedFilesMatcher.matchSourcemap(
13560
10281
  sourcemap.sourcemapFilePath,
13561
- () => {
10282
+ (reason) => {
13562
10283
  warnings.push(
13563
- `No tracked files found for sources contained in ${sourcemap.sourcemapFilePath}`
10284
+ `No tracked files found for sources contained in ${sourcemap.sourcemapFilePath}: "${reason}"`
13564
10285
  );
13565
10286
  }
13566
10287
  ),
@@ -13642,11 +10363,11 @@ const doRequest = async (url, getData2, onRetry) => {
13642
10363
  );
13643
10364
  };
13644
10365
  const getFile = async (path, options) => {
13645
- if (typeof fs$l.openAsBlob === "function") {
13646
- const blob = await fs$l.openAsBlob(path, { type: options.contentType });
10366
+ if (typeof fs$j.openAsBlob === "function") {
10367
+ const blob = await fs$j.openAsBlob(path, { type: options.contentType });
13647
10368
  return new File([blob], options.filename);
13648
10369
  } else {
13649
- const stream = Readable.toWeb(fs$l.createReadStream(path));
10370
+ const stream = Readable.toWeb(fs$j.createReadStream(path));
13650
10371
  const blob = await new Response(stream).blob();
13651
10372
  const file = new File([blob], options.filename, { type: options.contentType });
13652
10373
  return file;
@@ -13688,8 +10409,14 @@ const upload = async (payloads, options, context, log) => {
13688
10409
  };
13689
10410
  for (const payload of payloads) {
13690
10411
  const metadata = {
13691
- sourcemap: payload.content.get("source_map")?.path,
13692
- file: payload.content.get("minified_file")?.path
10412
+ sourcemap: payload.content.get("source_map")?.path.replace(
10413
+ context.outputDir,
10414
+ "."
10415
+ ),
10416
+ file: payload.content.get("minified_file")?.path.replace(
10417
+ context.outputDir,
10418
+ "."
10419
+ )
13693
10420
  };
13694
10421
  log(`Queuing ${green(metadata.sourcemap)} | ${green(metadata.file)}`);
13695
10422
  queue.add(async () => {
@@ -13715,7 +10442,7 @@ const sendSourcemaps = async (sourcemaps, options, context, log) => {
13715
10442
  git_repository_url: context.git?.remote,
13716
10443
  git_commit_sha: context.git?.hash,
13717
10444
  plugin_version: context.version,
13718
- project_path: options.basePath,
10445
+ project_path: context.outputDir,
13719
10446
  service: options.service,
13720
10447
  type: "js_sourcemap",
13721
10448
  version: options.releaseVersion
@@ -13746,7 +10473,7 @@ const sendSourcemaps = async (sourcemaps, options, context, log) => {
13746
10473
  const uploadSourcemaps = async (options, context, log) => {
13747
10474
  const green = chalk.green.bold;
13748
10475
  const configurationString = Object.entries(options.sourcemaps).map(([key, value]) => ` - ${key}: ${green(value.toString())}`).join("\n");
13749
- const sourcemaps = getSourcemapsFiles(options.sourcemaps);
10476
+ const sourcemaps = getSourcemapsFiles(options.sourcemaps, context);
13750
10477
  const summary = defaultOutdent`
13751
10478
  Uploading ${green(sourcemaps.length.toString())} sourcemaps with configuration:
13752
10479
  ${configurationString}
@@ -13792,9 +10519,6 @@ const validateSourcemapsOptions = (config) => {
13792
10519
  errors: []
13793
10520
  };
13794
10521
  if (validatedOptions.sourcemaps) {
13795
- if (!validatedOptions.sourcemaps.basePath) {
13796
- toReturn.errors.push(`${red("sourcemaps.basePath")} is required.`);
13797
- }
13798
10522
  if (!validatedOptions.sourcemaps.releaseVersion) {
13799
10523
  toReturn.errors.push(`${red("sourcemaps.releaseVersion")} is required.`);
13800
10524
  }
@@ -14416,7 +11140,7 @@ function clone$1 (obj) {
14416
11140
  return copy
14417
11141
  }
14418
11142
 
14419
- var fs$h = fs$l;
11143
+ var fs$h = fs$j;
14420
11144
  var polyfills = polyfills$1;
14421
11145
  var legacy = legacyStreams;
14422
11146
  var clone = clone_1;
@@ -14502,7 +11226,7 @@ if (!fs$h[gracefulQueue]) {
14502
11226
  if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || '')) {
14503
11227
  process.on('exit', function() {
14504
11228
  debug(fs$h[gracefulQueue]);
14505
- require$$6.equal(fs$h[gracefulQueue].length, 0);
11229
+ require$$5.equal(fs$h[gracefulQueue].length, 0);
14506
11230
  });
14507
11231
  }
14508
11232
  }
@@ -15674,7 +12398,7 @@ var copy$1 = {
15674
12398
 
15675
12399
  const fs$a = gracefulFs;
15676
12400
  const path$a = require$$1$1;
15677
- const assert = require$$6;
12401
+ const assert = require$$5;
15678
12402
 
15679
12403
  const isWindows = (process.platform === 'win32');
15680
12404
 
@@ -15994,7 +12718,7 @@ var remove$3 = {
15994
12718
  };
15995
12719
 
15996
12720
  const u$7 = universalify.fromCallback;
15997
- const fs$9 = fs$l;
12721
+ const fs$9 = fs$j;
15998
12722
  const path$9 = require$$1$1;
15999
12723
  const mkdir$5 = mkdirs_1;
16000
12724
  const remove$2 = remove$3;
@@ -16364,7 +13088,7 @@ var _fs;
16364
13088
  try {
16365
13089
  _fs = gracefulFs;
16366
13090
  } catch (_) {
16367
- _fs = fs$l;
13091
+ _fs = fs$j;
16368
13092
  }
16369
13093
 
16370
13094
  function readFile (file, options, callback) {
@@ -16822,7 +13546,7 @@ var output$1 = {
16822
13546
 
16823
13547
  // Export fs.promises as a getter property so that we don't trigger
16824
13548
  // ExperimentalWarning before fs.promises is actually accessed.
16825
- const fs = fs$l;
13549
+ const fs = fs$j;
16826
13550
  if (Object.getOwnPropertyDescriptor(fs, 'promises')) {
16827
13551
  Object.defineProperty(module.exports, 'promises', {
16828
13552
  get () { return fs.promises }
@@ -28998,7 +25722,7 @@ function remapping(input, loader, options) {
28998
25722
  return new SourceMap(traceMappings(tree), opts);
28999
25723
  }
29000
25724
  function normalizeAbsolutePath(path6) {
29001
- if (isAbsolute$1(path6))
25725
+ if (isAbsolute(path6))
29002
25726
  return normalize(path6);
29003
25727
  else
29004
25728
  return path6;
@@ -29123,9 +25847,9 @@ function createBuildContext(initialOptions) {
29123
25847
  if (initialOptions.outdir && emittedFile.source && outFileName) {
29124
25848
  const outPath = require$$1$1.resolve(initialOptions.outdir, outFileName);
29125
25849
  const outDir = require$$1$1.dirname(outPath);
29126
- if (!fs$l.existsSync(outDir))
29127
- fs$l.mkdirSync(outDir, { recursive: true });
29128
- fs$l.writeFileSync(outPath, emittedFile.source);
25850
+ if (!fs$j.existsSync(outDir))
25851
+ fs$j.mkdirSync(outDir, { recursive: true });
25852
+ fs$j.writeFileSync(outPath, emittedFile.source);
29129
25853
  }
29130
25854
  },
29131
25855
  getWatchFiles() {
@@ -29237,7 +25961,7 @@ function getEsbuildPlugin(factory) {
29237
25961
  return result.contents;
29238
25962
  if (fsContentsCache)
29239
25963
  return fsContentsCache;
29240
- return fsContentsCache = await fs$l.promises.readFile(args.path, "utf8");
25964
+ return fsContentsCache = await fs$j.promises.readFile(args.path, "utf8");
29241
25965
  }
29242
25966
  };
29243
25967
  const _result = await onTransformCb(newArgs);
@@ -29818,8 +26542,8 @@ function getRspackPlugin(factory) {
29818
26542
  });
29819
26543
  }
29820
26544
  if (plugin.writeBundle) {
29821
- compiler.hooks.afterEmit.tap(plugin.name, () => {
29822
- plugin.writeBundle();
26545
+ compiler.hooks.afterEmit.tapPromise(plugin.name, async () => {
26546
+ await plugin.writeBundle();
29823
26547
  });
29824
26548
  }
29825
26549
  }
@@ -29988,7 +26712,7 @@ function getWebpackPlugin(factory) {
29988
26712
  const isExternal = typeof resolveIdResult === "string" ? false : resolveIdResult.external === true;
29989
26713
  if (isExternal)
29990
26714
  externalModules.add(resolved);
29991
- if (!fs$l.existsSync(resolved)) {
26715
+ if (!fs$j.existsSync(resolved)) {
29992
26716
  resolved = normalizeAbsolutePath(
29993
26717
  plugin.__virtualModulePrefix + encodeURIComponent(resolved)
29994
26718
  // URI encode id so webpack doesn't think it's part of the path
@@ -30060,8 +26784,8 @@ function getWebpackPlugin(factory) {
30060
26784
  });
30061
26785
  }
30062
26786
  if (plugin.writeBundle) {
30063
- compiler.hooks.afterEmit.tap(plugin.name, () => {
30064
- plugin.writeBundle();
26787
+ compiler.hooks.afterEmit.tapPromise(plugin.name, async () => {
26788
+ await plugin.writeBundle();
30065
26789
  });
30066
26790
  }
30067
26791
  }
@@ -30130,7 +26854,7 @@ const buildPluginFactory = ({
30130
26854
 
30131
26855
  var name = "@datadog/webpack-plugin";
30132
26856
  var packageManager = "yarn@4.0.2";
30133
- var version = "2.0.2-dev-6";
26857
+ var version = "2.0.2-dev-8";
30134
26858
  var license = "MIT";
30135
26859
  var author = "Datadog";
30136
26860
  var description = "Datadog Webpack Plugin";
@@ -30186,8 +26910,8 @@ var devDependencies = {
30186
26910
  "@rollup/plugin-node-resolve": "15.2.3",
30187
26911
  "@types/babel__core": "^7",
30188
26912
  "@types/babel__preset-env": "^7",
30189
- esbuild: "0.20.2",
30190
- rollup: "4.17.1",
26913
+ esbuild: "0.21.5",
26914
+ rollup: "4.18.0",
30191
26915
  "rollup-plugin-dts": "6.1.0",
30192
26916
  "rollup-plugin-esbuild": "6.1.1",
30193
26917
  typescript: "5.4.3"