@fbaconversio/onborda
Version:
The ultimate product tour library for Next.js
1,547 lines (1,530 loc) • 428 kB
JavaScript
#!/usr/bin/env node
/* eslint-disable */
"use strict";
const RAW_RUNTIME_STATE =
'{\
"__info": [\
"This file is automatically generated. Do not touch it, or risk",\
"your modifications being lost."\
],\
"dependencyTreeRoots": [\
{\
"name": "onborda",\
"reference": "workspace:."\
}\
],\
"enableTopLevelFallback": true,\
"ignorePatternData": "(^(?:\\\\.yarn\\\\/sdks(?:\\\\/(?!\\\\.{1,2}(?:\\\\/|$))(?:(?:(?!(?:^|\\\\/)\\\\.{1,2}(?:\\\\/|$)).)*?)|$))$)",\
"fallbackExclusionList": [\
["onborda", ["workspace:."]]\
],\
"fallbackPool": [\
],\
"packageRegistryData": [\
[null, [\
[null, {\
"packageLocation": "./",\
"packageDependencies": [\
["framer-motion", "virtual:1db926a4ae2c49358fe48396b156dd0a8f5944c3b58012fe3ac5cef6cb3bcdda08af487f361bad199520be6687ddec570231be2f6b46e096590f235b0a220ded#npm:11.0.8"],\
["react", "npm:18.2.0"],\
["typescript", "patch:typescript@npm%3A5.3.3#optional!builtin<compat/typescript>::version=5.3.3&hash=e012d7"]\
],\
"linkType": "SOFT"\
}]\
]],\
["@emotion/is-prop-valid", [\
["npm:0.8.8", {\
"packageLocation": "../../.yarn/berry/cache/@emotion-is-prop-valid-npm-0.8.8-261a0f2426-10c0.zip/node_modules/@emotion/is-prop-valid/",\
"packageDependencies": [\
["@emotion/is-prop-valid", "npm:0.8.8"],\
["@emotion/memoize", "npm:0.7.4"]\
],\
"linkType": "HARD"\
}]\
]],\
["@emotion/memoize", [\
["npm:0.7.4", {\
"packageLocation": "../../.yarn/berry/cache/@emotion-memoize-npm-0.7.4-5648cf11b8-10c0.zip/node_modules/@emotion/memoize/",\
"packageDependencies": [\
["@emotion/memoize", "npm:0.7.4"]\
],\
"linkType": "HARD"\
}]\
]],\
["framer-motion", [\
["npm:11.0.8", {\
"packageLocation": "../../.yarn/berry/cache/framer-motion-npm-11.0.8-a3d819932a-10c0.zip/node_modules/framer-motion/",\
"packageDependencies": [\
["framer-motion", "npm:11.0.8"]\
],\
"linkType": "SOFT"\
}],\
["virtual:1db926a4ae2c49358fe48396b156dd0a8f5944c3b58012fe3ac5cef6cb3bcdda08af487f361bad199520be6687ddec570231be2f6b46e096590f235b0a220ded#npm:11.0.8", {\
"packageLocation": "./.yarn/__virtual__/framer-motion-virtual-bdc7eeb667/3/.yarn/berry/cache/framer-motion-npm-11.0.8-a3d819932a-10c0.zip/node_modules/framer-motion/",\
"packageDependencies": [\
["framer-motion", "virtual:1db926a4ae2c49358fe48396b156dd0a8f5944c3b58012fe3ac5cef6cb3bcdda08af487f361bad199520be6687ddec570231be2f6b46e096590f235b0a220ded#npm:11.0.8"],\
["@emotion/is-prop-valid", "npm:0.8.8"],\
["@types/react", null],\
["@types/react-dom", null],\
["react", "npm:18.2.0"],\
["react-dom", null],\
["tslib", "npm:2.6.2"]\
],\
"packagePeers": [\
"@types/react-dom",\
"@types/react",\
"react-dom",\
"react"\
],\
"linkType": "HARD"\
}]\
]],\
["js-tokens", [\
["npm:4.0.0", {\
"packageLocation": "../../.yarn/berry/cache/js-tokens-npm-4.0.0-0ac852e9e2-10c0.zip/node_modules/js-tokens/",\
"packageDependencies": [\
["js-tokens", "npm:4.0.0"]\
],\
"linkType": "HARD"\
}]\
]],\
["loose-envify", [\
["npm:1.4.0", {\
"packageLocation": "../../.yarn/berry/cache/loose-envify-npm-1.4.0-6307b72ccf-10c0.zip/node_modules/loose-envify/",\
"packageDependencies": [\
["loose-envify", "npm:1.4.0"],\
["js-tokens", "npm:4.0.0"]\
],\
"linkType": "HARD"\
}]\
]],\
["onborda", [\
["workspace:.", {\
"packageLocation": "./",\
"packageDependencies": [\
["onborda", "workspace:."],\
["framer-motion", "virtual:1db926a4ae2c49358fe48396b156dd0a8f5944c3b58012fe3ac5cef6cb3bcdda08af487f361bad199520be6687ddec570231be2f6b46e096590f235b0a220ded#npm:11.0.8"],\
["react", "npm:18.2.0"],\
["typescript", "patch:typescript@npm%3A5.3.3#optional!builtin<compat/typescript>::version=5.3.3&hash=e012d7"]\
],\
"linkType": "SOFT"\
}]\
]],\
["react", [\
["npm:18.2.0", {\
"packageLocation": "../../.yarn/berry/cache/react-npm-18.2.0-1eae08fee2-10c0.zip/node_modules/react/",\
"packageDependencies": [\
["react", "npm:18.2.0"],\
["loose-envify", "npm:1.4.0"]\
],\
"linkType": "HARD"\
}]\
]],\
["tslib", [\
["npm:2.6.2", {\
"packageLocation": "../../.yarn/berry/cache/tslib-npm-2.6.2-4fc8c068d9-10c0.zip/node_modules/tslib/",\
"packageDependencies": [\
["tslib", "npm:2.6.2"]\
],\
"linkType": "HARD"\
}]\
]],\
["typescript", [\
["patch:typescript@npm%3A5.3.3#optional!builtin<compat/typescript>::version=5.3.3&hash=e012d7", {\
"packageLocation": "../../.yarn/berry/cache/typescript-patch-4778c7998b-10c0.zip/node_modules/typescript/",\
"packageDependencies": [\
["typescript", "patch:typescript@npm%3A5.3.3#optional!builtin<compat/typescript>::version=5.3.3&hash=e012d7"]\
],\
"linkType": "HARD"\
}]\
]]\
]\
}';
function $$SETUP_STATE(hydrateRuntimeState, basePath) {
return hydrateRuntimeState(JSON.parse(RAW_RUNTIME_STATE), {basePath: basePath || __dirname});
}
const fs = require('fs');
const path = require('path');
const crypto = require('crypto');
const os = require('os');
const events = require('events');
const nodeUtils = require('util');
const stream = require('stream');
const zlib = require('zlib');
const require$$0 = require('module');
const StringDecoder = require('string_decoder');
const url = require('url');
const buffer = require('buffer');
const readline = require('readline');
const assert = require('assert');
const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
function _interopNamespace(e) {
if (e && e.__esModule) return e;
const n = Object.create(null);
if (e) {
for (const k in e) {
if (k !== 'default') {
const d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: () => e[k]
});
}
}
}
n.default = e;
return Object.freeze(n);
}
const fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
const path__default = /*#__PURE__*/_interopDefaultLegacy(path);
const nodeUtils__namespace = /*#__PURE__*/_interopNamespace(nodeUtils);
const zlib__default = /*#__PURE__*/_interopDefaultLegacy(zlib);
const require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
const StringDecoder__default = /*#__PURE__*/_interopDefaultLegacy(StringDecoder);
const buffer__default = /*#__PURE__*/_interopDefaultLegacy(buffer);
const assert__default = /*#__PURE__*/_interopDefaultLegacy(assert);
const S_IFMT = 61440;
const S_IFDIR = 16384;
const S_IFREG = 32768;
const S_IFLNK = 40960;
const SAFE_TIME = 456789e3;
function makeError$1(code, message) {
return Object.assign(new Error(`${code}: ${message}`), { code });
}
function EBUSY(message) {
return makeError$1(`EBUSY`, message);
}
function ENOSYS(message, reason) {
return makeError$1(`ENOSYS`, `${message}, ${reason}`);
}
function EINVAL(reason) {
return makeError$1(`EINVAL`, `invalid argument, ${reason}`);
}
function EBADF(reason) {
return makeError$1(`EBADF`, `bad file descriptor, ${reason}`);
}
function ENOENT(reason) {
return makeError$1(`ENOENT`, `no such file or directory, ${reason}`);
}
function ENOTDIR(reason) {
return makeError$1(`ENOTDIR`, `not a directory, ${reason}`);
}
function EISDIR(reason) {
return makeError$1(`EISDIR`, `illegal operation on a directory, ${reason}`);
}
function EEXIST(reason) {
return makeError$1(`EEXIST`, `file already exists, ${reason}`);
}
function EROFS(reason) {
return makeError$1(`EROFS`, `read-only filesystem, ${reason}`);
}
function ENOTEMPTY(reason) {
return makeError$1(`ENOTEMPTY`, `directory not empty, ${reason}`);
}
function EOPNOTSUPP(reason) {
return makeError$1(`EOPNOTSUPP`, `operation not supported, ${reason}`);
}
function ERR_DIR_CLOSED() {
return makeError$1(`ERR_DIR_CLOSED`, `Directory handle was closed`);
}
const DEFAULT_MODE = S_IFREG | 420;
class StatEntry {
constructor() {
this.uid = 0;
this.gid = 0;
this.size = 0;
this.blksize = 0;
this.atimeMs = 0;
this.mtimeMs = 0;
this.ctimeMs = 0;
this.birthtimeMs = 0;
this.atime = new Date(0);
this.mtime = new Date(0);
this.ctime = new Date(0);
this.birthtime = new Date(0);
this.dev = 0;
this.ino = 0;
this.mode = DEFAULT_MODE;
this.nlink = 1;
this.rdev = 0;
this.blocks = 1;
}
isBlockDevice() {
return false;
}
isCharacterDevice() {
return false;
}
isDirectory() {
return (this.mode & S_IFMT) === S_IFDIR;
}
isFIFO() {
return false;
}
isFile() {
return (this.mode & S_IFMT) === S_IFREG;
}
isSocket() {
return false;
}
isSymbolicLink() {
return (this.mode & S_IFMT) === S_IFLNK;
}
}
class BigIntStatsEntry {
constructor() {
this.uid = BigInt(0);
this.gid = BigInt(0);
this.size = BigInt(0);
this.blksize = BigInt(0);
this.atimeMs = BigInt(0);
this.mtimeMs = BigInt(0);
this.ctimeMs = BigInt(0);
this.birthtimeMs = BigInt(0);
this.atimeNs = BigInt(0);
this.mtimeNs = BigInt(0);
this.ctimeNs = BigInt(0);
this.birthtimeNs = BigInt(0);
this.atime = new Date(0);
this.mtime = new Date(0);
this.ctime = new Date(0);
this.birthtime = new Date(0);
this.dev = BigInt(0);
this.ino = BigInt(0);
this.mode = BigInt(DEFAULT_MODE);
this.nlink = BigInt(1);
this.rdev = BigInt(0);
this.blocks = BigInt(1);
}
isBlockDevice() {
return false;
}
isCharacterDevice() {
return false;
}
isDirectory() {
return (this.mode & BigInt(S_IFMT)) === BigInt(S_IFDIR);
}
isFIFO() {
return false;
}
isFile() {
return (this.mode & BigInt(S_IFMT)) === BigInt(S_IFREG);
}
isSocket() {
return false;
}
isSymbolicLink() {
return (this.mode & BigInt(S_IFMT)) === BigInt(S_IFLNK);
}
}
function makeDefaultStats() {
return new StatEntry();
}
function clearStats(stats) {
for (const key in stats) {
if (Object.hasOwn(stats, key)) {
const element = stats[key];
if (typeof element === `number`) {
stats[key] = 0;
} else if (typeof element === `bigint`) {
stats[key] = BigInt(0);
} else if (nodeUtils__namespace.types.isDate(element)) {
stats[key] = new Date(0);
}
}
}
return stats;
}
function convertToBigIntStats(stats) {
const bigintStats = new BigIntStatsEntry();
for (const key in stats) {
if (Object.hasOwn(stats, key)) {
const element = stats[key];
if (typeof element === `number`) {
bigintStats[key] = BigInt(element);
} else if (nodeUtils__namespace.types.isDate(element)) {
bigintStats[key] = new Date(element);
}
}
}
bigintStats.atimeNs = bigintStats.atimeMs * BigInt(1e6);
bigintStats.mtimeNs = bigintStats.mtimeMs * BigInt(1e6);
bigintStats.ctimeNs = bigintStats.ctimeMs * BigInt(1e6);
bigintStats.birthtimeNs = bigintStats.birthtimeMs * BigInt(1e6);
return bigintStats;
}
function areStatsEqual(a, b) {
if (a.atimeMs !== b.atimeMs)
return false;
if (a.birthtimeMs !== b.birthtimeMs)
return false;
if (a.blksize !== b.blksize)
return false;
if (a.blocks !== b.blocks)
return false;
if (a.ctimeMs !== b.ctimeMs)
return false;
if (a.dev !== b.dev)
return false;
if (a.gid !== b.gid)
return false;
if (a.ino !== b.ino)
return false;
if (a.isBlockDevice() !== b.isBlockDevice())
return false;
if (a.isCharacterDevice() !== b.isCharacterDevice())
return false;
if (a.isDirectory() !== b.isDirectory())
return false;
if (a.isFIFO() !== b.isFIFO())
return false;
if (a.isFile() !== b.isFile())
return false;
if (a.isSocket() !== b.isSocket())
return false;
if (a.isSymbolicLink() !== b.isSymbolicLink())
return false;
if (a.mode !== b.mode)
return false;
if (a.mtimeMs !== b.mtimeMs)
return false;
if (a.nlink !== b.nlink)
return false;
if (a.rdev !== b.rdev)
return false;
if (a.size !== b.size)
return false;
if (a.uid !== b.uid)
return false;
const aN = a;
const bN = b;
if (aN.atimeNs !== bN.atimeNs)
return false;
if (aN.mtimeNs !== bN.mtimeNs)
return false;
if (aN.ctimeNs !== bN.ctimeNs)
return false;
if (aN.birthtimeNs !== bN.birthtimeNs)
return false;
return true;
}
const PortablePath = {
root: `/`,
dot: `.`,
parent: `..`
};
const Filename = {
home: `~`,
nodeModules: `node_modules`,
manifest: `package.json`,
lockfile: `yarn.lock`,
virtual: `__virtual__`,
pnpJs: `.pnp.js`,
pnpCjs: `.pnp.cjs`,
pnpData: `.pnp.data.json`,
pnpEsmLoader: `.pnp.loader.mjs`,
rc: `.yarnrc.yml`,
env: `.env`
};
const npath = Object.create(path__default.default);
const ppath = Object.create(path__default.default.posix);
npath.cwd = () => process.cwd();
ppath.cwd = process.platform === `win32` ? () => toPortablePath(process.cwd()) : process.cwd;
if (process.platform === `win32`) {
ppath.resolve = (...segments) => {
if (segments.length > 0 && ppath.isAbsolute(segments[0])) {
return path__default.default.posix.resolve(...segments);
} else {
return path__default.default.posix.resolve(ppath.cwd(), ...segments);
}
};
}
const contains = function(pathUtils, from, to) {
from = pathUtils.normalize(from);
to = pathUtils.normalize(to);
if (from === to)
return `.`;
if (!from.endsWith(pathUtils.sep))
from = from + pathUtils.sep;
if (to.startsWith(from)) {
return to.slice(from.length);
} else {
return null;
}
};
npath.contains = (from, to) => contains(npath, from, to);
ppath.contains = (from, to) => contains(ppath, from, to);
const WINDOWS_PATH_REGEXP = /^([a-zA-Z]:.*)$/;
const UNC_WINDOWS_PATH_REGEXP = /^\/\/(\.\/)?(.*)$/;
const PORTABLE_PATH_REGEXP = /^\/([a-zA-Z]:.*)$/;
const UNC_PORTABLE_PATH_REGEXP = /^\/unc\/(\.dot\/)?(.*)$/;
function fromPortablePathWin32(p) {
let portablePathMatch, uncPortablePathMatch;
if (portablePathMatch = p.match(PORTABLE_PATH_REGEXP))
p = portablePathMatch[1];
else if (uncPortablePathMatch = p.match(UNC_PORTABLE_PATH_REGEXP))
p = `\\\\${uncPortablePathMatch[1] ? `.\\` : ``}${uncPortablePathMatch[2]}`;
else
return p;
return p.replace(/\//g, `\\`);
}
function toPortablePathWin32(p) {
p = p.replace(/\\/g, `/`);
let windowsPathMatch, uncWindowsPathMatch;
if (windowsPathMatch = p.match(WINDOWS_PATH_REGEXP))
p = `/${windowsPathMatch[1]}`;
else if (uncWindowsPathMatch = p.match(UNC_WINDOWS_PATH_REGEXP))
p = `/unc/${uncWindowsPathMatch[1] ? `.dot/` : ``}${uncWindowsPathMatch[2]}`;
return p;
}
const toPortablePath = process.platform === `win32` ? toPortablePathWin32 : (p) => p;
const fromPortablePath = process.platform === `win32` ? fromPortablePathWin32 : (p) => p;
npath.fromPortablePath = fromPortablePath;
npath.toPortablePath = toPortablePath;
function convertPath(targetPathUtils, sourcePath) {
return targetPathUtils === npath ? fromPortablePath(sourcePath) : toPortablePath(sourcePath);
}
const defaultTime = new Date(SAFE_TIME * 1e3);
const defaultTimeMs = defaultTime.getTime();
async function copyPromise(destinationFs, destination, sourceFs, source, opts) {
const normalizedDestination = destinationFs.pathUtils.normalize(destination);
const normalizedSource = sourceFs.pathUtils.normalize(source);
const prelayout = [];
const postlayout = [];
const { atime, mtime } = opts.stableTime ? { atime: defaultTime, mtime: defaultTime } : await sourceFs.lstatPromise(normalizedSource);
await destinationFs.mkdirpPromise(destinationFs.pathUtils.dirname(destination), { utimes: [atime, mtime] });
await copyImpl(prelayout, postlayout, destinationFs, normalizedDestination, sourceFs, normalizedSource, { ...opts, didParentExist: true });
for (const operation of prelayout)
await operation();
await Promise.all(postlayout.map((operation) => {
return operation();
}));
}
async function copyImpl(prelayout, postlayout, destinationFs, destination, sourceFs, source, opts) {
const destinationStat = opts.didParentExist ? await maybeLStat(destinationFs, destination) : null;
const sourceStat = await sourceFs.lstatPromise(source);
const { atime, mtime } = opts.stableTime ? { atime: defaultTime, mtime: defaultTime } : sourceStat;
let updated;
switch (true) {
case sourceStat.isDirectory():
{
updated = await copyFolder(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts);
}
break;
case sourceStat.isFile():
{
updated = await copyFile(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts);
}
break;
case sourceStat.isSymbolicLink():
{
updated = await copySymlink(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts);
}
break;
default: {
throw new Error(`Unsupported file type (${sourceStat.mode})`);
}
}
if (opts.linkStrategy?.type !== `HardlinkFromIndex` || !sourceStat.isFile()) {
if (updated || destinationStat?.mtime?.getTime() !== mtime.getTime() || destinationStat?.atime?.getTime() !== atime.getTime()) {
postlayout.push(() => destinationFs.lutimesPromise(destination, atime, mtime));
updated = true;
}
if (destinationStat === null || (destinationStat.mode & 511) !== (sourceStat.mode & 511)) {
postlayout.push(() => destinationFs.chmodPromise(destination, sourceStat.mode & 511));
updated = true;
}
}
return updated;
}
async function maybeLStat(baseFs, p) {
try {
return await baseFs.lstatPromise(p);
} catch (e) {
return null;
}
}
async function copyFolder(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts) {
if (destinationStat !== null && !destinationStat.isDirectory()) {
if (opts.overwrite) {
prelayout.push(async () => destinationFs.removePromise(destination));
destinationStat = null;
} else {
return false;
}
}
let updated = false;
if (destinationStat === null) {
prelayout.push(async () => {
try {
await destinationFs.mkdirPromise(destination, { mode: sourceStat.mode });
} catch (err) {
if (err.code !== `EEXIST`) {
throw err;
}
}
});
updated = true;
}
const entries = await sourceFs.readdirPromise(source);
const nextOpts = opts.didParentExist && !destinationStat ? { ...opts, didParentExist: false } : opts;
if (opts.stableSort) {
for (const entry of entries.sort()) {
if (await copyImpl(prelayout, postlayout, destinationFs, destinationFs.pathUtils.join(destination, entry), sourceFs, sourceFs.pathUtils.join(source, entry), nextOpts)) {
updated = true;
}
}
} else {
const entriesUpdateStatus = await Promise.all(entries.map(async (entry) => {
await copyImpl(prelayout, postlayout, destinationFs, destinationFs.pathUtils.join(destination, entry), sourceFs, sourceFs.pathUtils.join(source, entry), nextOpts);
}));
if (entriesUpdateStatus.some((status) => status)) {
updated = true;
}
}
return updated;
}
async function copyFileViaIndex(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts, linkStrategy) {
const sourceHash = await sourceFs.checksumFilePromise(source, { algorithm: `sha1` });
const defaultMode = 420;
const sourceMode = sourceStat.mode & 511;
const indexFileName = `${sourceHash}${sourceMode !== defaultMode ? sourceMode.toString(8) : ``}`;
const indexPath = destinationFs.pathUtils.join(linkStrategy.indexPath, sourceHash.slice(0, 2), `${indexFileName}.dat`);
let AtomicBehavior;
((AtomicBehavior2) => {
AtomicBehavior2[AtomicBehavior2["Lock"] = 0] = "Lock";
AtomicBehavior2[AtomicBehavior2["Rename"] = 1] = "Rename";
})(AtomicBehavior || (AtomicBehavior = {}));
let atomicBehavior = 1 /* Rename */;
let indexStat = await maybeLStat(destinationFs, indexPath);
if (destinationStat) {
const isDestinationHardlinkedFromIndex = indexStat && destinationStat.dev === indexStat.dev && destinationStat.ino === indexStat.ino;
const isIndexModified = indexStat?.mtimeMs !== defaultTimeMs;
if (isDestinationHardlinkedFromIndex) {
if (isIndexModified && linkStrategy.autoRepair) {
atomicBehavior = 0 /* Lock */;
indexStat = null;
}
}
if (!isDestinationHardlinkedFromIndex) {
if (opts.overwrite) {
prelayout.push(async () => destinationFs.removePromise(destination));
destinationStat = null;
} else {
return false;
}
}
}
const tempPath = !indexStat && atomicBehavior === 1 /* Rename */ ? `${indexPath}.${Math.floor(Math.random() * 4294967296).toString(16).padStart(8, `0`)}` : null;
let tempPathCleaned = false;
prelayout.push(async () => {
if (!indexStat) {
if (atomicBehavior === 0 /* Lock */) {
await destinationFs.lockPromise(indexPath, async () => {
const content = await sourceFs.readFilePromise(source);
await destinationFs.writeFilePromise(indexPath, content);
});
}
if (atomicBehavior === 1 /* Rename */ && tempPath) {
const content = await sourceFs.readFilePromise(source);
await destinationFs.writeFilePromise(tempPath, content);
try {
await destinationFs.linkPromise(tempPath, indexPath);
} catch (err) {
if (err.code === `EEXIST`) {
tempPathCleaned = true;
await destinationFs.unlinkPromise(tempPath);
} else {
throw err;
}
}
}
}
if (!destinationStat) {
await destinationFs.linkPromise(indexPath, destination);
}
});
postlayout.push(async () => {
if (!indexStat) {
await destinationFs.lutimesPromise(indexPath, defaultTime, defaultTime);
if (sourceMode !== defaultMode) {
await destinationFs.chmodPromise(indexPath, sourceMode);
}
}
if (tempPath && !tempPathCleaned) {
await destinationFs.unlinkPromise(tempPath);
}
});
return false;
}
async function copyFileDirect(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts) {
if (destinationStat !== null) {
if (opts.overwrite) {
prelayout.push(async () => destinationFs.removePromise(destination));
destinationStat = null;
} else {
return false;
}
}
prelayout.push(async () => {
const content = await sourceFs.readFilePromise(source);
await destinationFs.writeFilePromise(destination, content);
});
return true;
}
async function copyFile(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts) {
if (opts.linkStrategy?.type === `HardlinkFromIndex`) {
return copyFileViaIndex(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts, opts.linkStrategy);
} else {
return copyFileDirect(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts);
}
}
async function copySymlink(prelayout, postlayout, destinationFs, destination, destinationStat, sourceFs, source, sourceStat, opts) {
if (destinationStat !== null) {
if (opts.overwrite) {
prelayout.push(async () => destinationFs.removePromise(destination));
destinationStat = null;
} else {
return false;
}
}
prelayout.push(async () => {
await destinationFs.symlinkPromise(convertPath(destinationFs.pathUtils, await sourceFs.readlinkPromise(source)), destination);
});
return true;
}
class CustomDir {
constructor(path, nextDirent, opts = {}) {
this.path = path;
this.nextDirent = nextDirent;
this.opts = opts;
this.closed = false;
}
throwIfClosed() {
if (this.closed) {
throw ERR_DIR_CLOSED();
}
}
async *[Symbol.asyncIterator]() {
try {
let dirent;
while ((dirent = await this.read()) !== null) {
yield dirent;
}
} finally {
await this.close();
}
}
read(cb) {
const dirent = this.readSync();
if (typeof cb !== `undefined`)
return cb(null, dirent);
return Promise.resolve(dirent);
}
readSync() {
this.throwIfClosed();
return this.nextDirent();
}
close(cb) {
this.closeSync();
if (typeof cb !== `undefined`)
return cb(null);
return Promise.resolve();
}
closeSync() {
this.throwIfClosed();
this.opts.onClose?.();
this.closed = true;
}
}
function opendir(fakeFs, path, entries, opts) {
const nextDirent = () => {
const filename = entries.shift();
if (typeof filename === `undefined`)
return null;
const entryPath = fakeFs.pathUtils.join(path, filename);
return Object.assign(fakeFs.statSync(entryPath), {
name: filename,
path: void 0
});
};
return new CustomDir(path, nextDirent, opts);
}
function assertStatus(current, expected) {
if (current !== expected) {
throw new Error(`Invalid StatWatcher status: expected '${expected}', got '${current}'`);
}
}
class CustomStatWatcher extends events.EventEmitter {
constructor(fakeFs, path, { bigint = false } = {}) {
super();
this.status = "ready" /* Ready */;
this.changeListeners = /* @__PURE__ */ new Map();
this.startTimeout = null;
this.fakeFs = fakeFs;
this.path = path;
this.bigint = bigint;
this.lastStats = this.stat();
}
static create(fakeFs, path, opts) {
const statWatcher = new CustomStatWatcher(fakeFs, path, opts);
statWatcher.start();
return statWatcher;
}
start() {
assertStatus(this.status, "ready" /* Ready */);
this.status = "running" /* Running */;
this.startTimeout = setTimeout(() => {
this.startTimeout = null;
if (!this.fakeFs.existsSync(this.path)) {
this.emit("change" /* Change */, this.lastStats, this.lastStats);
}
}, 3);
}
stop() {
assertStatus(this.status, "running" /* Running */);
this.status = "stopped" /* Stopped */;
if (this.startTimeout !== null) {
clearTimeout(this.startTimeout);
this.startTimeout = null;
}
this.emit("stop" /* Stop */);
}
stat() {
try {
return this.fakeFs.statSync(this.path, { bigint: this.bigint });
} catch (error) {
const statInstance = this.bigint ? new BigIntStatsEntry() : new StatEntry();
return clearStats(statInstance);
}
}
makeInterval(opts) {
const interval = setInterval(() => {
const currentStats = this.stat();
const previousStats = this.lastStats;
if (areStatsEqual(currentStats, previousStats))
return;
this.lastStats = currentStats;
this.emit("change" /* Change */, currentStats, previousStats);
}, opts.interval);
return opts.persistent ? interval : interval.unref();
}
registerChangeListener(listener, opts) {
this.addListener("change" /* Change */, listener);
this.changeListeners.set(listener, this.makeInterval(opts));
}
unregisterChangeListener(listener) {
this.removeListener("change" /* Change */, listener);
const interval = this.changeListeners.get(listener);
if (typeof interval !== `undefined`)
clearInterval(interval);
this.changeListeners.delete(listener);
}
unregisterAllChangeListeners() {
for (const listener of this.changeListeners.keys()) {
this.unregisterChangeListener(listener);
}
}
hasChangeListeners() {
return this.changeListeners.size > 0;
}
ref() {
for (const interval of this.changeListeners.values())
interval.ref();
return this;
}
unref() {
for (const interval of this.changeListeners.values())
interval.unref();
return this;
}
}
const statWatchersByFakeFS = /* @__PURE__ */ new WeakMap();
function watchFile(fakeFs, path, a, b) {
let bigint;
let persistent;
let interval;
let listener;
switch (typeof a) {
case `function`:
{
bigint = false;
persistent = true;
interval = 5007;
listener = a;
}
break;
default:
{
({
bigint = false,
persistent = true,
interval = 5007
} = a);
listener = b;
}
break;
}
let statWatchers = statWatchersByFakeFS.get(fakeFs);
if (typeof statWatchers === `undefined`)
statWatchersByFakeFS.set(fakeFs, statWatchers = /* @__PURE__ */ new Map());
let statWatcher = statWatchers.get(path);
if (typeof statWatcher === `undefined`) {
statWatcher = CustomStatWatcher.create(fakeFs, path, { bigint });
statWatchers.set(path, statWatcher);
}
statWatcher.registerChangeListener(listener, { persistent, interval });
return statWatcher;
}
function unwatchFile(fakeFs, path, cb) {
const statWatchers = statWatchersByFakeFS.get(fakeFs);
if (typeof statWatchers === `undefined`)
return;
const statWatcher = statWatchers.get(path);
if (typeof statWatcher === `undefined`)
return;
if (typeof cb === `undefined`)
statWatcher.unregisterAllChangeListeners();
else
statWatcher.unregisterChangeListener(cb);
if (!statWatcher.hasChangeListeners()) {
statWatcher.stop();
statWatchers.delete(path);
}
}
function unwatchAllFiles(fakeFs) {
const statWatchers = statWatchersByFakeFS.get(fakeFs);
if (typeof statWatchers === `undefined`)
return;
for (const path of statWatchers.keys()) {
unwatchFile(fakeFs, path);
}
}
class FakeFS {
constructor(pathUtils) {
this.pathUtils = pathUtils;
}
async *genTraversePromise(init, { stableSort = false } = {}) {
const stack = [init];
while (stack.length > 0) {
const p = stack.shift();
const entry = await this.lstatPromise(p);
if (entry.isDirectory()) {
const entries = await this.readdirPromise(p);
if (stableSort) {
for (const entry2 of entries.sort()) {
stack.push(this.pathUtils.join(p, entry2));
}
} else {
throw new Error(`Not supported`);
}
} else {
yield p;
}
}
}
async checksumFilePromise(path, { algorithm = `sha512` } = {}) {
const fd = await this.openPromise(path, `r`);
try {
const CHUNK_SIZE = 65536;
const chunk = Buffer.allocUnsafeSlow(CHUNK_SIZE);
const hash = crypto.createHash(algorithm);
let bytesRead = 0;
while ((bytesRead = await this.readPromise(fd, chunk, 0, CHUNK_SIZE)) !== 0)
hash.update(bytesRead === CHUNK_SIZE ? chunk : chunk.slice(0, bytesRead));
return hash.digest(`hex`);
} finally {
await this.closePromise(fd);
}
}
async removePromise(p, { recursive = true, maxRetries = 5 } = {}) {
let stat;
try {
stat = await this.lstatPromise(p);
} catch (error) {
if (error.code === `ENOENT`) {
return;
} else {
throw error;
}
}
if (stat.isDirectory()) {
if (recursive) {
const entries = await this.readdirPromise(p);
await Promise.all(entries.map((entry) => {
return this.removePromise(this.pathUtils.resolve(p, entry));
}));
}
for (let t = 0; t <= maxRetries; t++) {
try {
await this.rmdirPromise(p);
break;
} catch (error) {
if (error.code !== `EBUSY` && error.code !== `ENOTEMPTY`) {
throw error;
} else if (t < maxRetries) {
await new Promise((resolve) => setTimeout(resolve, t * 100));
}
}
}
} else {
await this.unlinkPromise(p);
}
}
removeSync(p, { recursive = true } = {}) {
let stat;
try {
stat = this.lstatSync(p);
} catch (error) {
if (error.code === `ENOENT`) {
return;
} else {
throw error;
}
}
if (stat.isDirectory()) {
if (recursive)
for (const entry of this.readdirSync(p))
this.removeSync(this.pathUtils.resolve(p, entry));
this.rmdirSync(p);
} else {
this.unlinkSync(p);
}
}
async mkdirpPromise(p, { chmod, utimes } = {}) {
p = this.resolve(p);
if (p === this.pathUtils.dirname(p))
return void 0;
const parts = p.split(this.pathUtils.sep);
let createdDirectory;
for (let u = 2; u <= parts.length; ++u) {
const subPath = parts.slice(0, u).join(this.pathUtils.sep);
if (!this.existsSync(subPath)) {
try {
await this.mkdirPromise(subPath);
} catch (error) {
if (error.code === `EEXIST`) {
continue;
} else {
throw error;
}
}
createdDirectory ??= subPath;
if (chmod != null)
await this.chmodPromise(subPath, chmod);
if (utimes != null) {
await this.utimesPromise(subPath, utimes[0], utimes[1]);
} else {
const parentStat = await this.statPromise(this.pathUtils.dirname(subPath));
await this.utimesPromise(subPath, parentStat.atime, parentStat.mtime);
}
}
}
return createdDirectory;
}
mkdirpSync(p, { chmod, utimes } = {}) {
p = this.resolve(p);
if (p === this.pathUtils.dirname(p))
return void 0;
const parts = p.split(this.pathUtils.sep);
let createdDirectory;
for (let u = 2; u <= parts.length; ++u) {
const subPath = parts.slice(0, u).join(this.pathUtils.sep);
if (!this.existsSync(subPath)) {
try {
this.mkdirSync(subPath);
} catch (error) {
if (error.code === `EEXIST`) {
continue;
} else {
throw error;
}
}
createdDirectory ??= subPath;
if (chmod != null)
this.chmodSync(subPath, chmod);
if (utimes != null) {
this.utimesSync(subPath, utimes[0], utimes[1]);
} else {
const parentStat = this.statSync(this.pathUtils.dirname(subPath));
this.utimesSync(subPath, parentStat.atime, parentStat.mtime);
}
}
}
return createdDirectory;
}
async copyPromise(destination, source, { baseFs = this, overwrite = true, stableSort = false, stableTime = false, linkStrategy = null } = {}) {
return await copyPromise(this, destination, baseFs, source, { overwrite, stableSort, stableTime, linkStrategy });
}
copySync(destination, source, { baseFs = this, overwrite = true } = {}) {
const stat = baseFs.lstatSync(source);
const exists = this.existsSync(destination);
if (stat.isDirectory()) {
this.mkdirpSync(destination);
const directoryListing = baseFs.readdirSync(source);
for (const entry of directoryListing) {
this.copySync(this.pathUtils.join(destination, entry), baseFs.pathUtils.join(source, entry), { baseFs, overwrite });
}
} else if (stat.isFile()) {
if (!exists || overwrite) {
if (exists)
this.removeSync(destination);
const content = baseFs.readFileSync(source);
this.writeFileSync(destination, content);
}
} else if (stat.isSymbolicLink()) {
if (!exists || overwrite) {
if (exists)
this.removeSync(destination);
const target = baseFs.readlinkSync(source);
this.symlinkSync(convertPath(this.pathUtils, target), destination);
}
} else {
throw new Error(`Unsupported file type (file: ${source}, mode: 0o${stat.mode.toString(8).padStart(6, `0`)})`);
}
const mode = stat.mode & 511;
this.chmodSync(destination, mode);
}
async changeFilePromise(p, content, opts = {}) {
if (Buffer.isBuffer(content)) {
return this.changeFileBufferPromise(p, content, opts);
} else {
return this.changeFileTextPromise(p, content, opts);
}
}
async changeFileBufferPromise(p, content, { mode } = {}) {
let current = Buffer.alloc(0);
try {
current = await this.readFilePromise(p);
} catch (error) {
}
if (Buffer.compare(current, content) === 0)
return;
await this.writeFilePromise(p, content, { mode });
}
async changeFileTextPromise(p, content, { automaticNewlines, mode } = {}) {
let current = ``;
try {
current = await this.readFilePromise(p, `utf8`);
} catch (error) {
}
const normalizedContent = automaticNewlines ? normalizeLineEndings(current, content) : content;
if (current === normalizedContent)
return;
await this.writeFilePromise(p, normalizedContent, { mode });
}
changeFileSync(p, content, opts = {}) {
if (Buffer.isBuffer(content)) {
return this.changeFileBufferSync(p, content, opts);
} else {
return this.changeFileTextSync(p, content, opts);
}
}
changeFileBufferSync(p, content, { mode } = {}) {
let current = Buffer.alloc(0);
try {
current = this.readFileSync(p);
} catch (error) {
}
if (Buffer.compare(current, content) === 0)
return;
this.writeFileSync(p, content, { mode });
}
changeFileTextSync(p, content, { automaticNewlines = false, mode } = {}) {
let current = ``;
try {
current = this.readFileSync(p, `utf8`);
} catch (error) {
}
const normalizedContent = automaticNewlines ? normalizeLineEndings(current, content) : content;
if (current === normalizedContent)
return;
this.writeFileSync(p, normalizedContent, { mode });
}
async movePromise(fromP, toP) {
try {
await this.renamePromise(fromP, toP);
} catch (error) {
if (error.code === `EXDEV`) {
await this.copyPromise(toP, fromP);
await this.removePromise(fromP);
} else {
throw error;
}
}
}
moveSync(fromP, toP) {
try {
this.renameSync(fromP, toP);
} catch (error) {
if (error.code === `EXDEV`) {
this.copySync(toP, fromP);
this.removeSync(fromP);
} else {
throw error;
}
}
}
async lockPromise(affectedPath, callback) {
const lockPath = `${affectedPath}.flock`;
const interval = 1e3 / 60;
const startTime = Date.now();
let fd = null;
const isAlive = async () => {
let pid;
try {
[pid] = await this.readJsonPromise(lockPath);
} catch (error) {
return Date.now() - startTime < 500;
}
try {
process.kill(pid, 0);
return true;
} catch (error) {
return false;
}
};
while (fd === null) {
try {
fd = await this.openPromise(lockPath, `wx`);
} catch (error) {
if (error.code === `EEXIST`) {
if (!await isAlive()) {
try {
await this.unlinkPromise(lockPath);
continue;
} catch (error2) {
}
}
if (Date.now() - startTime < 60 * 1e3) {
await new Promise((resolve) => setTimeout(resolve, interval));
} else {
throw new Error(`Couldn't acquire a lock in a reasonable time (via ${lockPath})`);
}
} else {
throw error;
}
}
}
await this.writePromise(fd, JSON.stringify([process.pid]));
try {
return await callback();
} finally {
try {
await this.closePromise(fd);
await this.unlinkPromise(lockPath);
} catch (error) {
}
}
}
async readJsonPromise(p) {
const content = await this.readFilePromise(p, `utf8`);
try {
return JSON.parse(content);
} catch (error) {
error.message += ` (in ${p})`;
throw error;
}
}
readJsonSync(p) {
const content = this.readFileSync(p, `utf8`);
try {
return JSON.parse(content);
} catch (error) {
error.message += ` (in ${p})`;
throw error;
}
}
async writeJsonPromise(p, data, { compact = false } = {}) {
const space = compact ? 0 : 2;
return await this.writeFilePromise(p, `${JSON.stringify(data, null, space)}
`);
}
writeJsonSync(p, data, { compact = false } = {}) {
const space = compact ? 0 : 2;
return this.writeFileSync(p, `${JSON.stringify(data, null, space)}
`);
}
async preserveTimePromise(p, cb) {
const stat = await this.lstatPromise(p);
const result = await cb();
if (typeof result !== `undefined`)
p = result;
await this.lutimesPromise(p, stat.atime, stat.mtime);
}
async preserveTimeSync(p, cb) {
const stat = this.lstatSync(p);
const result = cb();
if (typeof result !== `undefined`)
p = result;
this.lutimesSync(p, stat.atime, stat.mtime);
}
}
class BasePortableFakeFS extends FakeFS {
constructor() {
super(ppath);
}
}
function getEndOfLine(content) {
const matches = content.match(/\r?\n/g);
if (matches === null)
return os.EOL;
const crlf = matches.filter((nl) => nl === `\r
`).length;
const lf = matches.length - crlf;
return crlf > lf ? `\r
` : `
`;
}
function normalizeLineEndings(originalContent, newContent) {
return newContent.replace(/\r?\n/g, getEndOfLine(originalContent));
}
class ProxiedFS extends FakeFS {
getExtractHint(hints) {
return this.baseFs.getExtractHint(hints);
}
resolve(path) {
return this.mapFromBase(this.baseFs.resolve(this.mapToBase(path)));
}
getRealPath() {
return this.mapFromBase(this.baseFs.getRealPath());
}
async openPromise(p, flags, mode) {
return this.baseFs.openPromise(this.mapToBase(p), flags, mode);
}
openSync(p, flags, mode) {
return this.baseFs.openSync(this.mapToBase(p), flags, mode);
}
async opendirPromise(p, opts) {
return Object.assign(await this.baseFs.opendirPromise(this.mapToBase(p), opts), { path: p });
}
opendirSync(p, opts) {
return Object.assign(this.baseFs.opendirSync(this.mapToBase(p), opts), { path: p });
}
async readPromise(fd, buffer, offset, length, position) {
return await this.baseFs.readPromise(fd, buffer, offset, length, position);
}
readSync(fd, buffer, offset, length, position) {
return this.baseFs.readSync(fd, buffer, offset, length, position);
}
async writePromise(fd, buffer, offset, length, position) {
if (typeof buffer === `string`) {
return await this.baseFs.writePromise(fd, buffer, offset);
} else {
return await this.baseFs.writePromise(fd, buffer, offset, length, position);
}
}
writeSync(fd, buffer, offset, length, position) {
if (typeof buffer === `string`) {
return this.baseFs.writeSync(fd, buffer, offset);
} else {
return this.baseFs.writeSync(fd, buffer, offset, length, position);
}
}
async closePromise(fd) {
return this.baseFs.closePromise(fd);
}
closeSync(fd) {
this.baseFs.closeSync(fd);
}
createReadStream(p, opts) {
return this.baseFs.createReadStream(p !== null ? this.mapToBase(p) : p, opts);
}
createWriteStream(p, opts) {
return this.baseFs.createWriteStream(p !== null ? this.mapToBase(p) : p, opts);
}
async realpathPromise(p) {
return this.mapFromBase(await this.baseFs.realpathPromise(this.mapToBase(p)));
}
realpathSync(p) {
return this.mapFromBase(this.baseFs.realpathSync(this.mapToBase(p)));
}
async existsPromise(p) {
return this.baseFs.existsPromise(this.mapToBase(p));
}
existsSync(p) {
return this.baseFs.existsSync(this.mapToBase(p));
}
accessSync(p, mode) {
return this.baseFs.accessSync(this.mapToBase(p), mode);
}
async accessPromise(p, mode) {
return this.baseFs.accessPromise(this.mapToBase(p), mode);
}
async statPromise(p, opts) {
return this.baseFs.statPromise(this.mapToBase(p), opts);
}
statSync(p, opts) {
return this.baseFs.statSync(this.mapToBase(p), opts);
}
async fstatPromise(fd, opts) {
return this.baseFs.fstatPromise(fd, opts);
}
fstatSync(fd, opts) {
return this.baseFs.fstatSync(fd, opts);
}
lstatPromise(p, opts) {
return this.baseFs.lstatPromise(this.mapToBase(p), opts);
}
lstatSync(p, opts) {
return this.baseFs.lstatSync(this.mapToBase(p), opts);
}
async fchmodPromise(fd, mask) {
return this.baseFs.fchmodPromise(fd, mask);
}
fchmodSync(fd, mask) {
return this.baseFs.fchmodSync(fd, mask);
}
async chmodPromise(p, mask) {
return this.baseFs.chmodPromise(this.mapToBase(p), mask);
}
chmodSync(p, mask) {
return this.baseFs.chmodSync(this.mapToBase(p), mask);
}
async fchownPromise(fd, uid, gid) {
return this.baseFs.fchownPromise(fd, uid, gid);
}
fchownSync(fd, uid, gid) {
return this.baseFs.fchownSync(fd, uid, gid);
}
async chownPromise(p, uid, gid) {
return this.baseFs.chownPromise(this.mapToBase(p), uid, gid);
}
chownSync(p, uid, gid) {
return this.baseFs.chownSync(this.mapToBase(p), uid, gid);
}
async renamePromise(oldP, newP) {
return this.baseFs.renamePromise(this.mapToBase(oldP), this.mapToBase(newP));
}
renameSync(oldP, newP) {
return this.baseFs.renameSync(this.mapToBase(oldP), this.mapToBase(newP));
}
async copyFilePromise(sourceP, destP, flags = 0) {
return this.baseFs.copyFilePromise(this.mapToBase(sourceP), this.mapToBase(destP), flags);
}
copyFileSync(sourceP, destP, flags = 0) {
return this.baseFs.copyFileSync(this.mapToBase(sourceP), this.mapToBase(destP), flags);
}
async appendFilePromise(p, content, opts) {
return this.baseFs.appendFilePromise(this.fsMapToBase(p), content, opts);
}
appendFileSync(p, content, opts) {
return this.baseFs.appendFileSync(this.fsMapToBase(p), content, opts);
}
async writeFilePromise(p, content, opts) {
return this.baseFs.writeFilePromise(this.fsMapToBase(p), content, opts);
}
writeFileSync(p, content, opts) {
return this.baseFs.writeFileSync(this.fsMapToBase(p), content, opts);
}
async unlinkPromise(p) {
return this.baseFs.unlinkPromise(this.mapToBase(p));
}
unlinkSync(p) {
return this.baseFs.unlinkSync(this.mapToBase(p));
}
async utimesPromise(p, atime, mtime) {
return this.baseFs.utimesPromise(this.mapToBase(p), atime, mtime);
}
utimesSync(p, atime, mtime) {
return this.baseFs.utimesSync(this.mapToBase(p), atime, mtime);
}
async lutimesPromise(p, atime, mtime) {
return this.baseFs.lutimesPromise(this.mapToBase(p), atime, mtime);
}
lutimesSync(p, atime, mtime) {
return this.baseFs.lutimesSync(this.mapToBase(p), atime, mtime);
}
async mkdirPromise(p, opts) {
return this.baseFs.mkdirPromise(this.mapToBase(p), opts);
}
mkdirSync(p, opts) {
return this.baseFs.mkdirSync(this.mapToBase(p), opts);
}
async rmdirPromise(p, opts) {
return this.baseFs.rmdirPromise(this.mapToBase(p), opts);
}
rmdirSync(p, opts) {
return this.baseFs.rmdirSync(this.mapToBase(p), opts);
}
async linkPromise(existingP, newP) {
return this.baseFs.linkPromise(this.mapToBase(existingP), this.mapToBase(newP));
}
linkSync(existingP, newP) {
return this.baseFs.linkSync(this.mapToBase(existingP), this.mapToBase(newP));
}
async symlinkPromise(target, p, type) {
const mappedP = this.mapToBase(p);
if (this.pathUtils.isAbsolute(target))
return this.baseFs.symlinkPromise(this.mapToBase(target), mappedP, type);
const mappedAbsoluteTarget = this.mapToBase(this.pathUtils.join(this.pathUtils.dirname(p), target));
const mappedTarget = this.baseFs.pathUtils.relative(this.baseFs.pathUtils.dirname(mappedP), mappedAbsoluteTarget);
return this.baseFs.symlinkPromise(mappedTarget, mappedP, type);
}
symlinkSync(target, p, type) {
const mappedP = this.mapToBase(p);
if (this.pathUtils.isAbsolute(target))
return this.baseFs.symlinkSync(this.mapToBase(target), mappedP, type);
const mappedAbsoluteTarget = this.mapToBase(this.pathUtils.join(this.pathUtils.dirname(p), target));
const mappedTarget = this.baseFs.pathUtils.relative(this.baseFs.pathUtils.dirname(mappedP), mappedAbsoluteTarget);
return this.baseFs.symlinkSync(mappedTarget, mappedP, type);
}
async readFilePromise(p, encoding) {
return this.baseFs.readFilePromise(this.fsMapToBase(p), encoding);
}
readFileSync(p, encoding) {
return this.baseFs.readFileSync(this.fsMapToBase(p), encoding);
}
readdirPromise(p, opts) {
return this.baseFs.readdirPromise(this.mapToBase(p), opts);
}
readdirSync(p, opts) {
return this.baseFs.readdirSync(this.mapToBase(p), opts);
}
async readlinkPromise(p) {
return this.mapFromBase(await this.baseFs.readlinkPromise(this.mapToBase(p)));
}
readlinkSync(p) {
return this.mapFromBase(this.baseFs.readlinkSync(this.mapToBase(p)));
}
async truncatePromise(p, len) {
return this.baseFs.truncatePromise(this.mapToBase(p), len);
}
truncateSync(p, len) {
return this.baseFs.truncateSync(this.mapToBase(p), len);
}
async ftruncatePromise(fd, len) {
return this.baseFs.ftruncatePromise(fd, len);
}
ftruncateSync(fd, len) {
return this.baseFs.ftruncateSync(fd, len);
}
watch(p, a, b) {
return this.baseFs.watch(
this.mapToBase(p),
a,
b
);
}
watchFile(p, a, b) {
return this.baseFs.watchFile(
this.mapToBase(p),
a,
b
);
}
unwatchFile(p, cb) {
return this.baseFs.unwatchFile(this.mapToBase(p), cb);
}
fsMapToBase(p) {
if (typeof p === `number`) {
return p;
} else {
return this.mapToBase(p);
}
}
}
function direntToPortable(dirent) {
const portableDirent = dirent;
if