@modern-js/utils
Version:
A Progressive React Framework for modern web development.
1,321 lines (1,320 loc) • 86.4 kB
JavaScript
(()=>{
var e = {
571: (e, t, r)=>{
"use strict";
const n = r(127);
const i = r(17);
const o = r(971).mkdirsSync;
const c = r(309).utimesMillisSync;
const s = r(883);
function copySync(e, t, r) {
if ("function" == typeof r) r = {
filter: r
};
r = r || {};
r.clobber = "clobber" in r ? !!r.clobber : true;
r.overwrite = "overwrite" in r ? !!r.overwrite : r.clobber;
if (r.preserveTimestamps && "ia32" === process.arch) console.warn(`fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269`);
const { srcStat: n, destStat: i } = s.checkPathsSync(e, t, "copy", r);
s.checkParentPathsSync(e, n, t, "copy");
return handleFilterAndCopy(i, e, t, r);
}
function handleFilterAndCopy(e, t, r, c) {
if (c.filter && !c.filter(t, r)) return;
const s = i.dirname(r);
if (!n.existsSync(s)) o(s);
return getStats(e, t, r, c);
}
function startCopy(e, t, r, n) {
if (n.filter && !n.filter(t, r)) return;
return getStats(e, t, r, n);
}
function getStats(e, t, r, i) {
const o = i.dereference ? n.statSync : n.lstatSync;
const c = o(t);
if (c.isDirectory()) return onDir(c, e, t, r, i);
if (c.isFile() || c.isCharacterDevice() || c.isBlockDevice()) return onFile(c, e, t, r, i);
if (c.isSymbolicLink()) return onLink(e, t, r, i);
if (c.isSocket()) throw new Error(`Cannot copy a socket file: ${t}`);
if (c.isFIFO()) throw new Error(`Cannot copy a FIFO pipe: ${t}`);
throw new Error(`Unknown file: ${t}`);
}
function onFile(e, t, r, n, i) {
if (!t) return copyFile(e, r, n, i);
return mayCopyFile(e, r, n, i);
}
function mayCopyFile(e, t, r, i) {
if (i.overwrite) {
n.unlinkSync(r);
return copyFile(e, t, r, i);
}
if (i.errorOnExist) throw new Error(`'${r}' already exists`);
}
function copyFile(e, t, r, i) {
n.copyFileSync(t, r);
if (i.preserveTimestamps) handleTimestamps(e.mode, t, r);
return setDestMode(r, e.mode);
}
function handleTimestamps(e, t, r) {
if (fileIsNotWritable(e)) makeFileWritable(r, e);
return setDestTimestamps(t, r);
}
function fileIsNotWritable(e) {
return (128 & e) === 0;
}
function makeFileWritable(e, t) {
return setDestMode(e, 128 | t);
}
function setDestMode(e, t) {
return n.chmodSync(e, t);
}
function setDestTimestamps(e, t) {
const r = n.statSync(e);
return c(t, r.atime, r.mtime);
}
function onDir(e, t, r, n, i) {
if (!t) return mkDirAndCopy(e.mode, r, n, i);
return copyDir(r, n, i);
}
function mkDirAndCopy(e, t, r, i) {
n.mkdirSync(r);
copyDir(t, r, i);
return setDestMode(r, e);
}
function copyDir(e, t, r) {
n.readdirSync(e).forEach((n)=>copyDirItem(n, e, t, r));
}
function copyDirItem(e, t, r, n) {
const o = i.join(t, e);
const c = i.join(r, e);
const { destStat: a } = s.checkPathsSync(o, c, "copy", n);
return startCopy(a, o, c, n);
}
function onLink(e, t, r, o) {
let c = n.readlinkSync(t);
if (o.dereference) c = i.resolve(process.cwd(), c);
if (!e) return n.symlinkSync(c, r);
{
let e;
try {
e = n.readlinkSync(r);
} catch (e) {
if ("EINVAL" === e.code || "UNKNOWN" === e.code) return n.symlinkSync(c, r);
throw e;
}
if (o.dereference) e = i.resolve(process.cwd(), e);
if (s.isSrcSubdir(c, e)) throw new Error(`Cannot copy '${c}' to a subdirectory of itself, '${e}'.`);
if (n.statSync(r).isDirectory() && s.isSrcSubdir(e, c)) throw new Error(`Cannot overwrite '${e}' with '${c}'.`);
return copyLink(c, r);
}
}
function copyLink(e, t) {
n.unlinkSync(t);
return n.symlinkSync(e, t);
}
e.exports = copySync;
},
987: (e, t, r)=>{
"use strict";
const n = r(127);
const i = r(17);
const o = r(971).mkdirs;
const c = r(725).pathExists;
const s = r(309).utimesMillis;
const a = r(883);
function copy(e, t, r, n) {
if ("function" != typeof r || n) {
if ("function" == typeof r) r = {
filter: r
};
} else {
n = r;
r = {};
}
n = n || function() {};
r = r || {};
r.clobber = "clobber" in r ? !!r.clobber : true;
r.overwrite = "overwrite" in r ? !!r.overwrite : r.clobber;
if (r.preserveTimestamps && "ia32" === process.arch) console.warn(`fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269`);
a.checkPaths(e, t, "copy", r, (i, o)=>{
if (i) return n(i);
const { srcStat: c, destStat: s } = o;
a.checkParentPaths(e, c, t, "copy", (i)=>{
if (i) return n(i);
if (r.filter) return handleFilter(checkParentDir, s, e, t, r, n);
return checkParentDir(s, e, t, r, n);
});
});
}
function checkParentDir(e, t, r, n, s) {
const a = i.dirname(r);
c(a, (i, c)=>{
if (i) return s(i);
if (c) return getStats(e, t, r, n, s);
o(a, (i)=>{
if (i) return s(i);
return getStats(e, t, r, n, s);
});
});
}
function handleFilter(e, t, r, n, i, o) {
Promise.resolve(i.filter(r, n)).then((c)=>{
if (c) return e(t, r, n, i, o);
return o();
}, (e)=>o(e));
}
function startCopy(e, t, r, n, i) {
if (n.filter) return handleFilter(getStats, e, t, r, n, i);
return getStats(e, t, r, n, i);
}
function getStats(e, t, r, i, o) {
const c = i.dereference ? n.stat : n.lstat;
c(t, (n, c)=>{
if (n) return o(n);
if (c.isDirectory()) return onDir(c, e, t, r, i, o);
if (c.isFile() || c.isCharacterDevice() || c.isBlockDevice()) return onFile(c, e, t, r, i, o);
if (c.isSymbolicLink()) return onLink(e, t, r, i, o);
if (c.isSocket()) return o(new Error(`Cannot copy a socket file: ${t}`));
if (c.isFIFO()) return o(new Error(`Cannot copy a FIFO pipe: ${t}`));
return o(new Error(`Unknown file: ${t}`));
});
}
function onFile(e, t, r, n, i, o) {
if (!t) return copyFile(e, r, n, i, o);
return mayCopyFile(e, r, n, i, o);
}
function mayCopyFile(e, t, r, i, o) {
if (i.overwrite) n.unlink(r, (n)=>{
if (n) return o(n);
return copyFile(e, t, r, i, o);
});
else if (i.errorOnExist) return o(new Error(`'${r}' already exists`));
else return o();
}
function copyFile(e, t, r, i, o) {
n.copyFile(t, r, (n)=>{
if (n) return o(n);
if (i.preserveTimestamps) return handleTimestampsAndMode(e.mode, t, r, o);
return setDestMode(r, e.mode, o);
});
}
function handleTimestampsAndMode(e, t, r, n) {
if (fileIsNotWritable(e)) return makeFileWritable(r, e, (i)=>{
if (i) return n(i);
return setDestTimestampsAndMode(e, t, r, n);
});
return setDestTimestampsAndMode(e, t, r, n);
}
function fileIsNotWritable(e) {
return (128 & e) === 0;
}
function makeFileWritable(e, t, r) {
return setDestMode(e, 128 | t, r);
}
function setDestTimestampsAndMode(e, t, r, n) {
setDestTimestamps(t, r, (t)=>{
if (t) return n(t);
return setDestMode(r, e, n);
});
}
function setDestMode(e, t, r) {
return n.chmod(e, t, r);
}
function setDestTimestamps(e, t, r) {
n.stat(e, (e, n)=>{
if (e) return r(e);
return s(t, n.atime, n.mtime, r);
});
}
function onDir(e, t, r, n, i, o) {
if (!t) return mkDirAndCopy(e.mode, r, n, i, o);
return copyDir(r, n, i, o);
}
function mkDirAndCopy(e, t, r, i, o) {
n.mkdir(r, (n)=>{
if (n) return o(n);
copyDir(t, r, i, (t)=>{
if (t) return o(t);
return setDestMode(r, e, o);
});
});
}
function copyDir(e, t, r, i) {
n.readdir(e, (n, o)=>{
if (n) return i(n);
return copyDirItems(o, e, t, r, i);
});
}
function copyDirItems(e, t, r, n, i) {
const o = e.pop();
if (!o) return i();
return copyDirItem(e, o, t, r, n, i);
}
function copyDirItem(e, t, r, n, o, c) {
const s = i.join(r, t);
const u = i.join(n, t);
a.checkPaths(s, u, "copy", o, (t, i)=>{
if (t) return c(t);
const { destStat: a } = i;
startCopy(a, s, u, o, (t)=>{
if (t) return c(t);
return copyDirItems(e, r, n, o, c);
});
});
}
function onLink(e, t, r, o, c) {
n.readlink(t, (t, s)=>{
if (t) return c(t);
if (o.dereference) s = i.resolve(process.cwd(), s);
if (!e) return n.symlink(s, r, c);
n.readlink(r, (t, u)=>{
if (t) {
if ("EINVAL" === t.code || "UNKNOWN" === t.code) return n.symlink(s, r, c);
return c(t);
}
if (o.dereference) u = i.resolve(process.cwd(), u);
if (a.isSrcSubdir(s, u)) return c(new Error(`Cannot copy '${s}' to a subdirectory of itself, '${u}'.`));
if (e.isDirectory() && a.isSrcSubdir(u, s)) return c(new Error(`Cannot overwrite '${u}' with '${s}'.`));
return copyLink(s, r, c);
});
});
}
function copyLink(e, t, r) {
n.unlink(t, (i)=>{
if (i) return r(i);
return n.symlink(e, t, r);
});
}
e.exports = copy;
},
2: (e, t, r)=>{
"use strict";
const n = r(5).fromCallback;
e.exports = {
copy: n(r(987)),
copySync: r(571)
};
},
708: (e, t, r)=>{
"use strict";
const n = r(5).fromPromise;
const i = r(812);
const o = r(17);
const c = r(971);
const s = r(95);
const a = n(async function(e) {
let t;
try {
t = await i.readdir(e);
} catch {
return c.mkdirs(e);
}
return Promise.all(t.map((t)=>s.remove(o.join(e, t))));
});
function emptyDirSync(e) {
let t;
try {
t = i.readdirSync(e);
} catch {
return c.mkdirsSync(e);
}
t.forEach((t)=>{
t = o.join(e, t);
s.removeSync(t);
});
}
e.exports = {
emptyDirSync: emptyDirSync,
emptydirSync: emptyDirSync,
emptyDir: a,
emptydir: a
};
},
102: (e, t, r)=>{
"use strict";
const n = r(5).fromCallback;
const i = r(17);
const o = r(127);
const c = r(971);
function createFile(e, t) {
function makeFile() {
o.writeFile(e, "", (e)=>{
if (e) return t(e);
t();
});
}
o.stat(e, (r, n)=>{
if (!r && n.isFile()) return t();
const s = i.dirname(e);
o.stat(s, (e, r)=>{
if (e) {
if ("ENOENT" === e.code) return c.mkdirs(s, (e)=>{
if (e) return t(e);
makeFile();
});
return t(e);
}
if (r.isDirectory()) makeFile();
else o.readdir(s, (e)=>{
if (e) return t(e);
});
});
});
}
function createFileSync(e) {
let t;
try {
t = o.statSync(e);
} catch {}
if (t && t.isFile()) return;
const r = i.dirname(e);
try {
if (!o.statSync(r).isDirectory()) o.readdirSync(r);
} catch (e) {
if (e && "ENOENT" === e.code) c.mkdirsSync(r);
else throw e;
}
o.writeFileSync(e, "");
}
e.exports = {
createFile: n(createFile),
createFileSync: createFileSync
};
},
726: (e, t, r)=>{
"use strict";
const { createFile: n, createFileSync: i } = r(102);
const { createLink: o, createLinkSync: c } = r(161);
const { createSymlink: s, createSymlinkSync: a } = r(294);
e.exports = {
createFile: n,
createFileSync: i,
ensureFile: n,
ensureFileSync: i,
createLink: o,
createLinkSync: c,
ensureLink: o,
ensureLinkSync: c,
createSymlink: s,
createSymlinkSync: a,
ensureSymlink: s,
ensureSymlinkSync: a
};
},
161: (e, t, r)=>{
"use strict";
const n = r(5).fromCallback;
const i = r(17);
const o = r(127);
const c = r(971);
const s = r(725).pathExists;
const { areIdentical: a } = r(883);
function createLink(e, t, r) {
function makeLink(e, t) {
o.link(e, t, (e)=>{
if (e) return r(e);
r(null);
});
}
o.lstat(t, (n, u)=>{
o.lstat(e, (n, o)=>{
if (n) {
n.message = n.message.replace("lstat", "ensureLink");
return r(n);
}
if (u && a(o, u)) return r(null);
const f = i.dirname(t);
s(f, (n, i)=>{
if (n) return r(n);
if (i) return makeLink(e, t);
c.mkdirs(f, (n)=>{
if (n) return r(n);
makeLink(e, t);
});
});
});
});
}
function createLinkSync(e, t) {
let r;
try {
r = o.lstatSync(t);
} catch {}
try {
const t = o.lstatSync(e);
if (r && a(t, r)) return;
} catch (e) {
e.message = e.message.replace("lstat", "ensureLink");
throw e;
}
const n = i.dirname(t);
const s = o.existsSync(n);
if (s) return o.linkSync(e, t);
c.mkdirsSync(n);
return o.linkSync(e, t);
}
e.exports = {
createLink: n(createLink),
createLinkSync: createLinkSync
};
},
332: (e, t, r)=>{
"use strict";
const n = r(17);
const i = r(127);
const o = r(725).pathExists;
function symlinkPaths(e, t, r) {
if (n.isAbsolute(e)) return i.lstat(e, (t)=>{
if (t) {
t.message = t.message.replace("lstat", "ensureSymlink");
return r(t);
}
return r(null, {
toCwd: e,
toDst: e
});
});
{
const c = n.dirname(t);
const s = n.join(c, e);
return o(s, (t, o)=>{
if (t) return r(t);
if (o) return r(null, {
toCwd: s,
toDst: e
});
return i.lstat(e, (t)=>{
if (t) {
t.message = t.message.replace("lstat", "ensureSymlink");
return r(t);
}
return r(null, {
toCwd: e,
toDst: n.relative(c, e)
});
});
});
}
}
function symlinkPathsSync(e, t) {
let r;
if (n.isAbsolute(e)) {
r = i.existsSync(e);
if (!r) throw new Error("absolute srcpath does not exist");
return {
toCwd: e,
toDst: e
};
}
{
const o = n.dirname(t);
const c = n.join(o, e);
r = i.existsSync(c);
if (r) return {
toCwd: c,
toDst: e
};
r = i.existsSync(e);
if (!r) throw new Error("relative srcpath does not exist");
return {
toCwd: e,
toDst: n.relative(o, e)
};
}
}
e.exports = {
symlinkPaths: symlinkPaths,
symlinkPathsSync: symlinkPathsSync
};
},
894: (e, t, r)=>{
"use strict";
const n = r(127);
function symlinkType(e, t, r) {
r = "function" == typeof t ? t : r;
t = "function" == typeof t ? false : t;
if (t) return r(null, t);
n.lstat(e, (e, n)=>{
if (e) return r(null, "file");
t = n && n.isDirectory() ? "dir" : "file";
r(null, t);
});
}
function symlinkTypeSync(e, t) {
let r;
if (t) return t;
try {
r = n.lstatSync(e);
} catch {
return "file";
}
return r && r.isDirectory() ? "dir" : "file";
}
e.exports = {
symlinkType: symlinkType,
symlinkTypeSync: symlinkTypeSync
};
},
294: (e, t, r)=>{
"use strict";
const n = r(5).fromCallback;
const i = r(17);
const o = r(812);
const c = r(971);
const s = c.mkdirs;
const a = c.mkdirsSync;
const u = r(332);
const f = u.symlinkPaths;
const l = u.symlinkPathsSync;
const y = r(894);
const d = y.symlinkType;
const m = y.symlinkTypeSync;
const p = r(725).pathExists;
const { areIdentical: h } = r(883);
function createSymlink(e, t, r, n) {
n = "function" == typeof r ? r : n;
r = "function" == typeof r ? false : r;
o.lstat(t, (i, c)=>{
if (!i && c.isSymbolicLink()) Promise.all([
o.stat(e),
o.stat(t)
]).then(([i, o])=>{
if (h(i, o)) return n(null);
_createSymlink(e, t, r, n);
});
else _createSymlink(e, t, r, n);
});
}
function _createSymlink(e, t, r, n) {
f(e, t, (c, a)=>{
if (c) return n(c);
e = a.toDst;
d(a.toCwd, r, (r, c)=>{
if (r) return n(r);
const a = i.dirname(t);
p(a, (r, i)=>{
if (r) return n(r);
if (i) return o.symlink(e, t, c, n);
s(a, (r)=>{
if (r) return n(r);
o.symlink(e, t, c, n);
});
});
});
});
}
function createSymlinkSync(e, t, r) {
let n;
try {
n = o.lstatSync(t);
} catch {}
if (n && n.isSymbolicLink()) {
const r = o.statSync(e);
const n = o.statSync(t);
if (h(r, n)) return;
}
const c = l(e, t);
e = c.toDst;
r = m(c.toCwd, r);
const s = i.dirname(t);
const u = o.existsSync(s);
if (u) return o.symlinkSync(e, t, r);
a(s);
return o.symlinkSync(e, t, r);
}
e.exports = {
createSymlink: n(createSymlink),
createSymlinkSync: createSymlinkSync
};
},
812: (e, t, r)=>{
"use strict";
const n = r(5).fromCallback;
const i = r(127);
const o = [
"access",
"appendFile",
"chmod",
"chown",
"close",
"copyFile",
"fchmod",
"fchown",
"fdatasync",
"fstat",
"fsync",
"ftruncate",
"futimes",
"lchmod",
"lchown",
"link",
"lstat",
"mkdir",
"mkdtemp",
"open",
"opendir",
"readdir",
"readFile",
"readlink",
"realpath",
"rename",
"rm",
"rmdir",
"stat",
"symlink",
"truncate",
"unlink",
"utimes",
"writeFile"
].filter((e)=>"function" == typeof i[e]);
Object.assign(t, i);
o.forEach((e)=>{
t[e] = n(i[e]);
});
t.realpath.native = n(i.realpath.native);
t.exists = function(e, t) {
if ("function" == typeof t) return i.exists(e, t);
return new Promise((t)=>i.exists(e, t));
};
t.read = function(e, t, r, n, o, c) {
if ("function" == typeof c) return i.read(e, t, r, n, o, c);
return new Promise((c, s)=>{
i.read(e, t, r, n, o, (e, t, r)=>{
if (e) return s(e);
c({
bytesRead: t,
buffer: r
});
});
});
};
t.write = function(e, t, ...r) {
if ("function" == typeof r[r.length - 1]) return i.write(e, t, ...r);
return new Promise((n, o)=>{
i.write(e, t, ...r, (e, t, r)=>{
if (e) return o(e);
n({
bytesWritten: t,
buffer: r
});
});
});
};
if ("function" == typeof i.writev) t.writev = function(e, t, ...r) {
if ("function" == typeof r[r.length - 1]) return i.writev(e, t, ...r);
return new Promise((n, o)=>{
i.writev(e, t, ...r, (e, t, r)=>{
if (e) return o(e);
n({
bytesWritten: t,
buffers: r
});
});
});
};
},
81: (e, t, r)=>{
"use strict";
e.exports = {
...r(812),
...r(2),
...r(708),
...r(726),
...r(779),
...r(971),
...r(511),
...r(701),
...r(725),
...r(95)
};
},
779: (e, t, r)=>{
"use strict";
const n = r(5).fromPromise;
const i = r(901);
i.outputJson = n(r(410));
i.outputJsonSync = r(925);
i.outputJSON = i.outputJson;
i.outputJSONSync = i.outputJsonSync;
i.writeJSON = i.writeJson;
i.writeJSONSync = i.writeJsonSync;
i.readJSON = i.readJson;
i.readJSONSync = i.readJsonSync;
e.exports = i;
},
901: (e, t, r)=>{
"use strict";
const n = r(654);
e.exports = {
readJson: n.readFile,
readJsonSync: n.readFileSync,
writeJson: n.writeFile,
writeJsonSync: n.writeFileSync
};
},
925: (e, t, r)=>{
"use strict";
const { stringify: n } = r(208);
const { outputFileSync: i } = r(701);
function outputJsonSync(e, t, r) {
const o = n(t, r);
i(e, o, r);
}
e.exports = outputJsonSync;
},
410: (e, t, r)=>{
"use strict";
const { stringify: n } = r(208);
const { outputFile: i } = r(701);
async function outputJson(e, t, r = {}) {
const o = n(t, r);
await i(e, o, r);
}
e.exports = outputJson;
},
971: (e, t, r)=>{
"use strict";
const n = r(5).fromPromise;
const { makeDir: i, makeDirSync: o } = r(284);
const c = n(i);
e.exports = {
mkdirs: c,
mkdirsSync: o,
mkdirp: c,
mkdirpSync: o,
ensureDir: c,
ensureDirSync: o
};
},
284: (e, t, r)=>{
"use strict";
const n = r(812);
const { checkPath: i } = r(216);
const getMode = (e)=>{
const t = {
mode: 511
};
if ("number" == typeof e) return e;
return ({
...t,
...e
}).mode;
};
e.exports.makeDir = async (e, t)=>{
i(e);
return n.mkdir(e, {
mode: getMode(t),
recursive: true
});
};
e.exports.makeDirSync = (e, t)=>{
i(e);
return n.mkdirSync(e, {
mode: getMode(t),
recursive: true
});
};
},
216: (e, t, r)=>{
"use strict";
const n = r(17);
e.exports.checkPath = function(e) {
if ("win32" === process.platform) {
const t = /[<>:"|?*]/.test(e.replace(n.parse(e).root, ""));
if (t) {
const t = new Error(`Path contains invalid characters: ${e}`);
t.code = "EINVAL";
throw t;
}
}
};
},
511: (e, t, r)=>{
"use strict";
const n = r(5).fromCallback;
e.exports = {
move: n(r(795)),
moveSync: r(429)
};
},
429: (e, t, r)=>{
"use strict";
const n = r(127);
const i = r(17);
const o = r(2).copySync;
const c = r(95).removeSync;
const s = r(971).mkdirpSync;
const a = r(883);
function moveSync(e, t, r) {
r = r || {};
const n = r.overwrite || r.clobber || false;
const { srcStat: o, isChangingCase: c = false } = a.checkPathsSync(e, t, "move", r);
a.checkParentPathsSync(e, o, t, "move");
if (!isParentRoot(t)) s(i.dirname(t));
return doRename(e, t, n, c);
}
function isParentRoot(e) {
const t = i.dirname(e);
const r = i.parse(t);
return r.root === t;
}
function doRename(e, t, r, i) {
if (i) return rename(e, t, r);
if (r) {
c(t);
return rename(e, t, r);
}
if (n.existsSync(t)) throw new Error("dest already exists.");
return rename(e, t, r);
}
function rename(e, t, r) {
try {
n.renameSync(e, t);
} catch (n) {
if ("EXDEV" !== n.code) throw n;
return moveAcrossDevice(e, t, r);
}
}
function moveAcrossDevice(e, t, r) {
const n = {
overwrite: r,
errorOnExist: true
};
o(e, t, n);
return c(e);
}
e.exports = moveSync;
},
795: (e, t, r)=>{
"use strict";
const n = r(127);
const i = r(17);
const o = r(2).copy;
const c = r(95).remove;
const s = r(971).mkdirp;
const a = r(725).pathExists;
const u = r(883);
function move(e, t, r, n) {
if ("function" == typeof r) {
n = r;
r = {};
}
const o = r.overwrite || r.clobber || false;
u.checkPaths(e, t, "move", r, (r, c)=>{
if (r) return n(r);
const { srcStat: a, isChangingCase: f = false } = c;
u.checkParentPaths(e, a, t, "move", (r)=>{
if (r) return n(r);
if (isParentRoot(t)) return doRename(e, t, o, f, n);
s(i.dirname(t), (r)=>{
if (r) return n(r);
return doRename(e, t, o, f, n);
});
});
});
}
function isParentRoot(e) {
const t = i.dirname(e);
const r = i.parse(t);
return r.root === t;
}
function doRename(e, t, r, n, i) {
if (n) return rename(e, t, r, i);
if (r) return c(t, (n)=>{
if (n) return i(n);
return rename(e, t, r, i);
});
a(t, (n, o)=>{
if (n) return i(n);
if (o) return i(new Error("dest already exists."));
return rename(e, t, r, i);
});
}
function rename(e, t, r, i) {
n.rename(e, t, (n)=>{
if (!n) return i();
if ("EXDEV" !== n.code) return i(n);
return moveAcrossDevice(e, t, r, i);
});
}
function moveAcrossDevice(e, t, r, n) {
const i = {
overwrite: r,
errorOnExist: true
};
o(e, t, i, (t)=>{
if (t) return n(t);
return c(e, n);
});
}
e.exports = move;
},
701: (e, t, r)=>{
"use strict";
const n = r(5).fromCallback;
const i = r(127);
const o = r(17);
const c = r(971);
const s = r(725).pathExists;
function outputFile(e, t, r, n) {
if ("function" == typeof r) {
n = r;
r = "utf8";
}
const a = o.dirname(e);
s(a, (o, s)=>{
if (o) return n(o);
if (s) return i.writeFile(e, t, r, n);
c.mkdirs(a, (o)=>{
if (o) return n(o);
i.writeFile(e, t, r, n);
});
});
}
function outputFileSync(e, ...t) {
const r = o.dirname(e);
if (i.existsSync(r)) return i.writeFileSync(e, ...t);
c.mkdirsSync(r);
i.writeFileSync(e, ...t);
}
e.exports = {
outputFile: n(outputFile),
outputFileSync: outputFileSync
};
},
725: (e, t, r)=>{
"use strict";
const n = r(5).fromPromise;
const i = r(812);
function pathExists(e) {
return i.access(e).then(()=>true).catch(()=>false);
}
e.exports = {
pathExists: n(pathExists),
pathExistsSync: i.existsSync
};
},
95: (e, t, r)=>{
"use strict";
const n = r(127);
const i = r(5).fromCallback;
const o = r(193);
function remove(e, t) {
if (n.rm) return n.rm(e, {
recursive: true,
force: true
}, t);
o(e, t);
}
function removeSync(e) {
if (n.rmSync) return n.rmSync(e, {
recursive: true,
force: true
});
o.sync(e);
}
e.exports = {
remove: i(remove),
removeSync: removeSync
};
},
193: (e, t, r)=>{
"use strict";
const n = r(127);
const i = r(17);
const o = r(491);
const c = "win32" === process.platform;
function defaults(e) {
const t = [
"unlink",
"chmod",
"stat",
"lstat",
"rmdir",
"readdir"
];
t.forEach((t)=>{
e[t] = e[t] || n[t];
t += "Sync";
e[t] = e[t] || n[t];
});
e.maxBusyTries = e.maxBusyTries || 3;
}
function rimraf(e, t, r) {
let n = 0;
if ("function" == typeof t) {
r = t;
t = {};
}
o(e, "rimraf: missing path");
o.strictEqual(typeof e, "string", "rimraf: path should be a string");
o.strictEqual(typeof r, "function", "rimraf: callback function required");
o(t, "rimraf: invalid options argument provided");
o.strictEqual(typeof t, "object", "rimraf: options should be object");
defaults(t);
rimraf_(e, t, function CB(i) {
if (i) {
if (("EBUSY" === i.code || "ENOTEMPTY" === i.code || "EPERM" === i.code) && n < t.maxBusyTries) {
n++;
const r = 100 * n;
return setTimeout(()=>rimraf_(e, t, CB), r);
}
if ("ENOENT" === i.code) i = null;
}
r(i);
});
}
function rimraf_(e, t, r) {
o(e);
o(t);
o("function" == typeof r);
t.lstat(e, (n, i)=>{
if (n && "ENOENT" === n.code) return r(null);
if (n && "EPERM" === n.code && c) return fixWinEPERM(e, t, n, r);
if (i && i.isDirectory()) return rmdir(e, t, n, r);
t.unlink(e, (n)=>{
if (n) {
if ("ENOENT" === n.code) return r(null);
if ("EPERM" === n.code) return c ? fixWinEPERM(e, t, n, r) : rmdir(e, t, n, r);
if ("EISDIR" === n.code) return rmdir(e, t, n, r);
}
return r(n);
});
});
}
function fixWinEPERM(e, t, r, n) {
o(e);
o(t);
o("function" == typeof n);
t.chmod(e, 438, (i)=>{
if (i) n("ENOENT" === i.code ? null : r);
else t.stat(e, (i, o)=>{
if (i) n("ENOENT" === i.code ? null : r);
else if (o.isDirectory()) rmdir(e, t, r, n);
else t.unlink(e, n);
});
});
}
function fixWinEPERMSync(e, t, r) {
let n;
o(e);
o(t);
try {
t.chmodSync(e, 438);
} catch (e) {
if ("ENOENT" === e.code) return;
throw r;
}
try {
n = t.statSync(e);
} catch (e) {
if ("ENOENT" === e.code) return;
throw r;
}
if (n.isDirectory()) rmdirSync(e, t, r);
else t.unlinkSync(e);
}
function rmdir(e, t, r, n) {
o(e);
o(t);
o("function" == typeof n);
t.rmdir(e, (i)=>{
if (i && ("ENOTEMPTY" === i.code || "EEXIST" === i.code || "EPERM" === i.code)) rmkids(e, t, n);
else i && "ENOTDIR" === i.code ? n(r) : n(i);
});
}
function rmkids(e, t, r) {
o(e);
o(t);
o("function" == typeof r);
t.readdir(e, (n, o)=>{
if (n) return r(n);
let c = o.length;
let s;
if (0 === c) return t.rmdir(e, r);
o.forEach((n)=>{
rimraf(i.join(e, n), t, (n)=>{
if (s) return;
if (n) return r(s = n);
if (0 === --c) t.rmdir(e, r);
});
});
});
}
function rimrafSync(e, t) {
let r;
t = t || {};
defaults(t);
o(e, "rimraf: missing path");
o.strictEqual(typeof e, "string", "rimraf: path should be a string");
o(t, "rimraf: missing options");
o.strictEqual(typeof t, "object", "rimraf: options should be object");
try {
r = t.lstatSync(e);
} catch (r) {
if ("ENOENT" === r.code) return;
if ("EPERM" === r.code && c) fixWinEPERMSync(e, t, r);
}
try {
if (r && r.isDirectory()) rmdirSync(e, t, null);
else t.unlinkSync(e);
} catch (r) {
if ("ENOENT" === r.code) return;
if ("EPERM" === r.code) return c ? fixWinEPERMSync(e, t, r) : rmdirSync(e, t, r);
if ("EISDIR" !== r.code) throw r;
rmdirSync(e, t, r);
}
}
function rmdirSync(e, t, r) {
o(e);
o(t);
try {
t.rmdirSync(e);
} catch (n) {
if ("ENOTDIR" === n.code) throw r;
if ("ENOTEMPTY" === n.code || "EEXIST" === n.code || "EPERM" === n.code) rmkidsSync(e, t);
else if ("ENOENT" !== n.code) throw n;
}
}
function rmkidsSync(e, t) {
o(e);
o(t);
t.readdirSync(e).forEach((r)=>rimrafSync(i.join(e, r), t));
if (c) {
const r = Date.now();
do try {
const r = t.rmdirSync(e, t);
return r;
} catch {}
while (Date.now() - r < 500);
} else {
const r = t.rmdirSync(e, t);
return r;
}
}
e.exports = rimraf;
rimraf.sync = rimrafSync;
},
883: (e, t, r)=>{
"use strict";
const n = r(812);
const i = r(17);
const o = r(837);
function getStats(e, t, r) {
const i = r.dereference ? (e)=>n.stat(e, {
bigint: true
}) : (e)=>n.lstat(e, {
bigint: true
});
return Promise.all([
i(e),
i(t).catch((e)=>{
if ("ENOENT" === e.code) return null;
throw e;
})
]).then(([e, t])=>({
srcStat: e,
destStat: t
}));
}
function getStatsSync(e, t, r) {
let i;
const o = r.dereference ? (e)=>n.statSync(e, {
bigint: true
}) : (e)=>n.lstatSync(e, {
bigint: true
});
const c = o(e);
try {
i = o(t);
} catch (e) {
if ("ENOENT" === e.code) return {
srcStat: c,
destStat: null
};
throw e;
}
return {
srcStat: c,
destStat: i
};
}
function checkPaths(e, t, r, n, c) {
o.callbackify(getStats)(e, t, n, (n, o)=>{
if (n) return c(n);
const { srcStat: s, destStat: a } = o;
if (a) {
if (areIdentical(s, a)) {
const n = i.basename(e);
const o = i.basename(t);
if ("move" === r && n !== o && n.toLowerCase() === o.toLowerCase()) return c(null, {
srcStat: s,
destStat: a,
isChangingCase: true
});
return c(new Error("Source and destination must not be the same."));
}
if (s.isDirectory() && !a.isDirectory()) return c(new Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`));
if (!s.isDirectory() && a.isDirectory()) return c(new Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`));
}
if (s.isDirectory() && isSrcSubdir(e, t)) return c(new Error(errMsg(e, t, r)));
return c(null, {
srcStat: s,
destStat: a
});
});
}
function checkPathsSync(e, t, r, n) {
const { srcStat: o, destStat: c } = getStatsSync(e, t, n);
if (c) {
if (areIdentical(o, c)) {
const n = i.basename(e);
const s = i.basename(t);
if ("move" === r && n !== s && n.toLowerCase() === s.toLowerCase()) return {
srcStat: o,
destStat: c,
isChangingCase: true
};
throw new Error("Source and destination must not be the same.");
}
if (o.isDirectory() && !c.isDirectory()) throw new Error(`Cannot overwrite non-directory '${t}' with directory '${e}'.`);
if (!o.isDirectory() && c.isDirectory()) throw new Error(`Cannot overwrite directory '${t}' with non-directory '${e}'.`);
}
if (o.isDirectory() && isSrcSubdir(e, t)) throw new Error(errMsg(e, t, r));
return {
srcStat: o,
destStat: c
};
}
function checkParentPaths(e, t, r, o, c) {
const s = i.resolve(i.dirname(e));
const a = i.resolve(i.dirname(r));
if (a === s || a === i.parse(a).root) return c();
n.stat(a, {
bigint: true
}, (n, i)=>{
if (n) {
if ("ENOENT" === n.code) return c();
return c(n);
}
if (areIdentical(t, i)) return c(new Error(errMsg(e, r, o)));
return checkParentPaths(e, t, a, o, c);
});
}
function checkParentPathsSync(e, t, r, o) {
const c = i.resolve(i.dirname(e));
const s = i.resolve(i.dirname(r));
if (s === c || s === i.parse(s).root) return;
let a;
try {
a = n.statSync(s, {
bigint: true
});
} catch (e) {
if ("ENOENT" === e.code) return;
throw e;
}
if (areIdentical(t, a)) throw new Error(errMsg(e, r, o));
return checkParentPathsSync(e, t, s, o);
}
function areIdentical(e, t) {