UNPKG

@enzymefinance/testutils

Version:

Technology Regulated and Operated Investment Funds

1,505 lines (1,485 loc) 246 kB
var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getOwnPropSymbols = Object.getOwnPropertySymbols; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __propIsEnum = Object.prototype.propertyIsEnumerable; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __spreadValues = (a, b) => { for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]); if (__getOwnPropSymbols) for (var prop of __getOwnPropSymbols(b)) { if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]); } return a; }; var __markAsModule = (target) => __defProp(target, "__esModule", { value: true }); var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) { if (typeof require !== "undefined") return require.apply(this, arguments); throw new Error('Dynamic require of "' + x + '" is not supported'); }); var __esm = (fn, res) => function __init() { return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res; }; var __commonJS = (cb, mod) => function __require2() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __reExport = (target, module, copyDefault, desc) => { if (module && typeof module === "object" || typeof module === "function") { for (let key of __getOwnPropNames(module)) if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default")) __defProp(target, key, { get: () => module[key], enumerable: !(desc = __getOwnPropDesc(module, key)) || desc.enumerable }); } return target; }; var __toESM = (module, isNodeMode) => { return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", !isNodeMode && module && module.__esModule ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module); }; // ../../node_modules/tsup/assets/esm_shims.js import { fileURLToPath } from "url"; import path from "path"; var getFilename, getDirname, __dirname; var init_esm_shims = __esm({ "../../node_modules/tsup/assets/esm_shims.js"() { getFilename = () => fileURLToPath(import.meta.url); getDirname = () => path.dirname(getFilename()); __dirname = /* @__PURE__ */ getDirname(); } }); // ../../node_modules/universalify/index.js var require_universalify = __commonJS({ "../../node_modules/universalify/index.js"(exports) { "use strict"; init_esm_shims(); exports.fromCallback = function(fn) { return Object.defineProperty(function() { if (typeof arguments[arguments.length - 1] === "function") fn.apply(this, arguments); else { return new Promise((resolve, reject) => { arguments[arguments.length] = (err, res) => { if (err) return reject(err); resolve(res); }; arguments.length++; fn.apply(this, arguments); }); } }, "name", { value: fn.name }); }; exports.fromPromise = function(fn) { return Object.defineProperty(function() { const cb = arguments[arguments.length - 1]; if (typeof cb !== "function") return fn.apply(this, arguments); else fn.apply(this, arguments).then((r) => cb(null, r), cb); }, "name", { value: fn.name }); }; } }); // ../../node_modules/fs-extra/node_modules/graceful-fs/polyfills.js var require_polyfills = __commonJS({ "../../node_modules/fs-extra/node_modules/graceful-fs/polyfills.js"(exports, module) { init_esm_shims(); var constants6 = __require("constants"); var origCwd = process.cwd; var cwd = null; var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform; process.cwd = function() { if (!cwd) cwd = origCwd.call(process); return cwd; }; try { process.cwd(); } catch (er) { } if (typeof process.chdir === "function") { chdir = process.chdir; process.chdir = function(d) { cwd = null; chdir.call(process, d); }; if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir); } var chdir; module.exports = patch; function patch(fs2) { if (constants6.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) { patchLchmod(fs2); } if (!fs2.lutimes) { patchLutimes(fs2); } fs2.chown = chownFix(fs2.chown); fs2.fchown = chownFix(fs2.fchown); fs2.lchown = chownFix(fs2.lchown); fs2.chmod = chmodFix(fs2.chmod); fs2.fchmod = chmodFix(fs2.fchmod); fs2.lchmod = chmodFix(fs2.lchmod); fs2.chownSync = chownFixSync(fs2.chownSync); fs2.fchownSync = chownFixSync(fs2.fchownSync); fs2.lchownSync = chownFixSync(fs2.lchownSync); fs2.chmodSync = chmodFixSync(fs2.chmodSync); fs2.fchmodSync = chmodFixSync(fs2.fchmodSync); fs2.lchmodSync = chmodFixSync(fs2.lchmodSync); fs2.stat = statFix(fs2.stat); fs2.fstat = statFix(fs2.fstat); fs2.lstat = statFix(fs2.lstat); fs2.statSync = statFixSync(fs2.statSync); fs2.fstatSync = statFixSync(fs2.fstatSync); fs2.lstatSync = statFixSync(fs2.lstatSync); if (!fs2.lchmod) { fs2.lchmod = function(path3, mode, cb) { if (cb) process.nextTick(cb); }; fs2.lchmodSync = function() { }; } if (!fs2.lchown) { fs2.lchown = function(path3, uid, gid, cb) { if (cb) process.nextTick(cb); }; fs2.lchownSync = function() { }; } if (platform === "win32") { fs2.rename = function(fs$rename) { return function(from, to, cb) { var start = Date.now(); var backoff = 0; fs$rename(from, to, function CB(er) { if (er && (er.code === "EACCES" || er.code === "EPERM") && Date.now() - start < 6e4) { setTimeout(function() { fs2.stat(to, function(stater, st) { if (stater && stater.code === "ENOENT") fs$rename(from, to, CB); else cb(er); }); }, backoff); if (backoff < 100) backoff += 10; return; } if (cb) cb(er); }); }; }(fs2.rename); } fs2.read = function(fs$read) { function read(fd, buffer, offset, length, position, callback_) { var callback; if (callback_ && typeof callback_ === "function") { var eagCounter = 0; callback = function(er, _, __) { if (er && er.code === "EAGAIN" && eagCounter < 10) { eagCounter++; return fs$read.call(fs2, fd, buffer, offset, length, position, callback); } callback_.apply(this, arguments); }; } return fs$read.call(fs2, fd, buffer, offset, length, position, callback); } if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read); return read; }(fs2.read); fs2.readSync = function(fs$readSync) { return function(fd, buffer, offset, length, position) { var eagCounter = 0; while (true) { try { return fs$readSync.call(fs2, fd, buffer, offset, length, position); } catch (er) { if (er.code === "EAGAIN" && eagCounter < 10) { eagCounter++; continue; } throw er; } } }; }(fs2.readSync); function patchLchmod(fs3) { fs3.lchmod = function(path3, mode, callback) { fs3.open(path3, constants6.O_WRONLY | constants6.O_SYMLINK, mode, function(err, fd) { if (err) { if (callback) callback(err); return; } fs3.fchmod(fd, mode, function(err2) { fs3.close(fd, function(err22) { if (callback) callback(err2 || err22); }); }); }); }; fs3.lchmodSync = function(path3, mode) { var fd = fs3.openSync(path3, constants6.O_WRONLY | constants6.O_SYMLINK, mode); var threw = true; var ret; try { ret = fs3.fchmodSync(fd, mode); threw = false; } finally { if (threw) { try { fs3.closeSync(fd); } catch (er) { } } else { fs3.closeSync(fd); } } return ret; }; } function patchLutimes(fs3) { if (constants6.hasOwnProperty("O_SYMLINK")) { fs3.lutimes = function(path3, at, mt, cb) { fs3.open(path3, constants6.O_SYMLINK, function(er, fd) { if (er) { if (cb) cb(er); return; } fs3.futimes(fd, at, mt, function(er2) { fs3.close(fd, function(er22) { if (cb) cb(er2 || er22); }); }); }); }; fs3.lutimesSync = function(path3, at, mt) { var fd = fs3.openSync(path3, constants6.O_SYMLINK); var ret; var threw = true; try { ret = fs3.futimesSync(fd, at, mt); threw = false; } finally { if (threw) { try { fs3.closeSync(fd); } catch (er) { } } else { fs3.closeSync(fd); } } return ret; }; } else { fs3.lutimes = function(_a, _b, _c, cb) { if (cb) process.nextTick(cb); }; fs3.lutimesSync = function() { }; } } function chmodFix(orig) { if (!orig) return orig; return function(target, mode, cb) { return orig.call(fs2, target, mode, function(er) { if (chownErOk(er)) er = null; if (cb) cb.apply(this, arguments); }); }; } function chmodFixSync(orig) { if (!orig) return orig; return function(target, mode) { try { return orig.call(fs2, target, mode); } catch (er) { if (!chownErOk(er)) throw er; } }; } function chownFix(orig) { if (!orig) return orig; return function(target, uid, gid, cb) { return orig.call(fs2, target, uid, gid, function(er) { if (chownErOk(er)) er = null; if (cb) cb.apply(this, arguments); }); }; } function chownFixSync(orig) { if (!orig) return orig; return function(target, uid, gid) { try { return orig.call(fs2, target, uid, gid); } catch (er) { if (!chownErOk(er)) throw er; } }; } function statFix(orig) { if (!orig) return orig; return function(target, options, cb) { if (typeof options === "function") { cb = options; options = null; } function callback(er, stats) { if (stats) { if (stats.uid < 0) stats.uid += 4294967296; if (stats.gid < 0) stats.gid += 4294967296; } if (cb) cb.apply(this, arguments); } return options ? orig.call(fs2, target, options, callback) : orig.call(fs2, target, callback); }; } function statFixSync(orig) { if (!orig) return orig; return function(target, options) { var stats = options ? orig.call(fs2, target, options) : orig.call(fs2, target); if (stats.uid < 0) stats.uid += 4294967296; if (stats.gid < 0) stats.gid += 4294967296; return stats; }; } function chownErOk(er) { if (!er) return true; if (er.code === "ENOSYS") return true; var nonroot = !process.getuid || process.getuid() !== 0; if (nonroot) { if (er.code === "EINVAL" || er.code === "EPERM") return true; } return false; } } } }); // ../../node_modules/fs-extra/node_modules/graceful-fs/legacy-streams.js var require_legacy_streams = __commonJS({ "../../node_modules/fs-extra/node_modules/graceful-fs/legacy-streams.js"(exports, module) { init_esm_shims(); var Stream = __require("stream").Stream; module.exports = legacy; function legacy(fs2) { return { ReadStream, WriteStream }; function ReadStream(path3, options) { if (!(this instanceof ReadStream)) return new ReadStream(path3, options); Stream.call(this); var self = this; this.path = path3; this.fd = null; this.readable = true; this.paused = false; this.flags = "r"; this.mode = 438; this.bufferSize = 64 * 1024; options = options || {}; var keys = Object.keys(options); for (var index = 0, length = keys.length; index < length; index++) { var key = keys[index]; this[key] = options[key]; } if (this.encoding) this.setEncoding(this.encoding); if (this.start !== void 0) { if (typeof this.start !== "number") { throw TypeError("start must be a Number"); } if (this.end === void 0) { this.end = Infinity; } else if (typeof this.end !== "number") { throw TypeError("end must be a Number"); } if (this.start > this.end) { throw new Error("start must be <= end"); } this.pos = this.start; } if (this.fd !== null) { process.nextTick(function() { self._read(); }); return; } fs2.open(this.path, this.flags, this.mode, function(err, fd) { if (err) { self.emit("error", err); self.readable = false; return; } self.fd = fd; self.emit("open", fd); self._read(); }); } function WriteStream(path3, options) { if (!(this instanceof WriteStream)) return new WriteStream(path3, options); Stream.call(this); this.path = path3; this.fd = null; this.writable = true; this.flags = "w"; this.encoding = "binary"; this.mode = 438; this.bytesWritten = 0; options = options || {}; var keys = Object.keys(options); for (var index = 0, length = keys.length; index < length; index++) { var key = keys[index]; this[key] = options[key]; } if (this.start !== void 0) { if (typeof this.start !== "number") { throw TypeError("start must be a Number"); } if (this.start < 0) { throw new Error("start must be >= zero"); } this.pos = this.start; } this.busy = false; this._queue = []; if (this.fd === null) { this._open = fs2.open; this._queue.push([this._open, this.path, this.flags, this.mode, void 0]); this.flush(); } } } } }); // ../../node_modules/fs-extra/node_modules/graceful-fs/clone.js var require_clone = __commonJS({ "../../node_modules/fs-extra/node_modules/graceful-fs/clone.js"(exports, module) { "use strict"; init_esm_shims(); module.exports = clone; var getPrototypeOf = Object.getPrototypeOf || function(obj) { return obj.__proto__; }; function clone(obj) { if (obj === null || typeof obj !== "object") return obj; if (obj instanceof Object) var copy = { __proto__: getPrototypeOf(obj) }; else var copy = /* @__PURE__ */ Object.create(null); Object.getOwnPropertyNames(obj).forEach(function(key) { Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key)); }); return copy; } } }); // ../../node_modules/fs-extra/node_modules/graceful-fs/graceful-fs.js var require_graceful_fs = __commonJS({ "../../node_modules/fs-extra/node_modules/graceful-fs/graceful-fs.js"(exports, module) { init_esm_shims(); var fs2 = __require("fs"); var polyfills = require_polyfills(); var legacy = require_legacy_streams(); var clone = require_clone(); var util = __require("util"); var gracefulQueue; var previousSymbol; if (typeof Symbol === "function" && typeof Symbol.for === "function") { gracefulQueue = Symbol.for("graceful-fs.queue"); previousSymbol = Symbol.for("graceful-fs.previous"); } else { gracefulQueue = "___graceful-fs.queue"; previousSymbol = "___graceful-fs.previous"; } function noop() { } function publishQueue(context, queue2) { Object.defineProperty(context, gracefulQueue, { get: function() { return queue2; } }); } var debug = noop; if (util.debuglog) debug = util.debuglog("gfs4"); else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) debug = function() { var m = util.format.apply(util, arguments); m = "GFS4: " + m.split(/\n/).join("\nGFS4: "); console.error(m); }; if (!fs2[gracefulQueue]) { queue = global[gracefulQueue] || []; publishQueue(fs2, queue); fs2.close = function(fs$close) { function close(fd, cb) { return fs$close.call(fs2, fd, function(err) { if (!err) { resetQueue(); } if (typeof cb === "function") cb.apply(this, arguments); }); } Object.defineProperty(close, previousSymbol, { value: fs$close }); return close; }(fs2.close); fs2.closeSync = function(fs$closeSync) { function closeSync(fd) { fs$closeSync.apply(fs2, arguments); resetQueue(); } Object.defineProperty(closeSync, previousSymbol, { value: fs$closeSync }); return closeSync; }(fs2.closeSync); if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) { process.on("exit", function() { debug(fs2[gracefulQueue]); __require("assert").equal(fs2[gracefulQueue].length, 0); }); } } var queue; if (!global[gracefulQueue]) { publishQueue(global, fs2[gracefulQueue]); } module.exports = patch(clone(fs2)); if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs2.__patched) { module.exports = patch(fs2); fs2.__patched = true; } function patch(fs3) { polyfills(fs3); fs3.gracefulify = patch; fs3.createReadStream = createReadStream; fs3.createWriteStream = createWriteStream; var fs$readFile = fs3.readFile; fs3.readFile = readFile; function readFile(path3, options, cb) { if (typeof options === "function") cb = options, options = null; return go$readFile(path3, options, cb); function go$readFile(path4, options2, cb2, startTime) { return fs$readFile(path4, options2, function(err) { if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([go$readFile, [path4, options2, cb2], err, startTime || Date.now(), Date.now()]); else { if (typeof cb2 === "function") cb2.apply(this, arguments); } }); } } var fs$writeFile = fs3.writeFile; fs3.writeFile = writeFile; function writeFile(path3, data, options, cb) { if (typeof options === "function") cb = options, options = null; return go$writeFile(path3, data, options, cb); function go$writeFile(path4, data2, options2, cb2, startTime) { return fs$writeFile(path4, data2, options2, function(err) { if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([go$writeFile, [path4, data2, options2, cb2], err, startTime || Date.now(), Date.now()]); else { if (typeof cb2 === "function") cb2.apply(this, arguments); } }); } } var fs$appendFile = fs3.appendFile; if (fs$appendFile) fs3.appendFile = appendFile; function appendFile(path3, data, options, cb) { if (typeof options === "function") cb = options, options = null; return go$appendFile(path3, data, options, cb); function go$appendFile(path4, data2, options2, cb2, startTime) { return fs$appendFile(path4, data2, options2, function(err) { if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([go$appendFile, [path4, data2, options2, cb2], err, startTime || Date.now(), Date.now()]); else { if (typeof cb2 === "function") cb2.apply(this, arguments); } }); } } var fs$copyFile = fs3.copyFile; if (fs$copyFile) fs3.copyFile = copyFile; function copyFile(src, dest, flags, cb) { if (typeof flags === "function") { cb = flags; flags = 0; } return go$copyFile(src, dest, flags, cb); function go$copyFile(src2, dest2, flags2, cb2, startTime) { return fs$copyFile(src2, dest2, flags2, function(err) { if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([go$copyFile, [src2, dest2, flags2, cb2], err, startTime || Date.now(), Date.now()]); else { if (typeof cb2 === "function") cb2.apply(this, arguments); } }); } } var fs$readdir = fs3.readdir; fs3.readdir = readdir; function readdir(path3, options, cb) { if (typeof options === "function") cb = options, options = null; return go$readdir(path3, options, cb); function go$readdir(path4, options2, cb2, startTime) { return fs$readdir(path4, options2, function(err, files) { if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([go$readdir, [path4, options2, cb2], err, startTime || Date.now(), Date.now()]); else { if (files && files.sort) files.sort(); if (typeof cb2 === "function") cb2.call(this, err, files); } }); } } if (process.version.substr(0, 4) === "v0.8") { var legStreams = legacy(fs3); ReadStream = legStreams.ReadStream; WriteStream = legStreams.WriteStream; } var fs$ReadStream = fs3.ReadStream; if (fs$ReadStream) { ReadStream.prototype = Object.create(fs$ReadStream.prototype); ReadStream.prototype.open = ReadStream$open; } var fs$WriteStream = fs3.WriteStream; if (fs$WriteStream) { WriteStream.prototype = Object.create(fs$WriteStream.prototype); WriteStream.prototype.open = WriteStream$open; } Object.defineProperty(fs3, "ReadStream", { get: function() { return ReadStream; }, set: function(val) { ReadStream = val; }, enumerable: true, configurable: true }); Object.defineProperty(fs3, "WriteStream", { get: function() { return WriteStream; }, set: function(val) { WriteStream = val; }, enumerable: true, configurable: true }); var FileReadStream = ReadStream; Object.defineProperty(fs3, "FileReadStream", { get: function() { return FileReadStream; }, set: function(val) { FileReadStream = val; }, enumerable: true, configurable: true }); var FileWriteStream = WriteStream; Object.defineProperty(fs3, "FileWriteStream", { get: function() { return FileWriteStream; }, set: function(val) { FileWriteStream = val; }, enumerable: true, configurable: true }); function ReadStream(path3, options) { if (this instanceof ReadStream) return fs$ReadStream.apply(this, arguments), this; else return ReadStream.apply(Object.create(ReadStream.prototype), arguments); } function ReadStream$open() { var that = this; open(that.path, that.flags, that.mode, function(err, fd) { if (err) { if (that.autoClose) that.destroy(); that.emit("error", err); } else { that.fd = fd; that.emit("open", fd); that.read(); } }); } function WriteStream(path3, options) { if (this instanceof WriteStream) return fs$WriteStream.apply(this, arguments), this; else return WriteStream.apply(Object.create(WriteStream.prototype), arguments); } function WriteStream$open() { var that = this; open(that.path, that.flags, that.mode, function(err, fd) { if (err) { that.destroy(); that.emit("error", err); } else { that.fd = fd; that.emit("open", fd); } }); } function createReadStream(path3, options) { return new fs3.ReadStream(path3, options); } function createWriteStream(path3, options) { return new fs3.WriteStream(path3, options); } var fs$open = fs3.open; fs3.open = open; function open(path3, flags, mode, cb) { if (typeof mode === "function") cb = mode, mode = null; return go$open(path3, flags, mode, cb); function go$open(path4, flags2, mode2, cb2, startTime) { return fs$open(path4, flags2, mode2, function(err, fd) { if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([go$open, [path4, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]); else { if (typeof cb2 === "function") cb2.apply(this, arguments); } }); } } return fs3; } function enqueue(elem) { debug("ENQUEUE", elem[0].name, elem[1]); fs2[gracefulQueue].push(elem); retry(); } var retryTimer; function resetQueue() { var now = Date.now(); for (var i = 0; i < fs2[gracefulQueue].length; ++i) { if (fs2[gracefulQueue][i].length > 2) { fs2[gracefulQueue][i][3] = now; fs2[gracefulQueue][i][4] = now; } } retry(); } function retry() { clearTimeout(retryTimer); retryTimer = void 0; if (fs2[gracefulQueue].length === 0) return; var elem = fs2[gracefulQueue].shift(); var fn = elem[0]; var args = elem[1]; var err = elem[2]; var startTime = elem[3]; var lastTime = elem[4]; if (startTime === void 0) { debug("RETRY", fn.name, args); fn.apply(null, args); } else if (Date.now() - startTime >= 6e4) { debug("TIMEOUT", fn.name, args); var cb = args.pop(); if (typeof cb === "function") cb.call(null, err); } else { var sinceAttempt = Date.now() - lastTime; var sinceStart = Math.max(lastTime - startTime, 1); var desiredDelay = Math.min(sinceStart * 1.2, 100); if (sinceAttempt >= desiredDelay) { debug("RETRY", fn.name, args); fn.apply(null, args.concat([startTime])); } else { fs2[gracefulQueue].push(elem); } } if (retryTimer === void 0) { retryTimer = setTimeout(retry, 0); } } } }); // ../../node_modules/fs-extra/lib/fs/index.js var require_fs = __commonJS({ "../../node_modules/fs-extra/lib/fs/index.js"(exports) { "use strict"; init_esm_shims(); var u = require_universalify().fromCallback; var fs2 = require_graceful_fs(); var api = [ "access", "appendFile", "chmod", "chown", "close", "copyFile", "fchmod", "fchown", "fdatasync", "fstat", "fsync", "ftruncate", "futimes", "lchown", "lchmod", "link", "lstat", "mkdir", "mkdtemp", "open", "readFile", "readdir", "readlink", "realpath", "rename", "rmdir", "stat", "symlink", "truncate", "unlink", "utimes", "writeFile" ].filter((key) => { return typeof fs2[key] === "function"; }); Object.keys(fs2).forEach((key) => { if (key === "promises") { return; } exports[key] = fs2[key]; }); api.forEach((method) => { exports[method] = u(fs2[method]); }); exports.exists = function(filename, callback) { if (typeof callback === "function") { return fs2.exists(filename, callback); } return new Promise((resolve) => { return fs2.exists(filename, resolve); }); }; exports.read = function(fd, buffer, offset, length, position, callback) { if (typeof callback === "function") { return fs2.read(fd, buffer, offset, length, position, callback); } return new Promise((resolve, reject) => { fs2.read(fd, buffer, offset, length, position, (err, bytesRead, buffer2) => { if (err) return reject(err); resolve({ bytesRead, buffer: buffer2 }); }); }); }; exports.write = function(fd, buffer, ...args) { if (typeof args[args.length - 1] === "function") { return fs2.write(fd, buffer, ...args); } return new Promise((resolve, reject) => { fs2.write(fd, buffer, ...args, (err, bytesWritten, buffer2) => { if (err) return reject(err); resolve({ bytesWritten, buffer: buffer2 }); }); }); }; } }); // ../../node_modules/fs-extra/lib/mkdirs/win32.js var require_win32 = __commonJS({ "../../node_modules/fs-extra/lib/mkdirs/win32.js"(exports, module) { "use strict"; init_esm_shims(); var path3 = __require("path"); function getRootPath(p) { p = path3.normalize(path3.resolve(p)).split(path3.sep); if (p.length > 0) return p[0]; return null; } var INVALID_PATH_CHARS = /[<>:"|?*]/; function invalidWin32Path(p) { const rp = getRootPath(p); p = p.replace(rp, ""); return INVALID_PATH_CHARS.test(p); } module.exports = { getRootPath, invalidWin32Path }; } }); // ../../node_modules/fs-extra/lib/mkdirs/mkdirs.js var require_mkdirs = __commonJS({ "../../node_modules/fs-extra/lib/mkdirs/mkdirs.js"(exports, module) { "use strict"; init_esm_shims(); var fs2 = require_graceful_fs(); var path3 = __require("path"); var invalidWin32Path = require_win32().invalidWin32Path; var o777 = parseInt("0777", 8); function mkdirs(p, opts, callback, made) { if (typeof opts === "function") { callback = opts; opts = {}; } else if (!opts || typeof opts !== "object") { opts = { mode: opts }; } if (process.platform === "win32" && invalidWin32Path(p)) { const errInval = new Error(p + " contains invalid WIN32 path characters."); errInval.code = "EINVAL"; return callback(errInval); } let mode = opts.mode; const xfs = opts.fs || fs2; if (mode === void 0) { mode = o777 & ~process.umask(); } if (!made) made = null; callback = callback || function() { }; p = path3.resolve(p); xfs.mkdir(p, mode, (er) => { if (!er) { made = made || p; return callback(null, made); } switch (er.code) { case "ENOENT": if (path3.dirname(p) === p) return callback(er); mkdirs(path3.dirname(p), opts, (er2, made2) => { if (er2) callback(er2, made2); else mkdirs(p, opts, callback, made2); }); break; default: xfs.stat(p, (er2, stat) => { if (er2 || !stat.isDirectory()) callback(er, made); else callback(null, made); }); break; } }); } module.exports = mkdirs; } }); // ../../node_modules/fs-extra/lib/mkdirs/mkdirs-sync.js var require_mkdirs_sync = __commonJS({ "../../node_modules/fs-extra/lib/mkdirs/mkdirs-sync.js"(exports, module) { "use strict"; init_esm_shims(); var fs2 = require_graceful_fs(); var path3 = __require("path"); var invalidWin32Path = require_win32().invalidWin32Path; var o777 = parseInt("0777", 8); function mkdirsSync(p, opts, made) { if (!opts || typeof opts !== "object") { opts = { mode: opts }; } let mode = opts.mode; const xfs = opts.fs || fs2; if (process.platform === "win32" && invalidWin32Path(p)) { const errInval = new Error(p + " contains invalid WIN32 path characters."); errInval.code = "EINVAL"; throw errInval; } if (mode === void 0) { mode = o777 & ~process.umask(); } if (!made) made = null; p = path3.resolve(p); try { xfs.mkdirSync(p, mode); made = made || p; } catch (err0) { if (err0.code === "ENOENT") { if (path3.dirname(p) === p) throw err0; made = mkdirsSync(path3.dirname(p), opts, made); mkdirsSync(p, opts, made); } else { let stat; try { stat = xfs.statSync(p); } catch (err1) { throw err0; } if (!stat.isDirectory()) throw err0; } } return made; } module.exports = mkdirsSync; } }); // ../../node_modules/fs-extra/lib/mkdirs/index.js var require_mkdirs2 = __commonJS({ "../../node_modules/fs-extra/lib/mkdirs/index.js"(exports, module) { "use strict"; init_esm_shims(); var u = require_universalify().fromCallback; var mkdirs = u(require_mkdirs()); var mkdirsSync = require_mkdirs_sync(); module.exports = { mkdirs, mkdirsSync, mkdirp: mkdirs, mkdirpSync: mkdirsSync, ensureDir: mkdirs, ensureDirSync: mkdirsSync }; } }); // ../../node_modules/fs-extra/lib/util/utimes.js var require_utimes = __commonJS({ "../../node_modules/fs-extra/lib/util/utimes.js"(exports, module) { "use strict"; init_esm_shims(); var fs2 = require_graceful_fs(); var os = __require("os"); var path3 = __require("path"); function hasMillisResSync() { let tmpfile = path3.join("millis-test-sync" + Date.now().toString() + Math.random().toString().slice(2)); tmpfile = path3.join(os.tmpdir(), tmpfile); const d = new Date(1435410243862); fs2.writeFileSync(tmpfile, "https://github.com/jprichardson/node-fs-extra/pull/141"); const fd = fs2.openSync(tmpfile, "r+"); fs2.futimesSync(fd, d, d); fs2.closeSync(fd); return fs2.statSync(tmpfile).mtime > 1435410243e3; } function hasMillisRes(callback) { let tmpfile = path3.join("millis-test" + Date.now().toString() + Math.random().toString().slice(2)); tmpfile = path3.join(os.tmpdir(), tmpfile); const d = new Date(1435410243862); fs2.writeFile(tmpfile, "https://github.com/jprichardson/node-fs-extra/pull/141", (err) => { if (err) return callback(err); fs2.open(tmpfile, "r+", (err2, fd) => { if (err2) return callback(err2); fs2.futimes(fd, d, d, (err3) => { if (err3) return callback(err3); fs2.close(fd, (err4) => { if (err4) return callback(err4); fs2.stat(tmpfile, (err5, stats) => { if (err5) return callback(err5); callback(null, stats.mtime > 1435410243e3); }); }); }); }); }); } function timeRemoveMillis(timestamp) { if (typeof timestamp === "number") { return Math.floor(timestamp / 1e3) * 1e3; } else if (timestamp instanceof Date) { return new Date(Math.floor(timestamp.getTime() / 1e3) * 1e3); } else { throw new Error("fs-extra: timeRemoveMillis() unknown parameter type"); } } function utimesMillis(path4, atime, mtime, callback) { fs2.open(path4, "r+", (err, fd) => { if (err) return callback(err); fs2.futimes(fd, atime, mtime, (futimesErr) => { fs2.close(fd, (closeErr) => { if (callback) callback(futimesErr || closeErr); }); }); }); } function utimesMillisSync(path4, atime, mtime) { const fd = fs2.openSync(path4, "r+"); fs2.futimesSync(fd, atime, mtime); return fs2.closeSync(fd); } module.exports = { hasMillisRes, hasMillisResSync, timeRemoveMillis, utimesMillis, utimesMillisSync }; } }); // ../../node_modules/fs-extra/lib/util/buffer.js var require_buffer = __commonJS({ "../../node_modules/fs-extra/lib/util/buffer.js"(exports, module) { "use strict"; init_esm_shims(); module.exports = function(size) { if (typeof Buffer.allocUnsafe === "function") { try { return Buffer.allocUnsafe(size); } catch (e) { return new Buffer(size); } } return new Buffer(size); }; } }); // ../../node_modules/fs-extra/lib/copy-sync/copy-sync.js var require_copy_sync = __commonJS({ "../../node_modules/fs-extra/lib/copy-sync/copy-sync.js"(exports, module) { "use strict"; init_esm_shims(); var fs2 = require_graceful_fs(); var path3 = __require("path"); var mkdirpSync = require_mkdirs2().mkdirsSync; var utimesSync = require_utimes().utimesMillisSync; var notExist = Symbol("notExist"); function copySync(src, dest, opts) { if (typeof opts === "function") { opts = { filter: opts }; } opts = opts || {}; opts.clobber = "clobber" in opts ? !!opts.clobber : true; opts.overwrite = "overwrite" in opts ? !!opts.overwrite : opts.clobber; if (opts.preserveTimestamps && process.arch === "ia32") { console.warn(`fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended; see https://github.com/jprichardson/node-fs-extra/issues/269`); } const destStat = checkPaths(src, dest); if (opts.filter && !opts.filter(src, dest)) return; const destParent = path3.dirname(dest); if (!fs2.existsSync(destParent)) mkdirpSync(destParent); return startCopy(destStat, src, dest, opts); } function startCopy(destStat, src, dest, opts) { if (opts.filter && !opts.filter(src, dest)) return; return getStats(destStat, src, dest, opts); } function getStats(destStat, src, dest, opts) { const statSync = opts.dereference ? fs2.statSync : fs2.lstatSync; const srcStat = statSync(src); if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts); else if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts); else if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts); } function onFile(srcStat, destStat, src, dest, opts) { if (destStat === notExist) return copyFile(srcStat, src, dest, opts); return mayCopyFile(srcStat, src, dest, opts); } function mayCopyFile(srcStat, src, dest, opts) { if (opts.overwrite) { fs2.unlinkSync(dest); return copyFile(srcStat, src, dest, opts); } else if (opts.errorOnExist) { throw new Error(`'${dest}' already exists`); } } function copyFile(srcStat, src, dest, opts) { if (typeof fs2.copyFileSync === "function") { fs2.copyFileSync(src, dest); fs2.chmodSync(dest, srcStat.mode); if (opts.preserveTimestamps) { return utimesSync(dest, srcStat.atime, srcStat.mtime); } return; } return copyFileFallback(srcStat, src, dest, opts); } function copyFileFallback(srcStat, src, dest, opts) { const BUF_LENGTH = 64 * 1024; const _buff = require_buffer()(BUF_LENGTH); const fdr = fs2.openSync(src, "r"); const fdw = fs2.openSync(dest, "w", srcStat.mode); let pos = 0; while (pos < srcStat.size) { const bytesRead = fs2.readSync(fdr, _buff, 0, BUF_LENGTH, pos); fs2.writeSync(fdw, _buff, 0, bytesRead); pos += bytesRead; } if (opts.preserveTimestamps) fs2.futimesSync(fdw, srcStat.atime, srcStat.mtime); fs2.closeSync(fdr); fs2.closeSync(fdw); } function onDir(srcStat, destStat, src, dest, opts) { if (destStat === notExist) return mkDirAndCopy(srcStat, src, dest, opts); if (destStat && !destStat.isDirectory()) { throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`); } return copyDir(src, dest, opts); } function mkDirAndCopy(srcStat, src, dest, opts) { fs2.mkdirSync(dest); copyDir(src, dest, opts); return fs2.chmodSync(dest, srcStat.mode); } function copyDir(src, dest, opts) { fs2.readdirSync(src).forEach((item) => copyDirItem(item, src, dest, opts)); } function copyDirItem(item, src, dest, opts) { const srcItem = path3.join(src, item); const destItem = path3.join(dest, item); const destStat = checkPaths(srcItem, destItem); return startCopy(destStat, srcItem, destItem, opts); } function onLink(destStat, src, dest, opts) { let resolvedSrc = fs2.readlinkSync(src); if (opts.dereference) { resolvedSrc = path3.resolve(process.cwd(), resolvedSrc); } if (destStat === notExist) { return fs2.symlinkSync(resolvedSrc, dest); } else { let resolvedDest; try { resolvedDest = fs2.readlinkSync(dest); } catch (err) { if (err.code === "EINVAL" || err.code === "UNKNOWN") return fs2.symlinkSync(resolvedSrc, dest); throw err; } if (opts.dereference) { resolvedDest = path3.resolve(process.cwd(), resolvedDest); } if (isSrcSubdir(resolvedSrc, resolvedDest)) { throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`); } if (fs2.statSync(dest).isDirectory() && isSrcSubdir(resolvedDest, resolvedSrc)) { throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`); } return copyLink(resolvedSrc, dest); } } function copyLink(resolvedSrc, dest) { fs2.unlinkSync(dest); return fs2.symlinkSync(resolvedSrc, dest); } function isSrcSubdir(src, dest) { const srcArray = path3.resolve(src).split(path3.sep); const destArray = path3.resolve(dest).split(path3.sep); return srcArray.reduce((acc, current, i) => acc && destArray[i] === current, true); } function checkStats(src, dest) { const srcStat = fs2.statSync(src); let destStat; try { destStat = fs2.statSync(dest); } catch (err) { if (err.code === "ENOENT") return { srcStat, destStat: notExist }; throw err; } return { srcStat, destStat }; } function checkPaths(src, dest) { const { srcStat, destStat } = checkStats(src, dest); if (destStat.ino && destStat.ino === srcStat.ino) { throw new Error("Source and destination must not be the same."); } if (srcStat.isDirectory() && isSrcSubdir(src, dest)) { throw new Error(`Cannot copy '${src}' to a subdirectory of itself, '${dest}'.`); } return destStat; } module.exports = copySync; } }); // ../../node_modules/fs-extra/lib/copy-sync/index.js var require_copy_sync2 = __commonJS({ "../../node_modules/fs-extra/lib/copy-sync/index.js"(exports, module) { "use strict"; init_esm_shims(); module.exports = { copySync: require_copy_sync() }; } }); // ../../node_modules/fs-extra/lib/path-exists/index.js var require_path_exists = __commonJS({ "../../node_modules/fs-extra/lib/path-exists/index.js"(exports, module) { "use strict"; init_esm_shims(); var u = require_universalify().fromPromise; var fs2 = require_fs(); function pathExists(path3) { return fs2.access(path3).then(() => true).catch(() => false); } module.exports = { pathExists: u(pathExists), pathExistsSync: fs2.existsSync }; } }); // ../../node_modules/fs-extra/lib/copy/copy.js var require_copy = __commonJS({ "../../node_modules/fs-extra/lib/copy/copy.js"(exports, module) { "use strict"; init_esm_shims(); var fs2 = require_graceful_fs(); var path3 = __require("path"); var mkdirp = require_mkdirs2().mkdirs; var pathExists = require_path_exists().pathExists; var utimes = require_utimes().utimesMillis; var notExist = Symbol("notExist"); function copy(src, dest, opts, cb) { if (typeof opts === "function" && !cb) { cb = opts; opts = {}; } else if (typeof opts === "function") { opts = { filter: opts }; } cb = cb || function() { }; opts = opts || {}; opts.clobber = "clobber" in opts ? !!opts.clobber : true; opts.overwrite = "overwrite" in opts ? !!opts.overwrite : opts.clobber; if (opts.preserveTimestamps && process.arch === "ia32") { console.warn(`fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended; see https://github.com/jprichardson/node-fs-extra/issues/269`); } checkPaths(src, dest, (err, destStat) => { if (err) return cb(err); if (opts.filter) return handleFilter(checkParentDir, destStat, src, dest, opts, cb); return checkParentDir(destStat, src, dest, opts, cb); }); } function checkParentDir(destStat, src, dest, opts, cb) { const destParent = path3.dirname(dest); pathExists(destParent, (err, dirExists) => { if (err) return cb(err); if (dirExists) return startCopy(destStat, src, dest, opts, cb); mkdirp(destParent, (err2) => { if (err2) return cb(err2); return startCopy(destStat, src, dest, opts, cb); }); }); } function handleFilter(onInclude, destStat, src, dest, opts, cb) { Promise.resolve(opts.filter(src, dest)).then((include) => { if (include) { if (destStat) return onInclude(destStat, src, dest, opts, cb); return onInclude(src, dest, opts, cb); } return cb(); }, (error) => cb(error)); } function startCopy(destStat, src, dest, opts, cb) { if (opts.filter) return handleFilter(getStats, destStat, src, dest, opts, cb); return getStats(destStat, src, dest, opts, cb); } function getStats(destStat, src, dest, opts, cb) { const stat = opts.dereference ? fs2.stat : fs2.lstat; stat(src, (err, srcStat) => { if (err) return cb(err); if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts, cb); else if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts, cb); else if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts, cb); }); } function onFile(srcStat, destStat, src, dest, opts, cb) { if (destStat === notExist) return copyFile(srcStat, src, dest, opts, cb); return mayCopyFile(srcStat, src, dest, opts, cb); } function mayCopyFile(srcStat, src, dest, opts, cb) { if (opts.overwrite) { fs2.unlink(dest, (err) => { if (err) return cb(err); return copyFile(srcStat, src, dest, opts, cb); }); } else if (opts.errorOnExist) {