summaryrefslogtreecommitdiff
path: root/node_modules/fs-extra/lib
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/fs-extra/lib')
-rw-r--r--node_modules/fs-extra/lib/copy/copy-sync.js161
-rw-r--r--node_modules/fs-extra/lib/copy/copy.js238
-rw-r--r--node_modules/fs-extra/lib/copy/index.js7
-rw-r--r--node_modules/fs-extra/lib/empty/index.js39
-rw-r--r--node_modules/fs-extra/lib/ensure/file.js69
-rw-r--r--node_modules/fs-extra/lib/ensure/index.js23
-rw-r--r--node_modules/fs-extra/lib/ensure/link.js64
-rw-r--r--node_modules/fs-extra/lib/ensure/symlink-paths.js99
-rw-r--r--node_modules/fs-extra/lib/ensure/symlink-type.js31
-rw-r--r--node_modules/fs-extra/lib/ensure/symlink.js82
-rw-r--r--node_modules/fs-extra/lib/esm.mjs68
-rw-r--r--node_modules/fs-extra/lib/fs/index.js140
-rw-r--r--node_modules/fs-extra/lib/index.js16
-rw-r--r--node_modules/fs-extra/lib/json/index.js16
-rw-r--r--node_modules/fs-extra/lib/json/jsonfile.js11
-rw-r--r--node_modules/fs-extra/lib/json/output-json-sync.js12
-rw-r--r--node_modules/fs-extra/lib/json/output-json.js12
-rw-r--r--node_modules/fs-extra/lib/mkdirs/index.js14
-rw-r--r--node_modules/fs-extra/lib/mkdirs/make-dir.js27
-rw-r--r--node_modules/fs-extra/lib/mkdirs/utils.js21
-rw-r--r--node_modules/fs-extra/lib/move/index.js7
-rw-r--r--node_modules/fs-extra/lib/move/move-sync.js55
-rw-r--r--node_modules/fs-extra/lib/move/move.js76
-rw-r--r--node_modules/fs-extra/lib/output-file/index.js40
-rw-r--r--node_modules/fs-extra/lib/path-exists/index.js12
-rw-r--r--node_modules/fs-extra/lib/remove/index.js17
-rw-r--r--node_modules/fs-extra/lib/util/stat.js154
-rw-r--r--node_modules/fs-extra/lib/util/utimes.js26
28 files changed, 1537 insertions, 0 deletions
diff --git a/node_modules/fs-extra/lib/copy/copy-sync.js b/node_modules/fs-extra/lib/copy/copy-sync.js
new file mode 100644
index 0000000..8bc6011
--- /dev/null
+++ b/node_modules/fs-extra/lib/copy/copy-sync.js
@@ -0,0 +1,161 @@
+'use strict'
+
+const fs = require('graceful-fs')
+const path = require('path')
+const mkdirsSync = require('../mkdirs').mkdirsSync
+const utimesMillisSync = require('../util/utimes').utimesMillisSync
+const stat = require('../util/stat')
+
+function copySync (src, dest, opts) {
+ if (typeof opts === 'function') {
+ opts = { filter: opts }
+ }
+
+ opts = opts || {}
+ opts.clobber = 'clobber' in opts ? !!opts.clobber : true // default to true for now
+ opts.overwrite = 'overwrite' in opts ? !!opts.overwrite : opts.clobber // overwrite falls back to clobber
+
+ // Warn about using preserveTimestamps on 32-bit node
+ if (opts.preserveTimestamps && process.arch === 'ia32') {
+ process.emitWarning(
+ 'Using the preserveTimestamps option in 32-bit node is not recommended;\n\n' +
+ '\tsee https://github.com/jprichardson/node-fs-extra/issues/269',
+ 'Warning', 'fs-extra-WARN0002'
+ )
+ }
+
+ const { srcStat, destStat } = stat.checkPathsSync(src, dest, 'copy', opts)
+ stat.checkParentPathsSync(src, srcStat, dest, 'copy')
+ if (opts.filter && !opts.filter(src, dest)) return
+ const destParent = path.dirname(dest)
+ if (!fs.existsSync(destParent)) mkdirsSync(destParent)
+ return getStats(destStat, src, dest, opts)
+}
+
+function getStats (destStat, src, dest, opts) {
+ const statSync = opts.dereference ? fs.statSync : fs.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)
+ else if (srcStat.isSocket()) throw new Error(`Cannot copy a socket file: ${src}`)
+ else if (srcStat.isFIFO()) throw new Error(`Cannot copy a FIFO pipe: ${src}`)
+ throw new Error(`Unknown file: ${src}`)
+}
+
+function onFile (srcStat, destStat, src, dest, opts) {
+ if (!destStat) return copyFile(srcStat, src, dest, opts)
+ return mayCopyFile(srcStat, src, dest, opts)
+}
+
+function mayCopyFile (srcStat, src, dest, opts) {
+ if (opts.overwrite) {
+ fs.unlinkSync(dest)
+ return copyFile(srcStat, src, dest, opts)
+ } else if (opts.errorOnExist) {
+ throw new Error(`'${dest}' already exists`)
+ }
+}
+
+function copyFile (srcStat, src, dest, opts) {
+ fs.copyFileSync(src, dest)
+ if (opts.preserveTimestamps) handleTimestamps(srcStat.mode, src, dest)
+ return setDestMode(dest, srcStat.mode)
+}
+
+function handleTimestamps (srcMode, src, dest) {
+ // Make sure the file is writable before setting the timestamp
+ // otherwise open fails with EPERM when invoked with 'r+'
+ // (through utimes call)
+ if (fileIsNotWritable(srcMode)) makeFileWritable(dest, srcMode)
+ return setDestTimestamps(src, dest)
+}
+
+function fileIsNotWritable (srcMode) {
+ return (srcMode & 0o200) === 0
+}
+
+function makeFileWritable (dest, srcMode) {
+ return setDestMode(dest, srcMode | 0o200)
+}
+
+function setDestMode (dest, srcMode) {
+ return fs.chmodSync(dest, srcMode)
+}
+
+function setDestTimestamps (src, dest) {
+ // The initial srcStat.atime cannot be trusted
+ // because it is modified by the read(2) system call
+ // (See https://nodejs.org/api/fs.html#fs_stat_time_values)
+ const updatedSrcStat = fs.statSync(src)
+ return utimesMillisSync(dest, updatedSrcStat.atime, updatedSrcStat.mtime)
+}
+
+function onDir (srcStat, destStat, src, dest, opts) {
+ if (!destStat) return mkDirAndCopy(srcStat.mode, src, dest, opts)
+ return copyDir(src, dest, opts)
+}
+
+function mkDirAndCopy (srcMode, src, dest, opts) {
+ fs.mkdirSync(dest)
+ copyDir(src, dest, opts)
+ return setDestMode(dest, srcMode)
+}
+
+function copyDir (src, dest, opts) {
+ fs.readdirSync(src).forEach(item => copyDirItem(item, src, dest, opts))
+}
+
+function copyDirItem (item, src, dest, opts) {
+ const srcItem = path.join(src, item)
+ const destItem = path.join(dest, item)
+ if (opts.filter && !opts.filter(srcItem, destItem)) return
+ const { destStat } = stat.checkPathsSync(srcItem, destItem, 'copy', opts)
+ return getStats(destStat, srcItem, destItem, opts)
+}
+
+function onLink (destStat, src, dest, opts) {
+ let resolvedSrc = fs.readlinkSync(src)
+ if (opts.dereference) {
+ resolvedSrc = path.resolve(process.cwd(), resolvedSrc)
+ }
+
+ if (!destStat) {
+ return fs.symlinkSync(resolvedSrc, dest)
+ } else {
+ let resolvedDest
+ try {
+ resolvedDest = fs.readlinkSync(dest)
+ } catch (err) {
+ // dest exists and is a regular file or directory,
+ // Windows may throw UNKNOWN error. If dest already exists,
+ // fs throws error anyway, so no need to guard against it here.
+ if (err.code === 'EINVAL' || err.code === 'UNKNOWN') return fs.symlinkSync(resolvedSrc, dest)
+ throw err
+ }
+ if (opts.dereference) {
+ resolvedDest = path.resolve(process.cwd(), resolvedDest)
+ }
+ if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
+ throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`)
+ }
+
+ // prevent copy if src is a subdir of dest since unlinking
+ // dest in this case would result in removing src contents
+ // and therefore a broken symlink would be created.
+ if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
+ throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`)
+ }
+ return copyLink(resolvedSrc, dest)
+ }
+}
+
+function copyLink (resolvedSrc, dest) {
+ fs.unlinkSync(dest)
+ return fs.symlinkSync(resolvedSrc, dest)
+}
+
+module.exports = copySync
diff --git a/node_modules/fs-extra/lib/copy/copy.js b/node_modules/fs-extra/lib/copy/copy.js
new file mode 100644
index 0000000..bc188fb
--- /dev/null
+++ b/node_modules/fs-extra/lib/copy/copy.js
@@ -0,0 +1,238 @@
+'use strict'
+
+const fs = require('graceful-fs')
+const path = require('path')
+const mkdirs = require('../mkdirs').mkdirs
+const pathExists = require('../path-exists').pathExists
+const utimesMillis = require('../util/utimes').utimesMillis
+const stat = require('../util/stat')
+
+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 // default to true for now
+ opts.overwrite = 'overwrite' in opts ? !!opts.overwrite : opts.clobber // overwrite falls back to clobber
+
+ // Warn about using preserveTimestamps on 32-bit node
+ if (opts.preserveTimestamps && process.arch === 'ia32') {
+ process.emitWarning(
+ 'Using the preserveTimestamps option in 32-bit node is not recommended;\n\n' +
+ '\tsee https://github.com/jprichardson/node-fs-extra/issues/269',
+ 'Warning', 'fs-extra-WARN0001'
+ )
+ }
+
+ stat.checkPaths(src, dest, 'copy', opts, (err, stats) => {
+ if (err) return cb(err)
+ const { srcStat, destStat } = stats
+ stat.checkParentPaths(src, srcStat, dest, 'copy', err => {
+ if (err) return cb(err)
+ runFilter(src, dest, opts, (err, include) => {
+ if (err) return cb(err)
+ if (!include) return cb()
+
+ checkParentDir(destStat, src, dest, opts, cb)
+ })
+ })
+ })
+}
+
+function checkParentDir (destStat, src, dest, opts, cb) {
+ const destParent = path.dirname(dest)
+ pathExists(destParent, (err, dirExists) => {
+ if (err) return cb(err)
+ if (dirExists) return getStats(destStat, src, dest, opts, cb)
+ mkdirs(destParent, err => {
+ if (err) return cb(err)
+ return getStats(destStat, src, dest, opts, cb)
+ })
+ })
+}
+
+function runFilter (src, dest, opts, cb) {
+ if (!opts.filter) return cb(null, true)
+ Promise.resolve(opts.filter(src, dest))
+ .then(include => cb(null, include), error => cb(error))
+}
+
+function getStats (destStat, src, dest, opts, cb) {
+ const stat = opts.dereference ? fs.stat : fs.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)
+ else if (srcStat.isSocket()) return cb(new Error(`Cannot copy a socket file: ${src}`))
+ else if (srcStat.isFIFO()) return cb(new Error(`Cannot copy a FIFO pipe: ${src}`))
+ return cb(new Error(`Unknown file: ${src}`))
+ })
+}
+
+function onFile (srcStat, destStat, src, dest, opts, cb) {
+ if (!destStat) return copyFile(srcStat, src, dest, opts, cb)
+ return mayCopyFile(srcStat, src, dest, opts, cb)
+}
+
+function mayCopyFile (srcStat, src, dest, opts, cb) {
+ if (opts.overwrite) {
+ fs.unlink(dest, err => {
+ if (err) return cb(err)
+ return copyFile(srcStat, src, dest, opts, cb)
+ })
+ } else if (opts.errorOnExist) {
+ return cb(new Error(`'${dest}' already exists`))
+ } else return cb()
+}
+
+function copyFile (srcStat, src, dest, opts, cb) {
+ fs.copyFile(src, dest, err => {
+ if (err) return cb(err)
+ if (opts.preserveTimestamps) return handleTimestampsAndMode(srcStat.mode, src, dest, cb)
+ return setDestMode(dest, srcStat.mode, cb)
+ })
+}
+
+function handleTimestampsAndMode (srcMode, src, dest, cb) {
+ // Make sure the file is writable before setting the timestamp
+ // otherwise open fails with EPERM when invoked with 'r+'
+ // (through utimes call)
+ if (fileIsNotWritable(srcMode)) {
+ return makeFileWritable(dest, srcMode, err => {
+ if (err) return cb(err)
+ return setDestTimestampsAndMode(srcMode, src, dest, cb)
+ })
+ }
+ return setDestTimestampsAndMode(srcMode, src, dest, cb)
+}
+
+function fileIsNotWritable (srcMode) {
+ return (srcMode & 0o200) === 0
+}
+
+function makeFileWritable (dest, srcMode, cb) {
+ return setDestMode(dest, srcMode | 0o200, cb)
+}
+
+function setDestTimestampsAndMode (srcMode, src, dest, cb) {
+ setDestTimestamps(src, dest, err => {
+ if (err) return cb(err)
+ return setDestMode(dest, srcMode, cb)
+ })
+}
+
+function setDestMode (dest, srcMode, cb) {
+ return fs.chmod(dest, srcMode, cb)
+}
+
+function setDestTimestamps (src, dest, cb) {
+ // The initial srcStat.atime cannot be trusted
+ // because it is modified by the read(2) system call
+ // (See https://nodejs.org/api/fs.html#fs_stat_time_values)
+ fs.stat(src, (err, updatedSrcStat) => {
+ if (err) return cb(err)
+ return utimesMillis(dest, updatedSrcStat.atime, updatedSrcStat.mtime, cb)
+ })
+}
+
+function onDir (srcStat, destStat, src, dest, opts, cb) {
+ if (!destStat) return mkDirAndCopy(srcStat.mode, src, dest, opts, cb)
+ return copyDir(src, dest, opts, cb)
+}
+
+function mkDirAndCopy (srcMode, src, dest, opts, cb) {
+ fs.mkdir(dest, err => {
+ if (err) return cb(err)
+ copyDir(src, dest, opts, err => {
+ if (err) return cb(err)
+ return setDestMode(dest, srcMode, cb)
+ })
+ })
+}
+
+function copyDir (src, dest, opts, cb) {
+ fs.readdir(src, (err, items) => {
+ if (err) return cb(err)
+ return copyDirItems(items, src, dest, opts, cb)
+ })
+}
+
+function copyDirItems (items, src, dest, opts, cb) {
+ const item = items.pop()
+ if (!item) return cb()
+ return copyDirItem(items, item, src, dest, opts, cb)
+}
+
+function copyDirItem (items, item, src, dest, opts, cb) {
+ const srcItem = path.join(src, item)
+ const destItem = path.join(dest, item)
+ runFilter(srcItem, destItem, opts, (err, include) => {
+ if (err) return cb(err)
+ if (!include) return copyDirItems(items, src, dest, opts, cb)
+
+ stat.checkPaths(srcItem, destItem, 'copy', opts, (err, stats) => {
+ if (err) return cb(err)
+ const { destStat } = stats
+ getStats(destStat, srcItem, destItem, opts, err => {
+ if (err) return cb(err)
+ return copyDirItems(items, src, dest, opts, cb)
+ })
+ })
+ })
+}
+
+function onLink (destStat, src, dest, opts, cb) {
+ fs.readlink(src, (err, resolvedSrc) => {
+ if (err) return cb(err)
+ if (opts.dereference) {
+ resolvedSrc = path.resolve(process.cwd(), resolvedSrc)
+ }
+
+ if (!destStat) {
+ return fs.symlink(resolvedSrc, dest, cb)
+ } else {
+ fs.readlink(dest, (err, resolvedDest) => {
+ if (err) {
+ // dest exists and is a regular file or directory,
+ // Windows may throw UNKNOWN error. If dest already exists,
+ // fs throws error anyway, so no need to guard against it here.
+ if (err.code === 'EINVAL' || err.code === 'UNKNOWN') return fs.symlink(resolvedSrc, dest, cb)
+ return cb(err)
+ }
+ if (opts.dereference) {
+ resolvedDest = path.resolve(process.cwd(), resolvedDest)
+ }
+ if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
+ return cb(new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`))
+ }
+
+ // do not copy if src is a subdir of dest since unlinking
+ // dest in this case would result in removing src contents
+ // and therefore a broken symlink would be created.
+ if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
+ return cb(new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`))
+ }
+ return copyLink(resolvedSrc, dest, cb)
+ })
+ }
+ })
+}
+
+function copyLink (resolvedSrc, dest, cb) {
+ fs.unlink(dest, err => {
+ if (err) return cb(err)
+ return fs.symlink(resolvedSrc, dest, cb)
+ })
+}
+
+module.exports = copy
diff --git a/node_modules/fs-extra/lib/copy/index.js b/node_modules/fs-extra/lib/copy/index.js
new file mode 100644
index 0000000..45c07a2
--- /dev/null
+++ b/node_modules/fs-extra/lib/copy/index.js
@@ -0,0 +1,7 @@
+'use strict'
+
+const u = require('universalify').fromCallback
+module.exports = {
+ copy: u(require('./copy')),
+ copySync: require('./copy-sync')
+}
diff --git a/node_modules/fs-extra/lib/empty/index.js b/node_modules/fs-extra/lib/empty/index.js
new file mode 100644
index 0000000..b4a2e82
--- /dev/null
+++ b/node_modules/fs-extra/lib/empty/index.js
@@ -0,0 +1,39 @@
+'use strict'
+
+const u = require('universalify').fromPromise
+const fs = require('../fs')
+const path = require('path')
+const mkdir = require('../mkdirs')
+const remove = require('../remove')
+
+const emptyDir = u(async function emptyDir (dir) {
+ let items
+ try {
+ items = await fs.readdir(dir)
+ } catch {
+ return mkdir.mkdirs(dir)
+ }
+
+ return Promise.all(items.map(item => remove.remove(path.join(dir, item))))
+})
+
+function emptyDirSync (dir) {
+ let items
+ try {
+ items = fs.readdirSync(dir)
+ } catch {
+ return mkdir.mkdirsSync(dir)
+ }
+
+ items.forEach(item => {
+ item = path.join(dir, item)
+ remove.removeSync(item)
+ })
+}
+
+module.exports = {
+ emptyDirSync,
+ emptydirSync: emptyDirSync,
+ emptyDir,
+ emptydir: emptyDir
+}
diff --git a/node_modules/fs-extra/lib/ensure/file.js b/node_modules/fs-extra/lib/ensure/file.js
new file mode 100644
index 0000000..15cc473
--- /dev/null
+++ b/node_modules/fs-extra/lib/ensure/file.js
@@ -0,0 +1,69 @@
+'use strict'
+
+const u = require('universalify').fromCallback
+const path = require('path')
+const fs = require('graceful-fs')
+const mkdir = require('../mkdirs')
+
+function createFile (file, callback) {
+ function makeFile () {
+ fs.writeFile(file, '', err => {
+ if (err) return callback(err)
+ callback()
+ })
+ }
+
+ fs.stat(file, (err, stats) => { // eslint-disable-line handle-callback-err
+ if (!err && stats.isFile()) return callback()
+ const dir = path.dirname(file)
+ fs.stat(dir, (err, stats) => {
+ if (err) {
+ // if the directory doesn't exist, make it
+ if (err.code === 'ENOENT') {
+ return mkdir.mkdirs(dir, err => {
+ if (err) return callback(err)
+ makeFile()
+ })
+ }
+ return callback(err)
+ }
+
+ if (stats.isDirectory()) makeFile()
+ else {
+ // parent is not a directory
+ // This is just to cause an internal ENOTDIR error to be thrown
+ fs.readdir(dir, err => {
+ if (err) return callback(err)
+ })
+ }
+ })
+ })
+}
+
+function createFileSync (file) {
+ let stats
+ try {
+ stats = fs.statSync(file)
+ } catch {}
+ if (stats && stats.isFile()) return
+
+ const dir = path.dirname(file)
+ try {
+ if (!fs.statSync(dir).isDirectory()) {
+ // parent is not a directory
+ // This is just to cause an internal ENOTDIR error to be thrown
+ fs.readdirSync(dir)
+ }
+ } catch (err) {
+ // If the stat call above failed because the directory doesn't exist, create it
+ if (err && err.code === 'ENOENT') mkdir.mkdirsSync(dir)
+ else throw err
+ }
+
+ fs.writeFileSync(file, '')
+}
+
+module.exports = {
+ createFile: u(createFile),
+ createFileSync
+}
diff --git a/node_modules/fs-extra/lib/ensure/index.js b/node_modules/fs-extra/lib/ensure/index.js
new file mode 100644
index 0000000..ecbcdd0
--- /dev/null
+++ b/node_modules/fs-extra/lib/ensure/index.js
@@ -0,0 +1,23 @@
+'use strict'
+
+const { createFile, createFileSync } = require('./file')
+const { createLink, createLinkSync } = require('./link')
+const { createSymlink, createSymlinkSync } = require('./symlink')
+
+module.exports = {
+ // file
+ createFile,
+ createFileSync,
+ ensureFile: createFile,
+ ensureFileSync: createFileSync,
+ // link
+ createLink,
+ createLinkSync,
+ ensureLink: createLink,
+ ensureLinkSync: createLinkSync,
+ // symlink
+ createSymlink,
+ createSymlinkSync,
+ ensureSymlink: createSymlink,
+ ensureSymlinkSync: createSymlinkSync
+}
diff --git a/node_modules/fs-extra/lib/ensure/link.js b/node_modules/fs-extra/lib/ensure/link.js
new file mode 100644
index 0000000..f6d6748
--- /dev/null
+++ b/node_modules/fs-extra/lib/ensure/link.js
@@ -0,0 +1,64 @@
+'use strict'
+
+const u = require('universalify').fromCallback
+const path = require('path')
+const fs = require('graceful-fs')
+const mkdir = require('../mkdirs')
+const pathExists = require('../path-exists').pathExists
+const { areIdentical } = require('../util/stat')
+
+function createLink (srcpath, dstpath, callback) {
+ function makeLink (srcpath, dstpath) {
+ fs.link(srcpath, dstpath, err => {
+ if (err) return callback(err)
+ callback(null)
+ })
+ }
+
+ fs.lstat(dstpath, (_, dstStat) => {
+ fs.lstat(srcpath, (err, srcStat) => {
+ if (err) {
+ err.message = err.message.replace('lstat', 'ensureLink')
+ return callback(err)
+ }
+ if (dstStat && areIdentical(srcStat, dstStat)) return callback(null)
+
+ const dir = path.dirname(dstpath)
+ pathExists(dir, (err, dirExists) => {
+ if (err) return callback(err)
+ if (dirExists) return makeLink(srcpath, dstpath)
+ mkdir.mkdirs(dir, err => {
+ if (err) return callback(err)
+ makeLink(srcpath, dstpath)
+ })
+ })
+ })
+ })
+}
+
+function createLinkSync (srcpath, dstpath) {
+ let dstStat
+ try {
+ dstStat = fs.lstatSync(dstpath)
+ } catch {}
+
+ try {
+ const srcStat = fs.lstatSync(srcpath)
+ if (dstStat && areIdentical(srcStat, dstStat)) return
+ } catch (err) {
+ err.message = err.message.replace('lstat', 'ensureLink')
+ throw err
+ }
+
+ const dir = path.dirname(dstpath)
+ const dirExists = fs.existsSync(dir)
+ if (dirExists) return fs.linkSync(srcpath, dstpath)
+ mkdir.mkdirsSync(dir)
+
+ return fs.linkSync(srcpath, dstpath)
+}
+
+module.exports = {
+ createLink: u(createLink),
+ createLinkSync
+}
diff --git a/node_modules/fs-extra/lib/ensure/symlink-paths.js b/node_modules/fs-extra/lib/ensure/symlink-paths.js
new file mode 100644
index 0000000..33cd760
--- /dev/null
+++ b/node_modules/fs-extra/lib/ensure/symlink-paths.js
@@ -0,0 +1,99 @@
+'use strict'
+
+const path = require('path')
+const fs = require('graceful-fs')
+const pathExists = require('../path-exists').pathExists
+
+/**
+ * Function that returns two types of paths, one relative to symlink, and one
+ * relative to the current working directory. Checks if path is absolute or
+ * relative. If the path is relative, this function checks if the path is
+ * relative to symlink or relative to current working directory. This is an
+ * initiative to find a smarter `srcpath` to supply when building symlinks.
+ * This allows you to determine which path to use out of one of three possible
+ * types of source paths. The first is an absolute path. This is detected by
+ * `path.isAbsolute()`. When an absolute path is provided, it is checked to
+ * see if it exists. If it does it's used, if not an error is returned
+ * (callback)/ thrown (sync). The other two options for `srcpath` are a
+ * relative url. By default Node's `fs.symlink` works by creating a symlink
+ * using `dstpath` and expects the `srcpath` to be relative to the newly
+ * created symlink. If you provide a `srcpath` that does not exist on the file
+ * system it results in a broken symlink. To minimize this, the function
+ * checks to see if the 'relative to symlink' source file exists, and if it
+ * does it will use it. If it does not, it checks if there's a file that
+ * exists that is relative to the current working directory, if does its used.
+ * This preserves the expectations of the original fs.symlink spec and adds
+ * the ability to pass in `relative to current working direcotry` paths.
+ */
+
+function symlinkPaths (srcpath, dstpath, callback) {
+ if (path.isAbsolute(srcpath)) {
+ return fs.lstat(srcpath, (err) => {
+ if (err) {
+ err.message = err.message.replace('lstat', 'ensureSymlink')
+ return callback(err)
+ }
+ return callback(null, {
+ toCwd: srcpath,
+ toDst: srcpath
+ })
+ })
+ } else {
+ const dstdir = path.dirname(dstpath)
+ const relativeToDst = path.join(dstdir, srcpath)
+ return pathExists(relativeToDst, (err, exists) => {
+ if (err) return callback(err)
+ if (exists) {
+ return callback(null, {
+ toCwd: relativeToDst,
+ toDst: srcpath
+ })
+ } else {
+ return fs.lstat(srcpath, (err) => {
+ if (err) {
+ err.message = err.message.replace('lstat', 'ensureSymlink')
+ return callback(err)
+ }
+ return callback(null, {
+ toCwd: srcpath,
+ toDst: path.relative(dstdir, srcpath)
+ })
+ })
+ }
+ })
+ }
+}
+
+function symlinkPathsSync (srcpath, dstpath) {
+ let exists
+ if (path.isAbsolute(srcpath)) {
+ exists = fs.existsSync(srcpath)
+ if (!exists) throw new Error('absolute srcpath does not exist')
+ return {
+ toCwd: srcpath,
+ toDst: srcpath
+ }
+ } else {
+ const dstdir = path.dirname(dstpath)
+ const relativeToDst = path.join(dstdir, srcpath)
+ exists = fs.existsSync(relativeToDst)
+ if (exists) {
+ return {
+ toCwd: relativeToDst,
+ toDst: srcpath
+ }
+ } else {
+ exists = fs.existsSync(srcpath)
+ if (!exists) throw new Error('relative srcpath does not exist')
+ return {
+ toCwd: srcpath,
+ toDst: path.relative(dstdir, srcpath)
+ }
+ }
+ }
+}
+
+module.exports = {
+ symlinkPaths,
+ symlinkPathsSync
+}
diff --git a/node_modules/fs-extra/lib/ensure/symlink-type.js b/node_modules/fs-extra/lib/ensure/symlink-type.js
new file mode 100644
index 0000000..42dc0ce
--- /dev/null
+++ b/node_modules/fs-extra/lib/ensure/symlink-type.js
@@ -0,0 +1,31 @@
+'use strict'
+
+const fs = require('graceful-fs')
+
+function symlinkType (srcpath, type, callback) {
+ callback = (typeof type === 'function') ? type : callback
+ type = (typeof type === 'function') ? false : type
+ if (type) return callback(null, type)
+ fs.lstat(srcpath, (err, stats) => {
+ if (err) return callback(null, 'file')
+ type = (stats && stats.isDirectory()) ? 'dir' : 'file'
+ callback(null, type)
+ })
+}
+
+function symlinkTypeSync (srcpath, type) {
+ let stats
+
+ if (type) return type
+ try {
+ stats = fs.lstatSync(srcpath)
+ } catch {
+ return 'file'
+ }
+ return (stats && stats.isDirectory()) ? 'dir' : 'file'
+}
+
+module.exports = {
+ symlinkType,
+ symlinkTypeSync
+}
diff --git a/node_modules/fs-extra/lib/ensure/symlink.js b/node_modules/fs-extra/lib/ensure/symlink.js
new file mode 100644
index 0000000..2b93052
--- /dev/null
+++ b/node_modules/fs-extra/lib/ensure/symlink.js
@@ -0,0 +1,82 @@
+'use strict'
+
+const u = require('universalify').fromCallback
+const path = require('path')
+const fs = require('../fs')
+const _mkdirs = require('../mkdirs')
+const mkdirs = _mkdirs.mkdirs
+const mkdirsSync = _mkdirs.mkdirsSync
+
+const _symlinkPaths = require('./symlink-paths')
+const symlinkPaths = _symlinkPaths.symlinkPaths
+const symlinkPathsSync = _symlinkPaths.symlinkPathsSync
+
+const _symlinkType = require('./symlink-type')
+const symlinkType = _symlinkType.symlinkType
+const symlinkTypeSync = _symlinkType.symlinkTypeSync
+
+const pathExists = require('../path-exists').pathExists
+
+const { areIdentical } = require('../util/stat')
+
+function createSymlink (srcpath, dstpath, type, callback) {
+ callback = (typeof type === 'function') ? type : callback
+ type = (typeof type === 'function') ? false : type
+
+ fs.lstat(dstpath, (err, stats) => {
+ if (!err && stats.isSymbolicLink()) {
+ Promise.all([
+ fs.stat(srcpath),
+ fs.stat(dstpath)
+ ]).then(([srcStat, dstStat]) => {
+ if (areIdentical(srcStat, dstStat)) return callback(null)
+ _createSymlink(srcpath, dstpath, type, callback)
+ })
+ } else _createSymlink(srcpath, dstpath, type, callback)
+ })
+}
+
+function _createSymlink (srcpath, dstpath, type, callback) {
+ symlinkPaths(srcpath, dstpath, (err, relative) => {
+ if (err) return callback(err)
+ srcpath = relative.toDst
+ symlinkType(relative.toCwd, type, (err, type) => {
+ if (err) return callback(err)
+ const dir = path.dirname(dstpath)
+ pathExists(dir, (err, dirExists) => {
+ if (err) return callback(err)
+ if (dirExists) return fs.symlink(srcpath, dstpath, type, callback)
+ mkdirs(dir, err => {
+ if (err) return callback(err)
+ fs.symlink(srcpath, dstpath, type, callback)
+ })
+ })
+ })
+ })
+}
+
+function createSymlinkSync (srcpath, dstpath, type) {
+ let stats
+ try {
+ stats = fs.lstatSync(dstpath)
+ } catch {}
+ if (stats && stats.isSymbolicLink()) {
+ const srcStat = fs.statSync(srcpath)
+ const dstStat = fs.statSync(dstpath)
+ if (areIdentical(srcStat, dstStat)) return
+ }
+
+ const relative = symlinkPathsSync(srcpath, dstpath)
+ srcpath = relative.toDst
+ type = symlinkTypeSync(relative.toCwd, type)
+ const dir = path.dirname(dstpath)
+ const exists = fs.existsSync(dir)
+ if (exists) return fs.symlinkSync(srcpath, dstpath, type)
+ mkdirsSync(dir)
+ return fs.symlinkSync(srcpath, dstpath, type)
+}
+
+module.exports = {
+ createSymlink: u(createSymlink),
+ createSymlinkSync
+}
diff --git a/node_modules/fs-extra/lib/esm.mjs b/node_modules/fs-extra/lib/esm.mjs
new file mode 100644
index 0000000..27b7a1f
--- /dev/null
+++ b/node_modules/fs-extra/lib/esm.mjs
@@ -0,0 +1,68 @@
+import _copy from './copy/index.js'
+import _empty from './empty/index.js'
+import _ensure from './ensure/index.js'
+import _json from './json/index.js'
+import _mkdirs from './mkdirs/index.js'
+import _move from './move/index.js'
+import _outputFile from './output-file/index.js'
+import _pathExists from './path-exists/index.js'
+import _remove from './remove/index.js'
+
+// NOTE: Only exports fs-extra's functions; fs functions must be imported from "node:fs" or "node:fs/promises"
+
+export const copy = _copy.copy
+export const copySync = _copy.copySync
+export const emptyDirSync = _empty.emptyDirSync
+export const emptydirSync = _empty.emptydirSync
+export const emptyDir = _empty.emptyDir
+export const emptydir = _empty.emptydir
+export const createFile = _ensure.createFile
+export const createFileSync = _ensure.createFileSync
+export const ensureFile = _ensure.ensureFile
+export const ensureFileSync = _ensure.ensureFileSync
+export const createLink = _ensure.createLink
+export const createLinkSync = _ensure.createLinkSync
+export const ensureLink = _ensure.ensureLink
+export const ensureLinkSync = _ensure.ensureLinkSync
+export const createSymlink = _ensure.createSymlink
+export const createSymlinkSync = _ensure.createSymlinkSync
+export const ensureSymlink = _ensure.ensureSymlink
+export const ensureSymlinkSync = _ensure.ensureSymlinkSync
+export const readJson = _json.readJson
+export const readJSON = _json.readJSON
+export const readJsonSync = _json.readJsonSync
+export const readJSONSync = _json.readJSONSync
+export const writeJson = _json.writeJson
+export const writeJSON = _json.writeJSON
+export const writeJsonSync = _json.writeJsonSync
+export const writeJSONSync = _json.writeJSONSync
+export const outputJson = _json.outputJson
+export const outputJSON = _json.outputJSON
+export const outputJsonSync = _json.outputJsonSync
+export const outputJSONSync = _json.outputJSONSync
+export const mkdirs = _mkdirs.mkdirs
+export const mkdirsSync = _mkdirs.mkdirsSync
+export const mkdirp = _mkdirs.mkdirp
+export const mkdirpSync = _mkdirs.mkdirpSync
+export const ensureDir = _mkdirs.ensureDir
+export const ensureDirSync = _mkdirs.ensureDirSync
+export const move = _move.move
+export const moveSync = _move.moveSync
+export const outputFile = _outputFile.outputFile
+export const outputFileSync = _outputFile.outputFileSync
+export const pathExists = _pathExists.pathExists
+export const pathExistsSync = _pathExists.pathExistsSync
+export const remove = _remove.remove
+export const removeSync = _remove.removeSync
+
+export default {
+ ..._copy,
+ ..._empty,
+ ..._ensure,
+ ..._json,
+ ..._mkdirs,
+ ..._move,
+ ..._outputFile,
+ ..._pathExists,
+ ..._remove
+}
diff --git a/node_modules/fs-extra/lib/fs/index.js b/node_modules/fs-extra/lib/fs/index.js
new file mode 100644
index 0000000..3c3ec51
--- /dev/null
+++ b/node_modules/fs-extra/lib/fs/index.js
@@ -0,0 +1,140 @@
+'use strict'
+// This is adapted from https://github.com/normalize/mz
+// Copyright (c) 2014-2016 Jonathan Ong me@jongleberry.com and Contributors
+const u = require('universalify').fromCallback
+const fs = require('graceful-fs')
+
+const api = [
+ '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(key => {
+ // Some commands are not available on some systems. Ex:
+ // fs.cp was added in Node.js v16.7.0
+ // fs.lchown is not available on at least some Linux
+ return typeof fs[key] === 'function'
+})
+
+// Export cloned fs:
+Object.assign(exports, fs)
+
+// Universalify async methods:
+api.forEach(method => {
+ exports[method] = u(fs[method])
+})
+
+// We differ from mz/fs in that we still ship the old, broken, fs.exists()
+// since we are a drop-in replacement for the native module
+exports.exists = function (filename, callback) {
+ if (typeof callback === 'function') {
+ return fs.exists(filename, callback)
+ }
+ return new Promise(resolve => {
+ return fs.exists(filename, resolve)
+ })
+}
+
+// fs.read(), fs.write(), fs.readv(), & fs.writev() need special treatment due to multiple callback args
+
+exports.read = function (fd, buffer, offset, length, position, callback) {
+ if (typeof callback === 'function') {
+ return fs.read(fd, buffer, offset, length, position, callback)
+ }
+ return new Promise((resolve, reject) => {
+ fs.read(fd, buffer, offset, length, position, (err, bytesRead, buffer) => {
+ if (err) return reject(err)
+ resolve({ bytesRead, buffer })
+ })
+ })
+}
+
+// Function signature can be
+// fs.write(fd, buffer[, offset[, length[, position]]], callback)
+// OR
+// fs.write(fd, string[, position[, encoding]], callback)
+// We need to handle both cases, so we use ...args
+exports.write = function (fd, buffer, ...args) {
+ if (typeof args[args.length - 1] === 'function') {
+ return fs.write(fd, buffer, ...args)
+ }
+
+ return new Promise((resolve, reject) => {
+ fs.write(fd, buffer, ...args, (err, bytesWritten, buffer) => {
+ if (err) return reject(err)
+ resolve({ bytesWritten, buffer })
+ })
+ })
+}
+
+// Function signature is
+// s.readv(fd, buffers[, position], callback)
+// We need to handle the optional arg, so we use ...args
+exports.readv = function (fd, buffers, ...args) {
+ if (typeof args[args.length - 1] === 'function') {
+ return fs.readv(fd, buffers, ...args)
+ }
+
+ return new Promise((resolve, reject) => {
+ fs.readv(fd, buffers, ...args, (err, bytesRead, buffers) => {
+ if (err) return reject(err)
+ resolve({ bytesRead, buffers })
+ })
+ })
+}
+
+// Function signature is
+// s.writev(fd, buffers[, position], callback)
+// We need to handle the optional arg, so we use ...args
+exports.writev = function (fd, buffers, ...args) {
+ if (typeof args[args.length - 1] === 'function') {
+ return fs.writev(fd, buffers, ...args)
+ }
+
+ return new Promise((resolve, reject) => {
+ fs.writev(fd, buffers, ...args, (err, bytesWritten, buffers) => {
+ if (err) return reject(err)
+ resolve({ bytesWritten, buffers })
+ })
+ })
+}
+
+// fs.realpath.native sometimes not available if fs is monkey-patched
+if (typeof fs.realpath.native === 'function') {
+ exports.realpath.native = u(fs.realpath.native)
+} else {
+ process.emitWarning(
+ 'fs.realpath.native is not a function. Is fs being monkey-patched?',
+ 'Warning', 'fs-extra-WARN0003'
+ )
+}
diff --git a/node_modules/fs-extra/lib/index.js b/node_modules/fs-extra/lib/index.js
new file mode 100644
index 0000000..da6711a
--- /dev/null
+++ b/node_modules/fs-extra/lib/index.js
@@ -0,0 +1,16 @@
+'use strict'
+
+module.exports = {
+ // Export promiseified graceful-fs:
+ ...require('./fs'),
+ // Export extra methods:
+ ...require('./copy'),
+ ...require('./empty'),
+ ...require('./ensure'),
+ ...require('./json'),
+ ...require('./mkdirs'),
+ ...require('./move'),
+ ...require('./output-file'),
+ ...require('./path-exists'),
+ ...require('./remove')
+}
diff --git a/node_modules/fs-extra/lib/json/index.js b/node_modules/fs-extra/lib/json/index.js
new file mode 100644
index 0000000..900126a
--- /dev/null
+++ b/node_modules/fs-extra/lib/json/index.js
@@ -0,0 +1,16 @@
+'use strict'
+
+const u = require('universalify').fromPromise
+const jsonFile = require('./jsonfile')
+
+jsonFile.outputJson = u(require('./output-json'))
+jsonFile.outputJsonSync = require('./output-json-sync')
+// aliases
+jsonFile.outputJSON = jsonFile.outputJson
+jsonFile.outputJSONSync = jsonFile.outputJsonSync
+jsonFile.writeJSON = jsonFile.writeJson
+jsonFile.writeJSONSync = jsonFile.writeJsonSync
+jsonFile.readJSON = jsonFile.readJson
+jsonFile.readJSONSync = jsonFile.readJsonSync
+
+module.exports = jsonFile
diff --git a/node_modules/fs-extra/lib/json/jsonfile.js b/node_modules/fs-extra/lib/json/jsonfile.js
new file mode 100644
index 0000000..f11d34d
--- /dev/null
+++ b/node_modules/fs-extra/lib/json/jsonfile.js
@@ -0,0 +1,11 @@
+'use strict'
+
+const jsonFile = require('jsonfile')
+
+module.exports = {
+ // jsonfile exports
+ readJson: jsonFile.readFile,
+ readJsonSync: jsonFile.readFileSync,
+ writeJson: jsonFile.writeFile,
+ writeJsonSync: jsonFile.writeFileSync
+}
diff --git a/node_modules/fs-extra/lib/json/output-json-sync.js b/node_modules/fs-extra/lib/json/output-json-sync.js
new file mode 100644
index 0000000..d4e564f
--- /dev/null
+++ b/node_modules/fs-extra/lib/json/output-json-sync.js
@@ -0,0 +1,12 @@
+'use strict'
+
+const { stringify } = require('jsonfile/utils')
+const { outputFileSync } = require('../output-file')
+
+function outputJsonSync (file, data, options) {
+ const str = stringify(data, options)
+
+ outputFileSync(file, str, options)
+}
+
+module.exports = outputJsonSync
diff --git a/node_modules/fs-extra/lib/json/output-json.js b/node_modules/fs-extra/lib/json/output-json.js
new file mode 100644
index 0000000..0afdeb6
--- /dev/null
+++ b/node_modules/fs-extra/lib/json/output-json.js
@@ -0,0 +1,12 @@
+'use strict'
+
+const { stringify } = require('jsonfile/utils')
+const { outputFile } = require('../output-file')
+
+async function outputJson (file, data, options = {}) {
+ const str = stringify(data, options)
+
+ await outputFile(file, str, options)
+}
+
+module.exports = outputJson
diff --git a/node_modules/fs-extra/lib/mkdirs/index.js b/node_modules/fs-extra/lib/mkdirs/index.js
new file mode 100644
index 0000000..9edecee
--- /dev/null
+++ b/node_modules/fs-extra/lib/mkdirs/index.js
@@ -0,0 +1,14 @@
+'use strict'
+const u = require('universalify').fromPromise
+const { makeDir: _makeDir, makeDirSync } = require('./make-dir')
+const makeDir = u(_makeDir)
+
+module.exports = {
+ mkdirs: makeDir,
+ mkdirsSync: makeDirSync,
+ // alias
+ mkdirp: makeDir,
+ mkdirpSync: makeDirSync,
+ ensureDir: makeDir,
+ ensureDirSync: makeDirSync
+}
diff --git a/node_modules/fs-extra/lib/mkdirs/make-dir.js b/node_modules/fs-extra/lib/mkdirs/make-dir.js
new file mode 100644
index 0000000..45ece64
--- /dev/null
+++ b/node_modules/fs-extra/lib/mkdirs/make-dir.js
@@ -0,0 +1,27 @@
+'use strict'
+const fs = require('../fs')
+const { checkPath } = require('./utils')
+
+const getMode = options => {
+ const defaults = { mode: 0o777 }
+ if (typeof options === 'number') return options
+ return ({ ...defaults, ...options }).mode
+}
+
+module.exports.makeDir = async (dir, options) => {
+ checkPath(dir)
+
+ return fs.mkdir(dir, {
+ mode: getMode(options),
+ recursive: true
+ })
+}
+
+module.exports.makeDirSync = (dir, options) => {
+ checkPath(dir)
+
+ return fs.mkdirSync(dir, {
+ mode: getMode(options),
+ recursive: true
+ })
+}
diff --git a/node_modules/fs-extra/lib/mkdirs/utils.js b/node_modules/fs-extra/lib/mkdirs/utils.js
new file mode 100644
index 0000000..a4059ad
--- /dev/null
+++ b/node_modules/fs-extra/lib/mkdirs/utils.js
@@ -0,0 +1,21 @@
+// Adapted from https://github.com/sindresorhus/make-dir
+// Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
+// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+'use strict'
+const path = require('path')
+
+// https://github.com/nodejs/node/issues/8987
+// https://github.com/libuv/libuv/pull/1088
+module.exports.checkPath = function checkPath (pth) {
+ if (process.platform === 'win32') {
+ const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path.parse(pth).root, ''))
+
+ if (pathHasInvalidWinCharacters) {
+ const error = new Error(`Path contains invalid characters: ${pth}`)
+ error.code = 'EINVAL'
+ throw error
+ }
+ }
+}
diff --git a/node_modules/fs-extra/lib/move/index.js b/node_modules/fs-extra/lib/move/index.js
new file mode 100644
index 0000000..fcee73c
--- /dev/null
+++ b/node_modules/fs-extra/lib/move/index.js
@@ -0,0 +1,7 @@
+'use strict'
+
+const u = require('universalify').fromCallback
+module.exports = {
+ move: u(require('./move')),
+ moveSync: require('./move-sync')
+}
diff --git a/node_modules/fs-extra/lib/move/move-sync.js b/node_modules/fs-extra/lib/move/move-sync.js
new file mode 100644
index 0000000..c456ab3
--- /dev/null
+++ b/node_modules/fs-extra/lib/move/move-sync.js
@@ -0,0 +1,55 @@
+'use strict'
+
+const fs = require('graceful-fs')
+const path = require('path')
+const copySync = require('../copy').copySync
+const removeSync = require('../remove').removeSync
+const mkdirpSync = require('../mkdirs').mkdirpSync
+const stat = require('../util/stat')
+
+function moveSync (src, dest, opts) {
+ opts = opts || {}
+ const overwrite = opts.overwrite || opts.clobber || false
+
+ const { srcStat, isChangingCase = false } = stat.checkPathsSync(src, dest, 'move', opts)
+ stat.checkParentPathsSync(src, srcStat, dest, 'move')
+ if (!isParentRoot(dest)) mkdirpSync(path.dirname(dest))
+ return doRename(src, dest, overwrite, isChangingCase)
+}
+
+function isParentRoot (dest) {
+ const parent = path.dirname(dest)
+ const parsedPath = path.parse(parent)
+ return parsedPath.root === parent
+}
+
+function doRename (src, dest, overwrite, isChangingCase) {
+ if (isChangingCase) return rename(src, dest, overwrite)
+ if (overwrite) {
+ removeSync(dest)
+ return rename(src, dest, overwrite)
+ }
+ if (fs.existsSync(dest)) throw new Error('dest already exists.')
+ return rename(src, dest, overwrite)
+}
+
+function rename (src, dest, overwrite) {
+ try {
+ fs.renameSync(src, dest)
+ } catch (err) {
+ if (err.code !== 'EXDEV') throw err
+ return moveAcrossDevice(src, dest, overwrite)
+ }
+}
+
+function moveAcrossDevice (src, dest, overwrite) {
+ const opts = {
+ overwrite,
+ errorOnExist: true,
+ preserveTimestamps: true
+ }
+ copySync(src, dest, opts)
+ return removeSync(src)
+}
+
+module.exports = moveSync
diff --git a/node_modules/fs-extra/lib/move/move.js b/node_modules/fs-extra/lib/move/move.js
new file mode 100644
index 0000000..5c4d74f
--- /dev/null
+++ b/node_modules/fs-extra/lib/move/move.js
@@ -0,0 +1,76 @@
+'use strict'
+
+const fs = require('graceful-fs')
+const path = require('path')
+const copy = require('../copy').copy
+const remove = require('../remove').remove
+const mkdirp = require('../mkdirs').mkdirp
+const pathExists = require('../path-exists').pathExists
+const stat = require('../util/stat')
+
+function move (src, dest, opts, cb) {
+ if (typeof opts === 'function') {
+ cb = opts
+ opts = {}
+ }
+
+ opts = opts || {}
+
+ const overwrite = opts.overwrite || opts.clobber || false
+
+ stat.checkPaths(src, dest, 'move', opts, (err, stats) => {
+ if (err) return cb(err)
+ const { srcStat, isChangingCase = false } = stats
+ stat.checkParentPaths(src, srcStat, dest, 'move', err => {
+ if (err) return cb(err)
+ if (isParentRoot(dest)) return doRename(src, dest, overwrite, isChangingCase, cb)
+ mkdirp(path.dirname(dest), err => {
+ if (err) return cb(err)
+ return doRename(src, dest, overwrite, isChangingCase, cb)
+ })
+ })
+ })
+}
+
+function isParentRoot (dest) {
+ const parent = path.dirname(dest)
+ const parsedPath = path.parse(parent)
+ return parsedPath.root === parent
+}
+
+function doRename (src, dest, overwrite, isChangingCase, cb) {
+ if (isChangingCase) return rename(src, dest, overwrite, cb)
+ if (overwrite) {
+ return remove(dest, err => {
+ if (err) return cb(err)
+ return rename(src, dest, overwrite, cb)
+ })
+ }
+ pathExists(dest, (err, destExists) => {
+ if (err) return cb(err)
+ if (destExists) return cb(new Error('dest already exists.'))
+ return rename(src, dest, overwrite, cb)
+ })
+}
+
+function rename (src, dest, overwrite, cb) {
+ fs.rename(src, dest, err => {
+ if (!err) return cb()
+ if (err.code !== 'EXDEV') return cb(err)
+ return moveAcrossDevice(src, dest, overwrite, cb)
+ })
+}
+
+function moveAcrossDevice (src, dest, overwrite, cb) {
+ const opts = {
+ overwrite,
+ errorOnExist: true,
+ preserveTimestamps: true
+ }
+ copy(src, dest, opts, err => {
+ if (err) return cb(err)
+ return remove(src, cb)
+ })
+}
+
+module.exports = move
diff --git a/node_modules/fs-extra/lib/output-file/index.js b/node_modules/fs-extra/lib/output-file/index.js
new file mode 100644
index 0000000..92297ca
--- /dev/null
+++ b/node_modules/fs-extra/lib/output-file/index.js
@@ -0,0 +1,40 @@
+'use strict'
+
+const u = require('universalify').fromCallback
+const fs = require('graceful-fs')
+const path = require('path')
+const mkdir = require('../mkdirs')
+const pathExists = require('../path-exists').pathExists
+
+function outputFile (file, data, encoding, callback) {
+ if (typeof encoding === 'function') {
+ callback = encoding
+ encoding = 'utf8'
+ }
+
+ const dir = path.dirname(file)
+ pathExists(dir, (err, itDoes) => {
+ if (err) return callback(err)
+ if (itDoes) return fs.writeFile(file, data, encoding, callback)
+
+ mkdir.mkdirs(dir, err => {
+ if (err) return callback(err)
+
+ fs.writeFile(file, data, encoding, callback)
+ })
+ })
+}
+
+function outputFileSync (file, ...args) {
+ const dir = path.dirname(file)
+ if (fs.existsSync(dir)) {
+ return fs.writeFileSync(file, ...args)
+ }
+ mkdir.mkdirsSync(dir)
+ fs.writeFileSync(file, ...args)
+}
+
+module.exports = {
+ outputFile: u(outputFile),
+ outputFileSync
+}
diff --git a/node_modules/fs-extra/lib/path-exists/index.js b/node_modules/fs-extra/lib/path-exists/index.js
new file mode 100644
index 0000000..ddd9bc7
--- /dev/null
+++ b/node_modules/fs-extra/lib/path-exists/index.js
@@ -0,0 +1,12 @@
+'use strict'
+const u = require('universalify').fromPromise
+const fs = require('../fs')
+
+function pathExists (path) {
+ return fs.access(path).then(() => true).catch(() => false)
+}
+
+module.exports = {
+ pathExists: u(pathExists),
+ pathExistsSync: fs.existsSync
+}
diff --git a/node_modules/fs-extra/lib/remove/index.js b/node_modules/fs-extra/lib/remove/index.js
new file mode 100644
index 0000000..da746c7
--- /dev/null
+++ b/node_modules/fs-extra/lib/remove/index.js
@@ -0,0 +1,17 @@
+'use strict'
+
+const fs = require('graceful-fs')
+const u = require('universalify').fromCallback
+
+function remove (path, callback) {
+ fs.rm(path, { recursive: true, force: true }, callback)
+}
+
+function removeSync (path) {
+ fs.rmSync(path, { recursive: true, force: true })
+}
+
+module.exports = {
+ remove: u(remove),
+ removeSync
+}
diff --git a/node_modules/fs-extra/lib/util/stat.js b/node_modules/fs-extra/lib/util/stat.js
new file mode 100644
index 0000000..0ed5aec
--- /dev/null
+++ b/node_modules/fs-extra/lib/util/stat.js
@@ -0,0 +1,154 @@
+'use strict'
+
+const fs = require('../fs')
+const path = require('path')
+const util = require('util')
+
+function getStats (src, dest, opts) {
+ const statFunc = opts.dereference
+ ? (file) => fs.stat(file, { bigint: true })
+ : (file) => fs.lstat(file, { bigint: true })
+ return Promise.all([
+ statFunc(src),
+ statFunc(dest).catch(err => {
+ if (err.code === 'ENOENT') return null
+ throw err
+ })
+ ]).then(([srcStat, destStat]) => ({ srcStat, destStat }))
+}
+
+function getStatsSync (src, dest, opts) {
+ let destStat
+ const statFunc = opts.dereference
+ ? (file) => fs.statSync(file, { bigint: true })
+ : (file) => fs.lstatSync(file, { bigint: true })
+ const srcStat = statFunc(src)
+ try {
+ destStat = statFunc(dest)
+ } catch (err) {
+ if (err.code === 'ENOENT') return { srcStat, destStat: null }
+ throw err
+ }
+ return { srcStat, destStat }
+}
+
+function checkPaths (src, dest, funcName, opts, cb) {
+ util.callbackify(getStats)(src, dest, opts, (err, stats) => {
+ if (err) return cb(err)
+ const { srcStat, destStat } = stats
+
+ if (destStat) {
+ if (areIdentical(srcStat, destStat)) {
+ const srcBaseName = path.basename(src)
+ const destBaseName = path.basename(dest)
+ if (funcName === 'move' &&
+ srcBaseName !== destBaseName &&
+ srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
+ return cb(null, { srcStat, destStat, isChangingCase: true })
+ }
+ return cb(new Error('Source and destination must not be the same.'))
+ }
+ if (srcStat.isDirectory() && !destStat.isDirectory()) {
+ return cb(new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`))
+ }
+ if (!srcStat.isDirectory() && destStat.isDirectory()) {
+ return cb(new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`))
+ }
+ }
+
+ if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
+ return cb(new Error(errMsg(src, dest, funcName)))
+ }
+ return cb(null, { srcStat, destStat })
+ })
+}
+
+function checkPathsSync (src, dest, funcName, opts) {
+ const { srcStat, destStat } = getStatsSync(src, dest, opts)
+
+ if (destStat) {
+ if (areIdentical(srcStat, destStat)) {
+ const srcBaseName = path.basename(src)
+ const destBaseName = path.basename(dest)
+ if (funcName === 'move' &&
+ srcBaseName !== destBaseName &&
+ srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
+ return { srcStat, destStat, isChangingCase: true }
+ }
+ throw new Error('Source and destination must not be the same.')
+ }
+ if (srcStat.isDirectory() && !destStat.isDirectory()) {
+ throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`)
+ }
+ if (!srcStat.isDirectory() && destStat.isDirectory()) {
+ throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`)
+ }
+ }
+
+ if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
+ throw new Error(errMsg(src, dest, funcName))
+ }
+ return { srcStat, destStat }
+}
+
+// recursively check if dest parent is a subdirectory of src.
+// It works for all file types including symlinks since it
+// checks the src and dest inodes. It starts from the deepest
+// parent and stops once it reaches the src parent or the root path.
+function checkParentPaths (src, srcStat, dest, funcName, cb) {
+ const srcParent = path.resolve(path.dirname(src))
+ const destParent = path.resolve(path.dirname(dest))
+ if (destParent === srcParent || destParent === path.parse(destParent).root) return cb()
+ fs.stat(destParent, { bigint: true }, (err, destStat) => {
+ if (err) {
+ if (err.code === 'ENOENT') return cb()
+ return cb(err)
+ }
+ if (areIdentical(srcStat, destStat)) {
+ return cb(new Error(errMsg(src, dest, funcName)))
+ }
+ return checkParentPaths(src, srcStat, destParent, funcName, cb)
+ })
+}
+
+function checkParentPathsSync (src, srcStat, dest, funcName) {
+ const srcParent = path.resolve(path.dirname(src))
+ const destParent = path.resolve(path.dirname(dest))
+ if (destParent === srcParent || destParent === path.parse(destParent).root) return
+ let destStat
+ try {
+ destStat = fs.statSync(destParent, { bigint: true })
+ } catch (err) {
+ if (err.code === 'ENOENT') return
+ throw err
+ }
+ if (areIdentical(srcStat, destStat)) {
+ throw new Error(errMsg(src, dest, funcName))
+ }
+ return checkParentPathsSync(src, srcStat, destParent, funcName)
+}
+
+function areIdentical (srcStat, destStat) {
+ return destStat.ino && destStat.dev && destStat.ino === srcStat.ino && destStat.dev === srcStat.dev
+}
+
+// return true if dest is a subdir of src, otherwise false.
+// It only checks the path strings.
+function isSrcSubdir (src, dest) {
+ const srcArr = path.resolve(src).split(path.sep).filter(i => i)
+ const destArr = path.resolve(dest).split(path.sep).filter(i => i)
+ return srcArr.reduce((acc, cur, i) => acc && destArr[i] === cur, true)
+}
+
+function errMsg (src, dest, funcName) {
+ return `Cannot ${funcName} '${src}' to a subdirectory of itself, '${dest}'.`
+}
+
+module.exports = {
+ checkPaths,
+ checkPathsSync,
+ checkParentPaths,
+ checkParentPathsSync,
+ isSrcSubdir,
+ areIdentical
+}
diff --git a/node_modules/fs-extra/lib/util/utimes.js b/node_modules/fs-extra/lib/util/utimes.js
new file mode 100644
index 0000000..75395de
--- /dev/null
+++ b/node_modules/fs-extra/lib/util/utimes.js
@@ -0,0 +1,26 @@
+'use strict'
+
+const fs = require('graceful-fs')
+
+function utimesMillis (path, atime, mtime, callback) {
+ // if (!HAS_MILLIS_RES) return fs.utimes(path, atime, mtime, callback)
+ fs.open(path, 'r+', (err, fd) => {
+ if (err) return callback(err)
+ fs.futimes(fd, atime, mtime, futimesErr => {
+ fs.close(fd, closeErr => {
+ if (callback) callback(futimesErr || closeErr)
+ })
+ })
+ })
+}
+
+function utimesMillisSync (path, atime, mtime) {
+ const fd = fs.openSync(path, 'r+')
+ fs.futimesSync(fd, atime, mtime)
+ return fs.closeSync(fd)
+}
+
+module.exports = {
+ utimesMillis,
+ utimesMillisSync
+}