Bump fs-extra from 9.1.0 to 10.0.0 (#139)

* Bump fs-extra from 9.1.0 to 10.0.0

Bumps [fs-extra](https://github.com/jprichardson/node-fs-extra) from 9.1.0 to 10.0.0.
- [Release notes](https://github.com/jprichardson/node-fs-extra/releases)
- [Changelog](https://github.com/jprichardson/node-fs-extra/blob/master/CHANGELOG.md)
- [Commits](https://github.com/jprichardson/node-fs-extra/compare/9.1.0...10.0.0)

Signed-off-by: dependabot[bot] <support@github.com>

* Update generated content

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
dependabot[bot] 2021-05-13 00:15:32 +02:00 committed by GitHub
parent 6e28e382c1
commit 1424fdc8bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 209 additions and 276 deletions

469
dist/index.js generated vendored
View File

@ -2207,18 +2207,6 @@ Tokenizer.prototype.checkChar = function (chr) {
}; };
/***/ }),
/***/ 5995:
/***/ ((module) => {
module.exports = r => {
const n = process.versions.node.split('.').map(x => parseInt(x, 10))
r = r.split('.').map(x => parseInt(x, 10))
return n[0] > r[0] || (n[0] === r[0] && (n[1] > r[1] || (n[1] === r[1] && n[2] >= r[2])))
}
/***/ }), /***/ }),
/***/ 3338: /***/ 3338:
@ -2248,7 +2236,7 @@ function copySync (src, dest, opts) {
see https://github.com/jprichardson/node-fs-extra/issues/269`) see https://github.com/jprichardson/node-fs-extra/issues/269`)
} }
const { srcStat, destStat } = stat.checkPathsSync(src, dest, 'copy') const { srcStat, destStat } = stat.checkPathsSync(src, dest, 'copy', opts)
stat.checkParentPathsSync(src, srcStat, dest, 'copy') stat.checkParentPathsSync(src, srcStat, dest, 'copy')
return handleFilterAndCopy(destStat, src, dest, opts) return handleFilterAndCopy(destStat, src, dest, opts)
} }
@ -2257,7 +2245,7 @@ function handleFilterAndCopy (destStat, src, dest, opts) {
if (opts.filter && !opts.filter(src, dest)) return if (opts.filter && !opts.filter(src, dest)) return
const destParent = path.dirname(dest) const destParent = path.dirname(dest)
if (!fs.existsSync(destParent)) mkdirsSync(destParent) if (!fs.existsSync(destParent)) mkdirsSync(destParent)
return startCopy(destStat, src, dest, opts) return getStats(destStat, src, dest, opts)
} }
function startCopy (destStat, src, dest, opts) { function startCopy (destStat, src, dest, opts) {
@ -2274,6 +2262,9 @@ function getStats (destStat, src, dest, opts) {
srcStat.isCharacterDevice() || srcStat.isCharacterDevice() ||
srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts) srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts)
else if (srcStat.isSymbolicLink()) return onLink(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) { function onFile (srcStat, destStat, src, dest, opts) {
@ -2326,9 +2317,6 @@ function setDestTimestamps (src, dest) {
function onDir (srcStat, destStat, src, dest, opts) { function onDir (srcStat, destStat, src, dest, opts) {
if (!destStat) return mkDirAndCopy(srcStat.mode, src, dest, opts) if (!destStat) return mkDirAndCopy(srcStat.mode, src, dest, opts)
if (destStat && !destStat.isDirectory()) {
throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`)
}
return copyDir(src, dest, opts) return copyDir(src, dest, opts)
} }
@ -2345,7 +2333,7 @@ function copyDir (src, dest, opts) {
function copyDirItem (item, src, dest, opts) { function copyDirItem (item, src, dest, opts) {
const srcItem = path.join(src, item) const srcItem = path.join(src, item)
const destItem = path.join(dest, item) const destItem = path.join(dest, item)
const { destStat } = stat.checkPathsSync(srcItem, destItem, 'copy') const { destStat } = stat.checkPathsSync(srcItem, destItem, 'copy', opts)
return startCopy(destStat, srcItem, destItem, opts) return startCopy(destStat, srcItem, destItem, opts)
} }
@ -2441,7 +2429,7 @@ function copy (src, dest, opts, cb) {
see https://github.com/jprichardson/node-fs-extra/issues/269`) see https://github.com/jprichardson/node-fs-extra/issues/269`)
} }
stat.checkPaths(src, dest, 'copy', (err, stats) => { stat.checkPaths(src, dest, 'copy', opts, (err, stats) => {
if (err) return cb(err) if (err) return cb(err)
const { srcStat, destStat } = stats const { srcStat, destStat } = stats
stat.checkParentPaths(src, srcStat, dest, 'copy', err => { stat.checkParentPaths(src, srcStat, dest, 'copy', err => {
@ -2456,10 +2444,10 @@ function checkParentDir (destStat, src, dest, opts, cb) {
const destParent = path.dirname(dest) const destParent = path.dirname(dest)
pathExists(destParent, (err, dirExists) => { pathExists(destParent, (err, dirExists) => {
if (err) return cb(err) if (err) return cb(err)
if (dirExists) return startCopy(destStat, src, dest, opts, cb) if (dirExists) return getStats(destStat, src, dest, opts, cb)
mkdirs(destParent, err => { mkdirs(destParent, err => {
if (err) return cb(err) if (err) return cb(err)
return startCopy(destStat, src, dest, opts, cb) return getStats(destStat, src, dest, opts, cb)
}) })
}) })
} }
@ -2486,6 +2474,9 @@ function getStats (destStat, src, dest, opts, cb) {
srcStat.isCharacterDevice() || srcStat.isCharacterDevice() ||
srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts, cb) srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts, cb)
else if (srcStat.isSymbolicLink()) return onLink(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}`))
}) })
} }
@ -2557,9 +2548,6 @@ function setDestTimestamps (src, dest, cb) {
function onDir (srcStat, destStat, src, dest, opts, cb) { function onDir (srcStat, destStat, src, dest, opts, cb) {
if (!destStat) return mkDirAndCopy(srcStat.mode, src, dest, opts, cb) if (!destStat) return mkDirAndCopy(srcStat.mode, src, dest, opts, cb)
if (destStat && !destStat.isDirectory()) {
return cb(new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`))
}
return copyDir(src, dest, opts, cb) return copyDir(src, dest, opts, cb)
} }
@ -2589,7 +2577,7 @@ function copyDirItems (items, src, dest, opts, cb) {
function copyDirItem (items, item, src, dest, opts, cb) { function copyDirItem (items, item, src, dest, opts, cb) {
const srcItem = path.join(src, item) const srcItem = path.join(src, item)
const destItem = path.join(dest, item) const destItem = path.join(dest, item)
stat.checkPaths(srcItem, destItem, 'copy', (err, stats) => { stat.checkPaths(srcItem, destItem, 'copy', opts, (err, stats) => {
if (err) return cb(err) if (err) return cb(err)
const { destStat } = stats const { destStat } = stats
startCopy(destStat, srcItem, destItem, opts, err => { startCopy(destStat, srcItem, destItem, opts, err => {
@ -2668,30 +2656,21 @@ module.exports = {
"use strict"; "use strict";
const u = __webpack_require__(9046).fromCallback const u = __webpack_require__(9046).fromPromise
const fs = __webpack_require__(7758) const fs = __webpack_require__(1176)
const path = __webpack_require__(5622) const path = __webpack_require__(5622)
const mkdir = __webpack_require__(8605) const mkdir = __webpack_require__(8605)
const remove = __webpack_require__(7357) const remove = __webpack_require__(7357)
const emptyDir = u(function emptyDir (dir, callback) { const emptyDir = u(async function emptyDir (dir) {
callback = callback || function () {} let items
fs.readdir(dir, (err, items) => { try {
if (err) return mkdir.mkdirs(dir, callback) items = await fs.readdir(dir)
} catch {
return mkdir.mkdirs(dir)
}
items = items.map(item => path.join(dir, item)) return Promise.all(items.map(item => remove.remove(path.join(dir, item))))
deleteItem()
function deleteItem () {
const item = items.pop()
if (!item) return callback()
remove.remove(item, err => {
if (err) return callback(err)
deleteItem()
})
}
})
}) })
function emptyDirSync (dir) { function emptyDirSync (dir) {
@ -2837,6 +2816,7 @@ const path = __webpack_require__(5622)
const fs = __webpack_require__(7758) const fs = __webpack_require__(7758)
const mkdir = __webpack_require__(8605) const mkdir = __webpack_require__(8605)
const pathExists = __webpack_require__(3835).pathExists const pathExists = __webpack_require__(3835).pathExists
const { areIdentical } = __webpack_require__(3901)
function createLink (srcpath, dstpath, callback) { function createLink (srcpath, dstpath, callback) {
function makeLink (srcpath, dstpath) { function makeLink (srcpath, dstpath) {
@ -2846,14 +2826,13 @@ function createLink (srcpath, dstpath, callback) {
}) })
} }
pathExists(dstpath, (err, destinationExists) => { fs.lstat(dstpath, (_, dstStat) => {
if (err) return callback(err) fs.lstat(srcpath, (err, srcStat) => {
if (destinationExists) return callback(null)
fs.lstat(srcpath, (err) => {
if (err) { if (err) {
err.message = err.message.replace('lstat', 'ensureLink') err.message = err.message.replace('lstat', 'ensureLink')
return callback(err) return callback(err)
} }
if (dstStat && areIdentical(srcStat, dstStat)) return callback(null)
const dir = path.dirname(dstpath) const dir = path.dirname(dstpath)
pathExists(dir, (err, dirExists) => { pathExists(dir, (err, dirExists) => {
@ -2869,11 +2848,14 @@ function createLink (srcpath, dstpath, callback) {
} }
function createLinkSync (srcpath, dstpath) { function createLinkSync (srcpath, dstpath) {
const destinationExists = fs.existsSync(dstpath) let dstStat
if (destinationExists) return undefined try {
dstStat = fs.lstatSync(dstpath)
} catch {}
try { try {
fs.lstatSync(srcpath) const srcStat = fs.lstatSync(srcpath)
if (dstStat && areIdentical(srcStat, dstStat)) return
} catch (err) { } catch (err) {
err.message = err.message.replace('lstat', 'ensureLink') err.message = err.message.replace('lstat', 'ensureLink')
throw err throw err
@ -3049,7 +3031,7 @@ module.exports = {
const u = __webpack_require__(9046).fromCallback const u = __webpack_require__(9046).fromCallback
const path = __webpack_require__(5622) const path = __webpack_require__(5622)
const fs = __webpack_require__(7758) const fs = __webpack_require__(1176)
const _mkdirs = __webpack_require__(8605) const _mkdirs = __webpack_require__(8605)
const mkdirs = _mkdirs.mkdirs const mkdirs = _mkdirs.mkdirs
const mkdirsSync = _mkdirs.mkdirsSync const mkdirsSync = _mkdirs.mkdirsSync
@ -3064,26 +3046,38 @@ const symlinkTypeSync = _symlinkType.symlinkTypeSync
const pathExists = __webpack_require__(3835).pathExists const pathExists = __webpack_require__(3835).pathExists
const { areIdentical } = __webpack_require__(3901)
function createSymlink (srcpath, dstpath, type, callback) { function createSymlink (srcpath, dstpath, type, callback) {
callback = (typeof type === 'function') ? type : callback callback = (typeof type === 'function') ? type : callback
type = (typeof type === 'function') ? false : type type = (typeof type === 'function') ? false : type
pathExists(dstpath, (err, destinationExists) => { 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) if (err) return callback(err)
if (destinationExists) return callback(null) srcpath = relative.toDst
symlinkPaths(srcpath, dstpath, (err, relative) => { symlinkType(relative.toCwd, type, (err, type) => {
if (err) return callback(err) if (err) return callback(err)
srcpath = relative.toDst const dir = path.dirname(dstpath)
symlinkType(relative.toCwd, type, (err, type) => { pathExists(dir, (err, dirExists) => {
if (err) return callback(err) if (err) return callback(err)
const dir = path.dirname(dstpath) if (dirExists) return fs.symlink(srcpath, dstpath, type, callback)
pathExists(dir, (err, dirExists) => { mkdirs(dir, err => {
if (err) return callback(err) if (err) return callback(err)
if (dirExists) return fs.symlink(srcpath, dstpath, type, callback) fs.symlink(srcpath, dstpath, type, callback)
mkdirs(dir, err => {
if (err) return callback(err)
fs.symlink(srcpath, dstpath, type, callback)
})
}) })
}) })
}) })
@ -3091,8 +3085,15 @@ function createSymlink (srcpath, dstpath, type, callback) {
} }
function createSymlinkSync (srcpath, dstpath, type) { function createSymlinkSync (srcpath, dstpath, type) {
const destinationExists = fs.existsSync(dstpath) let stats
if (destinationExists) return undefined 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) const relative = symlinkPathsSync(srcpath, dstpath)
srcpath = relative.toDst srcpath = relative.toDst
@ -3165,20 +3166,14 @@ const api = [
return typeof fs[key] === 'function' return typeof fs[key] === 'function'
}) })
// Export all keys: // Export cloned fs:
Object.keys(fs).forEach(key => { Object.assign(exports, fs)
if (key === 'promises') {
// fs.promises is a getter property that triggers ExperimentalWarning
// Don't re-export it here, the getter is defined in "lib/index.js"
return
}
exports[key] = fs[key]
})
// Universalify async methods: // Universalify async methods:
api.forEach(method => { api.forEach(method => {
exports[method] = u(fs[method]) exports[method] = u(fs[method])
}) })
exports.realpath.native = u(fs.realpath.native)
// We differ from mz/fs in that we still ship the old, broken, fs.exists() // 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 // since we are a drop-in replacement for the native module
@ -3242,11 +3237,6 @@ if (typeof fs.writev === 'function') {
} }
} }
// fs.realpath.native only available in Node v9.2+
if (typeof fs.realpath.native === 'function') {
exports.realpath.native = u(fs.realpath.native)
}
/***/ }), /***/ }),
@ -3273,15 +3263,6 @@ module.exports = {
...__webpack_require__(7357) ...__webpack_require__(7357)
} }
// Export fs.promises as a getter property so that we don't trigger
// ExperimentalWarning before fs.promises is actually accessed.
const fs = __webpack_require__(5747)
if (Object.getOwnPropertyDescriptor(fs, 'promises')) {
Object.defineProperty(module.exports, "promises", ({
get () { return fs.promises }
}))
}
/***/ }), /***/ }),
@ -3393,6 +3374,41 @@ module.exports = {
/***/ 2751: /***/ 2751:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => { /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
const fs = __webpack_require__(1176)
const { checkPath } = __webpack_require__(9907)
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
})
}
/***/ }),
/***/ 9907:
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict"; "use strict";
// Adapted from https://github.com/sindresorhus/make-dir // Adapted from https://github.com/sindresorhus/make-dir
// Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) // Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
@ -3400,15 +3416,11 @@ module.exports = {
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. // 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. // 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.
const fs = __webpack_require__(1176)
const path = __webpack_require__(5622) const path = __webpack_require__(5622)
const atLeastNode = __webpack_require__(5995)
const useNativeRecursiveOption = atLeastNode('10.12.0')
// https://github.com/nodejs/node/issues/8987 // https://github.com/nodejs/node/issues/8987
// https://github.com/libuv/libuv/pull/1088 // https://github.com/libuv/libuv/pull/1088
const checkPath = pth => { module.exports.checkPath = function checkPath (pth) {
if (process.platform === 'win32') { if (process.platform === 'win32') {
const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path.parse(pth).root, '')) const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path.parse(pth).root, ''))
@ -3420,122 +3432,6 @@ const checkPath = pth => {
} }
} }
const processOptions = options => {
const defaults = { mode: 0o777 }
if (typeof options === 'number') options = { mode: options }
return { ...defaults, ...options }
}
const permissionError = pth => {
// This replicates the exception of `fs.mkdir` with native the
// `recusive` option when run on an invalid drive under Windows.
const error = new Error(`operation not permitted, mkdir '${pth}'`)
error.code = 'EPERM'
error.errno = -4048
error.path = pth
error.syscall = 'mkdir'
return error
}
module.exports.makeDir = async (input, options) => {
checkPath(input)
options = processOptions(options)
if (useNativeRecursiveOption) {
const pth = path.resolve(input)
return fs.mkdir(pth, {
mode: options.mode,
recursive: true
})
}
const make = async pth => {
try {
await fs.mkdir(pth, options.mode)
} catch (error) {
if (error.code === 'EPERM') {
throw error
}
if (error.code === 'ENOENT') {
if (path.dirname(pth) === pth) {
throw permissionError(pth)
}
if (error.message.includes('null bytes')) {
throw error
}
await make(path.dirname(pth))
return make(pth)
}
try {
const stats = await fs.stat(pth)
if (!stats.isDirectory()) {
// This error is never exposed to the user
// it is caught below, and the original error is thrown
throw new Error('The path is not a directory')
}
} catch {
throw error
}
}
}
return make(path.resolve(input))
}
module.exports.makeDirSync = (input, options) => {
checkPath(input)
options = processOptions(options)
if (useNativeRecursiveOption) {
const pth = path.resolve(input)
return fs.mkdirSync(pth, {
mode: options.mode,
recursive: true
})
}
const make = pth => {
try {
fs.mkdirSync(pth, options.mode)
} catch (error) {
if (error.code === 'EPERM') {
throw error
}
if (error.code === 'ENOENT') {
if (path.dirname(pth) === pth) {
throw permissionError(pth)
}
if (error.message.includes('null bytes')) {
throw error
}
make(path.dirname(pth))
return make(pth)
}
try {
if (!fs.statSync(pth).isDirectory()) {
// This error is never exposed to the user
// it is caught below, and the original error is thrown
throw new Error('The path is not a directory')
}
} catch {
throw error
}
}
}
return make(path.resolve(input))
}
/***/ }), /***/ }),
@ -3569,13 +3465,20 @@ function moveSync (src, dest, opts) {
opts = opts || {} opts = opts || {}
const overwrite = opts.overwrite || opts.clobber || false const overwrite = opts.overwrite || opts.clobber || false
const { srcStat } = stat.checkPathsSync(src, dest, 'move') const { srcStat, isChangingCase = false } = stat.checkPathsSync(src, dest, 'move', opts)
stat.checkParentPathsSync(src, srcStat, dest, 'move') stat.checkParentPathsSync(src, srcStat, dest, 'move')
mkdirpSync(path.dirname(dest)) if (!isParentRoot(dest)) mkdirpSync(path.dirname(dest))
return doRename(src, dest, overwrite) return doRename(src, dest, overwrite, isChangingCase)
} }
function doRename (src, dest, overwrite) { 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) { if (overwrite) {
removeSync(dest) removeSync(dest)
return rename(src, dest, overwrite) return rename(src, dest, overwrite)
@ -3643,20 +3546,28 @@ function move (src, dest, opts, cb) {
const overwrite = opts.overwrite || opts.clobber || false const overwrite = opts.overwrite || opts.clobber || false
stat.checkPaths(src, dest, 'move', (err, stats) => { stat.checkPaths(src, dest, 'move', opts, (err, stats) => {
if (err) return cb(err) if (err) return cb(err)
const { srcStat } = stats const { srcStat, isChangingCase = false } = stats
stat.checkParentPaths(src, srcStat, dest, 'move', err => { stat.checkParentPaths(src, srcStat, dest, 'move', err => {
if (err) return cb(err) if (err) return cb(err)
if (isParentRoot(dest)) return doRename(src, dest, overwrite, isChangingCase, cb)
mkdirp(path.dirname(dest), err => { mkdirp(path.dirname(dest), err => {
if (err) return cb(err) if (err) return cb(err)
return doRename(src, dest, overwrite, cb) return doRename(src, dest, overwrite, isChangingCase, cb)
}) })
}) })
}) })
} }
function doRename (src, dest, overwrite, 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) { if (overwrite) {
return remove(dest, err => { return remove(dest, err => {
if (err) return cb(err) if (err) return cb(err)
@ -3768,12 +3679,25 @@ module.exports = {
"use strict"; "use strict";
const fs = __webpack_require__(7758)
const u = __webpack_require__(9046).fromCallback const u = __webpack_require__(9046).fromCallback
const rimraf = __webpack_require__(8761) const rimraf = __webpack_require__(8761)
function remove (path, callback) {
// Node 14.14.0+
if (fs.rm) return fs.rm(path, { recursive: true, force: true }, callback)
rimraf(path, callback)
}
function removeSync (path) {
// Node 14.14.0+
if (fs.rmSync) return fs.rmSync(path, { recursive: true, force: true })
rimraf.sync(path)
}
module.exports = { module.exports = {
remove: u(rimraf), remove: u(remove),
removeSync: rimraf.sync removeSync
} }
@ -4098,27 +4022,28 @@ rimraf.sync = rimrafSync
const fs = __webpack_require__(1176) const fs = __webpack_require__(1176)
const path = __webpack_require__(5622) const path = __webpack_require__(5622)
const util = __webpack_require__(1669) const util = __webpack_require__(1669)
const atLeastNode = __webpack_require__(5995)
const nodeSupportsBigInt = atLeastNode('10.5.0') function getStats (src, dest, opts) {
const stat = (file) => nodeSupportsBigInt ? fs.stat(file, { bigint: true }) : fs.stat(file) const statFunc = opts.dereference
const statSync = (file) => nodeSupportsBigInt ? fs.statSync(file, { bigint: true }) : fs.statSync(file) ? (file) => fs.stat(file, { bigint: true })
: (file) => fs.lstat(file, { bigint: true })
function getStats (src, dest) {
return Promise.all([ return Promise.all([
stat(src), statFunc(src),
stat(dest).catch(err => { statFunc(dest).catch(err => {
if (err.code === 'ENOENT') return null if (err.code === 'ENOENT') return null
throw err throw err
}) })
]).then(([srcStat, destStat]) => ({ srcStat, destStat })) ]).then(([srcStat, destStat]) => ({ srcStat, destStat }))
} }
function getStatsSync (src, dest) { function getStatsSync (src, dest, opts) {
let destStat let destStat
const srcStat = statSync(src) const statFunc = opts.dereference
? (file) => fs.statSync(file, { bigint: true })
: (file) => fs.lstatSync(file, { bigint: true })
const srcStat = statFunc(src)
try { try {
destStat = statSync(dest) destStat = statFunc(dest)
} catch (err) { } catch (err) {
if (err.code === 'ENOENT') return { srcStat, destStat: null } if (err.code === 'ENOENT') return { srcStat, destStat: null }
throw err throw err
@ -4126,13 +4051,30 @@ function getStatsSync (src, dest) {
return { srcStat, destStat } return { srcStat, destStat }
} }
function checkPaths (src, dest, funcName, cb) { function checkPaths (src, dest, funcName, opts, cb) {
util.callbackify(getStats)(src, dest, (err, stats) => { util.callbackify(getStats)(src, dest, opts, (err, stats) => {
if (err) return cb(err) if (err) return cb(err)
const { srcStat, destStat } = stats const { srcStat, destStat } = stats
if (destStat && areIdentical(srcStat, destStat)) {
return cb(new Error('Source and destination must not be the same.')) 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)) { if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
return cb(new Error(errMsg(src, dest, funcName))) return cb(new Error(errMsg(src, dest, funcName)))
} }
@ -4140,11 +4082,28 @@ function checkPaths (src, dest, funcName, cb) {
}) })
} }
function checkPathsSync (src, dest, funcName) { function checkPathsSync (src, dest, funcName, opts) {
const { srcStat, destStat } = getStatsSync(src, dest) const { srcStat, destStat } = getStatsSync(src, dest, opts)
if (destStat && areIdentical(srcStat, destStat)) {
throw new Error('Source and destination must not be the same.') 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)) { if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
throw new Error(errMsg(src, dest, funcName)) throw new Error(errMsg(src, dest, funcName))
} }
@ -4159,7 +4118,7 @@ function checkParentPaths (src, srcStat, dest, funcName, cb) {
const srcParent = path.resolve(path.dirname(src)) const srcParent = path.resolve(path.dirname(src))
const destParent = path.resolve(path.dirname(dest)) const destParent = path.resolve(path.dirname(dest))
if (destParent === srcParent || destParent === path.parse(destParent).root) return cb() if (destParent === srcParent || destParent === path.parse(destParent).root) return cb()
const callback = (err, destStat) => { fs.stat(destParent, { bigint: true }, (err, destStat) => {
if (err) { if (err) {
if (err.code === 'ENOENT') return cb() if (err.code === 'ENOENT') return cb()
return cb(err) return cb(err)
@ -4168,9 +4127,7 @@ function checkParentPaths (src, srcStat, dest, funcName, cb) {
return cb(new Error(errMsg(src, dest, funcName))) return cb(new Error(errMsg(src, dest, funcName)))
} }
return checkParentPaths(src, srcStat, destParent, funcName, cb) return checkParentPaths(src, srcStat, destParent, funcName, cb)
} })
if (nodeSupportsBigInt) fs.stat(destParent, { bigint: true }, callback)
else fs.stat(destParent, callback)
} }
function checkParentPathsSync (src, srcStat, dest, funcName) { function checkParentPathsSync (src, srcStat, dest, funcName) {
@ -4179,7 +4136,7 @@ function checkParentPathsSync (src, srcStat, dest, funcName) {
if (destParent === srcParent || destParent === path.parse(destParent).root) return if (destParent === srcParent || destParent === path.parse(destParent).root) return
let destStat let destStat
try { try {
destStat = statSync(destParent) destStat = fs.statSync(destParent, { bigint: true })
} catch (err) { } catch (err) {
if (err.code === 'ENOENT') return if (err.code === 'ENOENT') return
throw err throw err
@ -4191,26 +4148,7 @@ function checkParentPathsSync (src, srcStat, dest, funcName) {
} }
function areIdentical (srcStat, destStat) { function areIdentical (srcStat, destStat) {
if (destStat.ino && destStat.dev && destStat.ino === srcStat.ino && destStat.dev === srcStat.dev) { return destStat.ino && destStat.dev && destStat.ino === srcStat.ino && destStat.dev === srcStat.dev
if (nodeSupportsBigInt || destStat.ino < Number.MAX_SAFE_INTEGER) {
// definitive answer
return true
}
// Use additional heuristics if we can't use 'bigint'.
// Different 'ino' could be represented the same if they are >= Number.MAX_SAFE_INTEGER
// See issue 657
if (destStat.size === srcStat.size &&
destStat.mode === srcStat.mode &&
destStat.nlink === srcStat.nlink &&
destStat.atimeMs === srcStat.atimeMs &&
destStat.mtimeMs === srcStat.mtimeMs &&
destStat.ctimeMs === srcStat.ctimeMs &&
destStat.birthtimeMs === srcStat.birthtimeMs) {
// heuristic answer
return true
}
}
return false
} }
// return true if dest is a subdir of src, otherwise false. // return true if dest is a subdir of src, otherwise false.
@ -4230,7 +4168,8 @@ module.exports = {
checkPathsSync, checkPathsSync,
checkParentPaths, checkParentPaths,
checkParentPathsSync, checkParentPathsSync,
isSrcSubdir isSrcSubdir,
areIdentical
} }

View File

@ -24,7 +24,7 @@
"@actions/core": "^1.2.7", "@actions/core": "^1.2.7",
"@actions/exec": "^1.0.4", "@actions/exec": "^1.0.4",
"addressparser": "^1.0.1", "addressparser": "^1.0.1",
"fs-extra": "^9.0.1" "fs-extra": "^10.0.0"
}, },
"devDependencies": { "devDependencies": {
"@actions/io": "^1.0.2", "@actions/io": "^1.0.2",

View File

@ -41,11 +41,6 @@ addressparser@^1.0.1:
resolved "https://registry.yarnpkg.com/addressparser/-/addressparser-1.0.1.tgz#47afbe1a2a9262191db6838e4fd1d39b40821746" resolved "https://registry.yarnpkg.com/addressparser/-/addressparser-1.0.1.tgz#47afbe1a2a9262191db6838e4fd1d39b40821746"
integrity sha1-R6++GiqSYhkdtoOOT9HTm0CCF0Y= integrity sha1-R6++GiqSYhkdtoOOT9HTm0CCF0Y=
at-least-node@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/at-least-node/-/at-least-node-1.0.0.tgz#602cd4b46e844ad4effc92a8011a3c46e0238dc2"
integrity sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg==
commander@^2.19.0: commander@^2.19.0:
version "2.20.3" version "2.20.3"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
@ -66,12 +61,11 @@ editorconfig@^0.15.0:
semver "^5.6.0" semver "^5.6.0"
sigmund "^1.0.1" sigmund "^1.0.1"
fs-extra@^9.0.1: fs-extra@^10.0.0:
version "9.1.0" version "10.0.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.1.0.tgz#5954460c764a8da2094ba3554bf839e6b9a7c86d" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-10.0.0.tgz#9ff61b655dde53fb34a82df84bb214ce802e17c1"
integrity sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ== integrity sha512-C5owb14u9eJwizKGdchcDUQeFtlSHHthBk8pbX9Vc1PFZrLombudjDnNns88aYslCyF6IY5SUw3Roz6xShcEIQ==
dependencies: dependencies:
at-least-node "^1.0.0"
graceful-fs "^4.2.0" graceful-fs "^4.2.0"
jsonfile "^6.0.1" jsonfile "^6.0.1"
universalify "^2.0.0" universalify "^2.0.0"