archiver-node 8.0.2 → 8.0.4

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,103 +1,98 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
- // If the importer is in node compatibility mode or this is not an ESM
21
- // file that has been converted to a CommonJS file using a Babel-
22
- // compatible transform (i.e. "__esModule" has not been set), then set
23
- // "default" to the CommonJS "module.exports" for node compatibility.
24
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
- mod
26
- ));
27
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
- var zip_exports = {};
29
- __export(zip_exports, {
30
- default: () => Zip
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
31
5
  });
32
- module.exports = __toCommonJS(zip_exports);
33
- var import_zip_stream = __toESM(require("zip-stream"), 1);
34
- /**
35
- * ZIP Format Plugin
36
- *
37
- * @module plugins/zip
38
- * @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE}
39
- * @copyright (c) 2012-2014 Chris Talkington, contributors.
6
+ exports["default"] = void 0;
7
+ var _zipStream = _interopRequireDefault(require("zip-stream"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
9
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
10
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
11
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
12
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
13
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
14
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
15
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
16
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
17
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
18
+ /**
19
+ * ZIP Format Plugin
20
+ *
21
+ * @module plugins/zip
22
+ * @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE}
23
+ * @copyright (c) 2012-2014 Chris Talkington, contributors.
40
24
  */
41
- class Zip {
42
- /**
43
- * @constructor
44
- * @param {ZipOptions} [options]
45
- * @param {String} [options.comment] Sets the zip archive comment.
46
- * @param {Boolean} [options.forceLocalTime=false] Forces the archive to contain local file times instead of UTC.
47
- * @param {Boolean} [options.forceZip64=false] Forces the archive to contain ZIP64 headers.
48
- * @param {Boolean} [options.namePrependSlash=false] Prepends a forward slash to archive file paths.
49
- * @param {Boolean} [options.store=false] Sets the compression method to STORE.
50
- * @param {Object} [options.zlib] Passed to [zlib]{@link https://nodejs.org/api/zlib.html#zlib_class_options}
25
+ var Zip = exports["default"] = /*#__PURE__*/function () {
26
+ /**
27
+ * @constructor
28
+ * @param {ZipOptions} [options]
29
+ * @param {String} [options.comment] Sets the zip archive comment.
30
+ * @param {Boolean} [options.forceLocalTime=false] Forces the archive to contain local file times instead of UTC.
31
+ * @param {Boolean} [options.forceZip64=false] Forces the archive to contain ZIP64 headers.
32
+ * @param {Boolean} [options.namePrependSlash=false] Prepends a forward slash to archive file paths.
33
+ * @param {Boolean} [options.store=false] Sets the compression method to STORE.
34
+ * @param {Object} [options.zlib] Passed to [zlib]{@link https://nodejs.org/api/zlib.html#zlib_class_options}
51
35
  */
52
- constructor(options) {
53
- options = this.options = {
36
+ function Zip(options) {
37
+ _classCallCheck(this, Zip);
38
+ options = this.options = _objectSpread({
54
39
  comment: "",
55
40
  forceUTC: false,
56
41
  namePrependSlash: false,
57
- store: false,
58
- ...options
59
- };
60
- this.engine = new import_zip_stream.default(options);
61
- }
62
- /**
63
- * @param {(Buffer|Stream)} source
64
- * @param {ZipEntryData} data
65
- * @param {String} data.name Sets the entry name including internal path.
66
- * @param {(String|Date)} [data.date=NOW()] Sets the entry date.
67
- * @param {Number} [data.mode=D:0755/F:0644] Sets the entry permissions.
68
- * @param {String} [data.prefix] Sets a path prefix for the entry name. Useful
69
- * when working with methods like `directory` or `glob`.
70
- * @param {fs.Stats} [data.stats] Sets the fs stat data for this entry allowing
71
- * for reduction of fs stat calls when stat data is already known.
72
- * @param {Boolean} [data.store=ZipOptions.store] Sets the compression method to STORE.
73
- * @param {Function} callback
74
- * @return void
75
- */
76
- append(source, data, callback) {
77
- this.engine.entry(source, data, callback);
78
- }
79
- /**
80
- * @return void
81
- */
82
- finalize() {
83
- this.engine.finalize();
42
+ store: false
43
+ }, options);
44
+ this.engine = new _zipStream["default"](options);
84
45
  }
85
- /**
86
- * @return this.engine
46
+ /**
47
+ * @param {(Buffer|Stream)} source
48
+ * @param {ZipEntryData} data
49
+ * @param {String} data.name Sets the entry name including internal path.
50
+ * @param {(String|Date)} [data.date=NOW()] Sets the entry date.
51
+ * @param {Number} [data.mode=D:0755/F:0644] Sets the entry permissions.
52
+ * @param {String} [data.prefix] Sets a path prefix for the entry name. Useful
53
+ * when working with methods like `directory` or `glob`.
54
+ * @param {fs.Stats} [data.stats] Sets the fs stat data for this entry allowing
55
+ * for reduction of fs stat calls when stat data is already known.
56
+ * @param {Boolean} [data.store=ZipOptions.store] Sets the compression method to STORE.
57
+ * @param {Function} callback
58
+ * @return void
87
59
  */
88
- on() {
89
- return this.engine.on.apply(this.engine, arguments);
90
- }
91
- /**
92
- * @return this.engine
93
- */
94
- pipe() {
95
- return this.engine.pipe.apply(this.engine, arguments);
96
- }
97
- /**
98
- * @return this.engine
99
- */
100
- unpipe() {
101
- return this.engine.unpipe.apply(this.engine, arguments);
102
- }
103
- }
60
+ return _createClass(Zip, [{
61
+ key: "append",
62
+ value: function append(source, data, callback) {
63
+ this.engine.entry(source, data, callback);
64
+ }
65
+ /**
66
+ * @return void
67
+ */
68
+ }, {
69
+ key: "finalize",
70
+ value: function finalize() {
71
+ this.engine.finalize();
72
+ }
73
+ /**
74
+ * @return this.engine
75
+ */
76
+ }, {
77
+ key: "on",
78
+ value: function on() {
79
+ return this.engine.on.apply(this.engine, arguments);
80
+ }
81
+ /**
82
+ * @return this.engine
83
+ */
84
+ }, {
85
+ key: "pipe",
86
+ value: function pipe() {
87
+ return this.engine.pipe.apply(this.engine, arguments);
88
+ }
89
+ /**
90
+ * @return this.engine
91
+ */
92
+ }, {
93
+ key: "unpipe",
94
+ value: function unpipe() {
95
+ return this.engine.unpipe.apply(this.engine, arguments);
96
+ }
97
+ }]);
98
+ }();
@@ -0,0 +1,382 @@
1
+ "use strict";
2
+
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.readdirGlob = exports.ReaddirGlob = void 0;
8
+ var fs = _interopRequireWildcard(require("fs"));
9
+ var _events = require("events");
10
+ var _minimatch = require("minimatch");
11
+ var _path = require("path");
12
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t5 in e) "default" !== _t5 && {}.hasOwnProperty.call(e, _t5) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t5)) && (i.get || i.set) ? o(f, _t5, i) : f[_t5] = e[_t5]); return f; })(e, t); }
13
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
14
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
15
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
16
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
17
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
18
+ function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
19
+ function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
20
+ function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
21
+ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
22
+ function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
23
+ function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
24
+ function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
25
+ function _regeneratorValues(e) { if (null != e) { var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"], r = 0; if (t) return t.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) return { next: function next() { return e && r >= e.length && (e = void 0), { value: e && e[r++], done: !e }; } }; } throw new TypeError(_typeof(e) + " is not iterable"); }
26
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
27
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
28
+ function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
29
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
30
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
31
+ function _wrapAsyncGenerator(e) { return function () { return new AsyncGenerator(e.apply(this, arguments)); }; }
32
+ function AsyncGenerator(e) { var r, t; function resume(r, t) { try { var n = e[r](t), o = n.value, u = o instanceof _OverloadYield; Promise.resolve(u ? o.v : o).then(function (t) { if (u) { var i = "return" === r ? "return" : "next"; if (!o.k || t.done) return resume(i, t); t = e[i](t).value; } settle(n.done ? "return" : "normal", t); }, function (e) { resume("throw", e); }); } catch (e) { settle("throw", e); } } function settle(e, n) { switch (e) { case "return": r.resolve({ value: n, done: !0 }); break; case "throw": r.reject(n); break; default: r.resolve({ value: n, done: !1 }); } (r = r.next) ? resume(r.key, r.arg) : t = null; } this._invoke = function (e, n) { return new Promise(function (o, u) { var i = { key: e, arg: n, resolve: o, reject: u, next: null }; t ? t = t.next = i : (r = t = i, resume(e, n)); }); }, "function" != typeof e["return"] && (this["return"] = void 0); }
33
+ AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator || "@@asyncIterator"] = function () { return this; }, AsyncGenerator.prototype.next = function (e) { return this._invoke("next", e); }, AsyncGenerator.prototype["throw"] = function (e) { return this._invoke("throw", e); }, AsyncGenerator.prototype["return"] = function (e) { return this._invoke("return", e); };
34
+ function _awaitAsyncGenerator(e) { return new _OverloadYield(e, 0); }
35
+ function _asyncGeneratorDelegate(t) { var e = {}, n = !1; function pump(e, r) { return n = !0, r = new Promise(function (n) { n(t[e](r)); }), { done: !1, value: new _OverloadYield(r, 1) }; } return e["undefined" != typeof Symbol && Symbol.iterator || "@@iterator"] = function () { return this; }, e.next = function (t) { return n ? (n = !1, t) : pump("next", t); }, "function" == typeof t["throw"] && (e["throw"] = function (t) { if (n) throw n = !1, t; return pump("throw", t); }), "function" == typeof t["return"] && (e["return"] = function (t) { return n ? (n = !1, t) : pump("return", t); }), e; }
36
+ function _OverloadYield(e, d) { this.v = e, this.k = d; }
37
+ function _asyncIterator(r) { var n, t, o, e = 2; for ("undefined" != typeof Symbol && (t = Symbol.asyncIterator, o = Symbol.iterator); e--;) { if (t && null != (n = r[t])) return n.call(r); if (o && null != (n = r[o])) return new AsyncFromSyncIterator(n.call(r)); t = "@@asyncIterator", o = "@@iterator"; } throw new TypeError("Object is not async iterable"); }
38
+ function AsyncFromSyncIterator(r) { function AsyncFromSyncIteratorContinuation(r) { if (Object(r) !== r) return Promise.reject(new TypeError(r + " is not an object.")); var n = r.done; return Promise.resolve(r.value).then(function (r) { return { value: r, done: n }; }); } return AsyncFromSyncIterator = function AsyncFromSyncIterator(r) { this.s = r, this.n = r.next; }, AsyncFromSyncIterator.prototype = { s: null, n: null, next: function next() { return AsyncFromSyncIteratorContinuation(this.n.apply(this.s, arguments)); }, "return": function _return(r) { var n = this.s["return"]; return void 0 === n ? Promise.resolve({ value: r, done: !0 }) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); }, "throw": function _throw(r) { var n = this.s["return"]; return void 0 === n ? Promise.reject(r) : AsyncFromSyncIteratorContinuation(n.apply(this.s, arguments)); } }, new AsyncFromSyncIterator(r); } // `readdir-glob` has different exports in `esm` and `cjs`:
39
+ // in `esm` it's a named export but in `cjs` it's a default export.
40
+ // https://github.com/Yqnn/node-readdir-glob/issues/28
41
+ // As a result, this package's code can't be transpiled properly.
42
+ // Copy-pasted `readdir-glob` code here to fix that.
43
+ // Converted TypeScript to Javascript on TypeScript website:
44
+ // https://www.typescriptlang.org/play/?target=9#
45
+ function readdir(dir, strict) {
46
+ return new Promise(function (resolve, reject) {
47
+ fs.readdir(dir, {
48
+ withFileTypes: true
49
+ }, function (err, files) {
50
+ if (err) {
51
+ switch (err.code) {
52
+ case 'ENOTDIR':
53
+ // Not a directory
54
+ if (strict) {
55
+ reject(err);
56
+ } else {
57
+ resolve([]);
58
+ }
59
+ break;
60
+ case 'ENOTSUP': // Operation not supported
61
+ case 'ENOENT': // No such file or directory
62
+ case 'ENAMETOOLONG': // Filename too long
63
+ case 'UNKNOWN':
64
+ resolve([]);
65
+ break;
66
+ case 'ELOOP': // Too many levels of symbolic links
67
+ default:
68
+ reject(err);
69
+ break;
70
+ }
71
+ } else {
72
+ resolve(files);
73
+ }
74
+ });
75
+ });
76
+ }
77
+ function getStat(file, followSymlinks) {
78
+ return new Promise(function (resolve) {
79
+ var statFunc = followSymlinks ? fs.stat : fs.lstat;
80
+ statFunc(file, function (err, stats) {
81
+ if (err) {
82
+ switch (err.code) {
83
+ case 'ENOENT':
84
+ if (followSymlinks) {
85
+ // Fallback to lstat to handle broken links as files
86
+ resolve(getStat(file, false));
87
+ } else {
88
+ resolve(null);
89
+ }
90
+ break;
91
+ default:
92
+ resolve(null);
93
+ break;
94
+ }
95
+ } else {
96
+ resolve(stats);
97
+ }
98
+ });
99
+ });
100
+ }
101
+ function exploreWalkAsync(_x, _x2, _x3, _x4, _x5, _x6) {
102
+ return _exploreWalkAsync.apply(this, arguments);
103
+ }
104
+ function _exploreWalkAsync() {
105
+ _exploreWalkAsync = _wrapAsyncGenerator(/*#__PURE__*/_regenerator().m(function _callee(dir, path, followSymlinks, useStat, shouldSkip, strict) {
106
+ var files, _iterator, _step, file, name, filename, relative, absolute, stat, _yield$_awaitAsyncGen, _t, _t2, _t3, _t4;
107
+ return _regenerator().w(function (_context) {
108
+ while (1) switch (_context.p = _context.n) {
109
+ case 0:
110
+ _context.n = 1;
111
+ return _awaitAsyncGenerator(readdir(path + dir, strict));
112
+ case 1:
113
+ files = _context.v;
114
+ _iterator = _createForOfIteratorHelper(files);
115
+ _context.p = 2;
116
+ _iterator.s();
117
+ case 3:
118
+ if ((_step = _iterator.n()).done) {
119
+ _context.n = 13;
120
+ break;
121
+ }
122
+ file = _step.value;
123
+ name = file.name;
124
+ filename = dir + '/' + name;
125
+ relative = filename.slice(1); // Remove the leading /
126
+ absolute = path + '/' + relative;
127
+ stat = file;
128
+ if (!(useStat || followSymlinks)) {
129
+ _context.n = 8;
130
+ break;
131
+ }
132
+ _context.n = 4;
133
+ return _awaitAsyncGenerator(getStat(absolute, followSymlinks));
134
+ case 4:
135
+ _t2 = _yield$_awaitAsyncGen = _context.v;
136
+ _t = _t2 !== null;
137
+ if (!_t) {
138
+ _context.n = 5;
139
+ break;
140
+ }
141
+ _t = _yield$_awaitAsyncGen !== void 0;
142
+ case 5:
143
+ if (!_t) {
144
+ _context.n = 6;
145
+ break;
146
+ }
147
+ _t3 = _yield$_awaitAsyncGen;
148
+ _context.n = 7;
149
+ break;
150
+ case 6:
151
+ _t3 = stat;
152
+ case 7:
153
+ stat = _t3;
154
+ case 8:
155
+ if (!stat.isDirectory()) {
156
+ _context.n = 11;
157
+ break;
158
+ }
159
+ if (shouldSkip(relative)) {
160
+ _context.n = 10;
161
+ break;
162
+ }
163
+ _context.n = 9;
164
+ return {
165
+ relative: relative,
166
+ absolute: absolute,
167
+ stat: stat
168
+ };
169
+ case 9:
170
+ return _context.d(_regeneratorValues(_asyncGeneratorDelegate(_asyncIterator(exploreWalkAsync(filename, path, followSymlinks, useStat, shouldSkip, false)), _awaitAsyncGenerator)), 10);
171
+ case 10:
172
+ _context.n = 12;
173
+ break;
174
+ case 11:
175
+ _context.n = 12;
176
+ return {
177
+ relative: relative,
178
+ absolute: absolute,
179
+ stat: stat
180
+ };
181
+ case 12:
182
+ _context.n = 3;
183
+ break;
184
+ case 13:
185
+ _context.n = 15;
186
+ break;
187
+ case 14:
188
+ _context.p = 14;
189
+ _t4 = _context.v;
190
+ _iterator.e(_t4);
191
+ case 15:
192
+ _context.p = 15;
193
+ _iterator.f();
194
+ return _context.f(15);
195
+ case 16:
196
+ return _context.a(2);
197
+ }
198
+ }, _callee, null, [[2, 14, 15, 16]]);
199
+ }));
200
+ return _exploreWalkAsync.apply(this, arguments);
201
+ }
202
+ function explore(_x7, _x8, _x9, _x0) {
203
+ return _explore.apply(this, arguments);
204
+ }
205
+ function _explore() {
206
+ _explore = _wrapAsyncGenerator(/*#__PURE__*/_regenerator().m(function _callee2(path, followSymlinks, useStat, shouldSkip) {
207
+ return _regenerator().w(function (_context2) {
208
+ while (1) switch (_context2.n) {
209
+ case 0:
210
+ return _context2.d(_regeneratorValues(_asyncGeneratorDelegate(_asyncIterator(exploreWalkAsync('', path, followSymlinks, useStat, shouldSkip, true)), _awaitAsyncGenerator)), 1);
211
+ case 1:
212
+ return _context2.a(2);
213
+ }
214
+ }, _callee2);
215
+ }));
216
+ return _explore.apply(this, arguments);
217
+ }
218
+ function readOptions(options) {
219
+ return {
220
+ pattern: options.pattern,
221
+ dot: !!options.dot,
222
+ noglobstar: !!options.noglobstar,
223
+ matchBase: !!options.matchBase,
224
+ nocase: !!options.nocase,
225
+ ignore: options.ignore,
226
+ skip: options.skip,
227
+ follow: !!options.follow,
228
+ stat: !!options.stat,
229
+ nodir: !!options.nodir,
230
+ mark: !!options.mark,
231
+ silent: !!options.silent,
232
+ absolute: !!options.absolute
233
+ };
234
+ }
235
+ var ReaddirGlob = exports.ReaddirGlob = /*#__PURE__*/function (_EventEmitter) {
236
+ function ReaddirGlob(cwd, options, cb) {
237
+ var _this;
238
+ _classCallCheck(this, ReaddirGlob);
239
+ _this = _callSuper(this, ReaddirGlob);
240
+ if (typeof options === 'function') {
241
+ cb = options;
242
+ options = undefined;
243
+ }
244
+ _this.options = readOptions(options || {});
245
+ _this.matchers = [];
246
+ if (_this.options.pattern) {
247
+ var matchers = Array.isArray(_this.options.pattern) ? _this.options.pattern : [_this.options.pattern];
248
+ _this.matchers = matchers.map(function (m) {
249
+ return new _minimatch.Minimatch(m, {
250
+ dot: _this.options.dot,
251
+ noglobstar: _this.options.noglobstar,
252
+ matchBase: _this.options.matchBase,
253
+ nocase: _this.options.nocase
254
+ });
255
+ });
256
+ }
257
+ _this.ignoreMatchers = [];
258
+ if (_this.options.ignore) {
259
+ var ignorePatterns = Array.isArray(_this.options.ignore) ? _this.options.ignore : [_this.options.ignore];
260
+ _this.ignoreMatchers = ignorePatterns.map(function (ignore) {
261
+ return new _minimatch.Minimatch(ignore, {
262
+ dot: true
263
+ });
264
+ });
265
+ }
266
+ _this.skipMatchers = [];
267
+ if (_this.options.skip) {
268
+ var skipPatterns = Array.isArray(_this.options.skip) ? _this.options.skip : [_this.options.skip];
269
+ _this.skipMatchers = skipPatterns.map(function (skip) {
270
+ return new _minimatch.Minimatch(skip, {
271
+ dot: true
272
+ });
273
+ });
274
+ }
275
+ _this.iterator = explore((0, _path.resolve)(cwd || '.'), _this.options.follow, _this.options.stat, _this._shouldSkipDirectory.bind(_this));
276
+ _this.paused = false;
277
+ _this.inactive = false;
278
+ _this.aborted = false;
279
+ if (cb) {
280
+ var nonNullCb = cb;
281
+ var matches = [];
282
+ _this.on('match', function (match) {
283
+ return matches.push(_this.options.absolute ? match.absolute : match.relative);
284
+ });
285
+ _this.on('error', function (err) {
286
+ return nonNullCb(err);
287
+ });
288
+ _this.on('end', function () {
289
+ return nonNullCb(null, matches);
290
+ });
291
+ }
292
+ setTimeout(function () {
293
+ return _this._next();
294
+ });
295
+ return _this;
296
+ }
297
+ _inherits(ReaddirGlob, _EventEmitter);
298
+ return _createClass(ReaddirGlob, [{
299
+ key: "_shouldSkipDirectory",
300
+ value: function _shouldSkipDirectory(relative) {
301
+ return this.skipMatchers.some(function (m) {
302
+ return m.match(relative);
303
+ });
304
+ }
305
+ }, {
306
+ key: "_fileMatches",
307
+ value: function _fileMatches(relative, isDirectory) {
308
+ var file = relative + (isDirectory ? '/' : '');
309
+ return (this.matchers.length === 0 || this.matchers.some(function (m) {
310
+ return m.match(file);
311
+ })) && !this.ignoreMatchers.some(function (m) {
312
+ return m.match(file);
313
+ }) && (!this.options.nodir || !isDirectory);
314
+ }
315
+ }, {
316
+ key: "_next",
317
+ value: function _next() {
318
+ var _this2 = this;
319
+ if (!this.paused && !this.aborted) {
320
+ this.iterator.next().then(function (obj) {
321
+ if (!obj.done) {
322
+ var isDirectory = obj.value.stat.isDirectory();
323
+ if (_this2._fileMatches(obj.value.relative, isDirectory)) {
324
+ var relative = obj.value.relative;
325
+ var absolute = obj.value.absolute;
326
+ if (_this2.options.mark && isDirectory) {
327
+ relative += '/';
328
+ absolute += '/';
329
+ }
330
+ if (_this2.options.stat) {
331
+ _this2.emit('match', {
332
+ relative: relative,
333
+ absolute: absolute,
334
+ stat: obj.value.stat
335
+ });
336
+ } else {
337
+ _this2.emit('match', {
338
+ relative: relative,
339
+ absolute: absolute
340
+ });
341
+ }
342
+ }
343
+ _this2._next();
344
+ } else {
345
+ _this2.emit('end');
346
+ }
347
+ })["catch"](function (err) {
348
+ _this2.abort();
349
+ _this2.emit('error', err);
350
+ if (!err.code && !_this2.options.silent) {
351
+ console.error(err);
352
+ }
353
+ });
354
+ } else {
355
+ this.inactive = true;
356
+ }
357
+ }
358
+ }, {
359
+ key: "abort",
360
+ value: function abort() {
361
+ this.aborted = true;
362
+ }
363
+ }, {
364
+ key: "pause",
365
+ value: function pause() {
366
+ this.paused = true;
367
+ }
368
+ }, {
369
+ key: "resume",
370
+ value: function resume() {
371
+ this.paused = false;
372
+ if (this.inactive) {
373
+ this.inactive = false;
374
+ this._next();
375
+ }
376
+ }
377
+ }]);
378
+ }(_events.EventEmitter);
379
+ var readdirGlob = exports.readdirGlob = function readdirGlob(pattern, options, cb) {
380
+ return new ReaddirGlob(pattern, options, cb);
381
+ };
382
+ readdirGlob.ReaddirGlob = ReaddirGlob;