@emulsify/cli 1.4.2 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/handlers/componentInstall.js +8 -4
- package/dist/handlers/init.js +1 -1
- package/dist/handlers/systemInstall.js +3 -2
- package/dist/index.js +1 -0
- package/dist/node_modules/.package-lock.json +19 -28
- package/dist/node_modules/@types/node/README.md +3 -3
- package/dist/node_modules/@types/node/async_hooks.d.ts +1 -1
- package/dist/node_modules/@types/node/buffer.d.ts +64 -0
- package/dist/node_modules/@types/node/crypto.d.ts +28 -4
- package/dist/node_modules/@types/node/globals.d.ts +141 -8
- package/dist/node_modules/@types/node/http.d.ts +3 -1
- package/dist/node_modules/@types/node/http2.d.ts +4 -3
- package/dist/node_modules/@types/node/index.d.ts +0 -1
- package/dist/node_modules/@types/node/inspector.d.ts +1 -1
- package/dist/node_modules/@types/node/net.d.ts +15 -3
- package/dist/node_modules/@types/node/package.json +3 -8
- package/dist/node_modules/@types/node/process.d.ts +1 -1
- package/dist/node_modules/@types/node/stream.d.ts +8 -8
- package/dist/node_modules/@types/node/timers.d.ts +3 -3
- package/dist/node_modules/@types/node/tls.d.ts +2 -1
- package/dist/node_modules/@types/node/url.d.ts +31 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/README.md +2 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/codegen/code.d.ts +1 -0
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/codegen/code.js +9 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/codegen/code.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/index.js +8 -9
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/index.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/jtd/parse.js +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/jtd/parse.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/jtd/serialize.js +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/jtd/serialize.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/ref_error.d.ts +2 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/ref_error.js +3 -3
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/ref_error.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/resolve.d.ts +5 -5
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/resolve.js +13 -11
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/resolve.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/validate/index.js +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/compile/validate/index.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/core.d.ts +4 -2
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/core.js +20 -17
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/core.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/runtime/uri.d.ts +6 -0
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/runtime/uri.js +6 -0
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/runtime/uri.js.map +1 -0
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/standalone/index.js +8 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/standalone/index.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/types/index.d.ts +6 -0
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/types/jtd-schema.d.ts +2 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/core/ref.js +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/core/ref.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/discriminator/index.js +10 -3
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/discriminator/index.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/jtd/ref.js +3 -2
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/jtd/ref.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/validation/enum.js +4 -3
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/validation/enum.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/dist/vocabularies/validation/limitProperties.js.map +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/compile/codegen/code.ts +8 -0
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/compile/index.ts +8 -8
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/compile/jtd/parse.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/compile/jtd/serialize.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/compile/ref_error.ts +4 -3
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/compile/resolve.ts +15 -12
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/compile/validate/index.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/core.ts +9 -2
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/runtime/uri.ts +6 -0
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/standalone/index.ts +9 -2
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/types/index.ts +7 -0
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/types/json-schema.ts +1 -4
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/types/jtd-schema.ts +4 -5
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/vocabularies/core/ref.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/vocabularies/discriminator/index.ts +11 -3
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/vocabularies/jtd/ref.ts +3 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/vocabularies/validation/enum.ts +5 -3
- package/dist/node_modules/ajv-formats/node_modules/ajv/lib/vocabularies/validation/limitProperties.ts +1 -1
- package/dist/node_modules/ajv-formats/node_modules/ajv/package.json +5 -3
- package/dist/node_modules/debug/README.md +3 -0
- package/dist/node_modules/debug/package.json +1 -1
- package/dist/node_modules/debug/src/common.js +1 -1
- package/dist/node_modules/fs-extra/README.md +3 -5
- package/dist/node_modules/fs-extra/lib/{copy-sync → copy}/copy-sync.js +11 -8
- package/dist/node_modules/fs-extra/lib/copy/copy.js +12 -9
- package/dist/node_modules/fs-extra/lib/copy/index.js +2 -1
- package/dist/node_modules/fs-extra/lib/empty/index.js +10 -19
- package/dist/node_modules/fs-extra/lib/ensure/index.js +15 -15
- package/dist/node_modules/fs-extra/lib/ensure/link.js +10 -7
- package/dist/node_modules/fs-extra/lib/ensure/symlink.js +34 -15
- package/dist/node_modules/fs-extra/lib/fs/index.js +8 -10
- package/dist/node_modules/fs-extra/lib/index.js +1 -12
- package/dist/node_modules/fs-extra/lib/json/output-json-sync.js +1 -1
- package/dist/node_modules/fs-extra/lib/json/output-json.js +1 -1
- package/dist/node_modules/fs-extra/lib/mkdirs/make-dir.js +16 -130
- package/dist/node_modules/fs-extra/lib/mkdirs/utils.js +21 -0
- package/dist/node_modules/fs-extra/lib/move/index.js +2 -1
- package/dist/node_modules/fs-extra/lib/{move-sync → move}/move-sync.js +12 -5
- package/dist/node_modules/fs-extra/lib/move/move.js +14 -4
- package/dist/node_modules/fs-extra/lib/{output → output-file}/index.js +0 -0
- package/dist/node_modules/fs-extra/lib/remove/index.js +15 -2
- package/dist/node_modules/fs-extra/lib/util/stat.js +60 -45
- package/dist/node_modules/fs-extra/package.json +7 -10
- package/dist/node_modules/graceful-fs/LICENSE +1 -1
- package/dist/node_modules/graceful-fs/graceful-fs.js +23 -4
- package/dist/node_modules/graceful-fs/package.json +1 -1
- package/dist/node_modules/graceful-fs/polyfills.js +39 -30
- package/dist/node_modules/ramda/dist/ramda.js +4 -4
- package/dist/node_modules/ramda/dist/ramda.min.js +1 -1
- package/dist/node_modules/ramda/es/trim.js +1 -1
- package/dist/node_modules/ramda/package.json +1 -1
- package/dist/node_modules/ramda/src/trim.js +1 -1
- package/dist/package.json +4 -4
- package/dist/schemas/variant.json +28 -5
- package/dist/util/cache/cloneIntoCache.js +1 -7
- package/dist/util/getAvailableStarters.js +1 -1
- package/dist/util/platform/getInitSuccessMessageForPlatform.js +4 -3
- package/dist/util/project/buildComponentDependencyList.js +20 -0
- package/package.json +5 -5
- package/dist/node_modules/at-least-node/LICENSE +0 -6
- package/dist/node_modules/at-least-node/README.md +0 -25
- package/dist/node_modules/at-least-node/index.js +0 -5
- package/dist/node_modules/at-least-node/package.json +0 -32
- package/dist/node_modules/fs-extra/CHANGELOG.md +0 -902
- package/dist/node_modules/fs-extra/lib/copy-sync/index.js +0 -5
- package/dist/node_modules/fs-extra/lib/move-sync/index.js +0 -5
|
@@ -23,11 +23,14 @@ function copy (src, dest, opts, cb) {
|
|
|
23
23
|
|
|
24
24
|
// Warn about using preserveTimestamps on 32-bit node
|
|
25
25
|
if (opts.preserveTimestamps && process.arch === 'ia32') {
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
process.emitWarning(
|
|
27
|
+
'Using the preserveTimestamps option in 32-bit node is not recommended;\n\n' +
|
|
28
|
+
'\tsee https://github.com/jprichardson/node-fs-extra/issues/269',
|
|
29
|
+
'Warning', 'fs-extra-WARN0001'
|
|
30
|
+
)
|
|
28
31
|
}
|
|
29
32
|
|
|
30
|
-
stat.checkPaths(src, dest, 'copy', (err, stats) => {
|
|
33
|
+
stat.checkPaths(src, dest, 'copy', opts, (err, stats) => {
|
|
31
34
|
if (err) return cb(err)
|
|
32
35
|
const { srcStat, destStat } = stats
|
|
33
36
|
stat.checkParentPaths(src, srcStat, dest, 'copy', err => {
|
|
@@ -42,10 +45,10 @@ function checkParentDir (destStat, src, dest, opts, cb) {
|
|
|
42
45
|
const destParent = path.dirname(dest)
|
|
43
46
|
pathExists(destParent, (err, dirExists) => {
|
|
44
47
|
if (err) return cb(err)
|
|
45
|
-
if (dirExists) return
|
|
48
|
+
if (dirExists) return getStats(destStat, src, dest, opts, cb)
|
|
46
49
|
mkdirs(destParent, err => {
|
|
47
50
|
if (err) return cb(err)
|
|
48
|
-
return
|
|
51
|
+
return getStats(destStat, src, dest, opts, cb)
|
|
49
52
|
})
|
|
50
53
|
})
|
|
51
54
|
}
|
|
@@ -72,6 +75,9 @@ function getStats (destStat, src, dest, opts, cb) {
|
|
|
72
75
|
srcStat.isCharacterDevice() ||
|
|
73
76
|
srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts, cb)
|
|
74
77
|
else if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts, cb)
|
|
78
|
+
else if (srcStat.isSocket()) return cb(new Error(`Cannot copy a socket file: ${src}`))
|
|
79
|
+
else if (srcStat.isFIFO()) return cb(new Error(`Cannot copy a FIFO pipe: ${src}`))
|
|
80
|
+
return cb(new Error(`Unknown file: ${src}`))
|
|
75
81
|
})
|
|
76
82
|
}
|
|
77
83
|
|
|
@@ -143,9 +149,6 @@ function setDestTimestamps (src, dest, cb) {
|
|
|
143
149
|
|
|
144
150
|
function onDir (srcStat, destStat, src, dest, opts, cb) {
|
|
145
151
|
if (!destStat) return mkDirAndCopy(srcStat.mode, src, dest, opts, cb)
|
|
146
|
-
if (destStat && !destStat.isDirectory()) {
|
|
147
|
-
return cb(new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`))
|
|
148
|
-
}
|
|
149
152
|
return copyDir(src, dest, opts, cb)
|
|
150
153
|
}
|
|
151
154
|
|
|
@@ -175,7 +178,7 @@ function copyDirItems (items, src, dest, opts, cb) {
|
|
|
175
178
|
function copyDirItem (items, item, src, dest, opts, cb) {
|
|
176
179
|
const srcItem = path.join(src, item)
|
|
177
180
|
const destItem = path.join(dest, item)
|
|
178
|
-
stat.checkPaths(srcItem, destItem, 'copy', (err, stats) => {
|
|
181
|
+
stat.checkPaths(srcItem, destItem, 'copy', opts, (err, stats) => {
|
|
179
182
|
if (err) return cb(err)
|
|
180
183
|
const { destStat } = stats
|
|
181
184
|
startCopy(destStat, srcItem, destItem, opts, err => {
|
|
@@ -1,29 +1,20 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const u = require('universalify').
|
|
4
|
-
const fs = require('
|
|
3
|
+
const u = require('universalify').fromPromise
|
|
4
|
+
const fs = require('../fs')
|
|
5
5
|
const path = require('path')
|
|
6
6
|
const mkdir = require('../mkdirs')
|
|
7
7
|
const remove = require('../remove')
|
|
8
8
|
|
|
9
|
-
const emptyDir = u(function emptyDir (dir
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
deleteItem()
|
|
9
|
+
const emptyDir = u(async function emptyDir (dir) {
|
|
10
|
+
let items
|
|
11
|
+
try {
|
|
12
|
+
items = await fs.readdir(dir)
|
|
13
|
+
} catch {
|
|
14
|
+
return mkdir.mkdirs(dir)
|
|
15
|
+
}
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
const item = items.pop()
|
|
20
|
-
if (!item) return callback()
|
|
21
|
-
remove.remove(item, err => {
|
|
22
|
-
if (err) return callback(err)
|
|
23
|
-
deleteItem()
|
|
24
|
-
})
|
|
25
|
-
}
|
|
26
|
-
})
|
|
17
|
+
return Promise.all(items.map(item => remove.remove(path.join(dir, item))))
|
|
27
18
|
})
|
|
28
19
|
|
|
29
20
|
function emptyDirSync (dir) {
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
const
|
|
3
|
+
const { createFile, createFileSync } = require('./file')
|
|
4
|
+
const { createLink, createLinkSync } = require('./link')
|
|
5
|
+
const { createSymlink, createSymlinkSync } = require('./symlink')
|
|
6
6
|
|
|
7
7
|
module.exports = {
|
|
8
8
|
// file
|
|
9
|
-
createFile
|
|
10
|
-
createFileSync
|
|
11
|
-
ensureFile:
|
|
12
|
-
ensureFileSync:
|
|
9
|
+
createFile,
|
|
10
|
+
createFileSync,
|
|
11
|
+
ensureFile: createFile,
|
|
12
|
+
ensureFileSync: createFileSync,
|
|
13
13
|
// link
|
|
14
|
-
createLink
|
|
15
|
-
createLinkSync
|
|
16
|
-
ensureLink:
|
|
17
|
-
ensureLinkSync:
|
|
14
|
+
createLink,
|
|
15
|
+
createLinkSync,
|
|
16
|
+
ensureLink: createLink,
|
|
17
|
+
ensureLinkSync: createLinkSync,
|
|
18
18
|
// symlink
|
|
19
|
-
createSymlink
|
|
20
|
-
createSymlinkSync
|
|
21
|
-
ensureSymlink:
|
|
22
|
-
ensureSymlinkSync:
|
|
19
|
+
createSymlink,
|
|
20
|
+
createSymlinkSync,
|
|
21
|
+
ensureSymlink: createSymlink,
|
|
22
|
+
ensureSymlinkSync: createSymlinkSync
|
|
23
23
|
}
|
|
@@ -5,6 +5,7 @@ const path = require('path')
|
|
|
5
5
|
const fs = require('graceful-fs')
|
|
6
6
|
const mkdir = require('../mkdirs')
|
|
7
7
|
const pathExists = require('../path-exists').pathExists
|
|
8
|
+
const { areIdentical } = require('../util/stat')
|
|
8
9
|
|
|
9
10
|
function createLink (srcpath, dstpath, callback) {
|
|
10
11
|
function makeLink (srcpath, dstpath) {
|
|
@@ -14,14 +15,13 @@ function createLink (srcpath, dstpath, callback) {
|
|
|
14
15
|
})
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (destinationExists) return callback(null)
|
|
20
|
-
fs.lstat(srcpath, (err) => {
|
|
18
|
+
fs.lstat(dstpath, (_, dstStat) => {
|
|
19
|
+
fs.lstat(srcpath, (err, srcStat) => {
|
|
21
20
|
if (err) {
|
|
22
21
|
err.message = err.message.replace('lstat', 'ensureLink')
|
|
23
22
|
return callback(err)
|
|
24
23
|
}
|
|
24
|
+
if (dstStat && areIdentical(srcStat, dstStat)) return callback(null)
|
|
25
25
|
|
|
26
26
|
const dir = path.dirname(dstpath)
|
|
27
27
|
pathExists(dir, (err, dirExists) => {
|
|
@@ -37,11 +37,14 @@ function createLink (srcpath, dstpath, callback) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
function createLinkSync (srcpath, dstpath) {
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
let dstStat
|
|
41
|
+
try {
|
|
42
|
+
dstStat = fs.lstatSync(dstpath)
|
|
43
|
+
} catch {}
|
|
42
44
|
|
|
43
45
|
try {
|
|
44
|
-
fs.lstatSync(srcpath)
|
|
46
|
+
const srcStat = fs.lstatSync(srcpath)
|
|
47
|
+
if (dstStat && areIdentical(srcStat, dstStat)) return
|
|
45
48
|
} catch (err) {
|
|
46
49
|
err.message = err.message.replace('lstat', 'ensureLink')
|
|
47
50
|
throw err
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const u = require('universalify').fromCallback
|
|
4
4
|
const path = require('path')
|
|
5
|
-
const fs = require('
|
|
5
|
+
const fs = require('../fs')
|
|
6
6
|
const _mkdirs = require('../mkdirs')
|
|
7
7
|
const mkdirs = _mkdirs.mkdirs
|
|
8
8
|
const mkdirsSync = _mkdirs.mkdirsSync
|
|
@@ -17,26 +17,38 @@ const symlinkTypeSync = _symlinkType.symlinkTypeSync
|
|
|
17
17
|
|
|
18
18
|
const pathExists = require('../path-exists').pathExists
|
|
19
19
|
|
|
20
|
+
const { areIdentical } = require('../util/stat')
|
|
21
|
+
|
|
20
22
|
function createSymlink (srcpath, dstpath, type, callback) {
|
|
21
23
|
callback = (typeof type === 'function') ? type : callback
|
|
22
24
|
type = (typeof type === 'function') ? false : type
|
|
23
25
|
|
|
24
|
-
|
|
26
|
+
fs.lstat(dstpath, (err, stats) => {
|
|
27
|
+
if (!err && stats.isSymbolicLink()) {
|
|
28
|
+
Promise.all([
|
|
29
|
+
fs.stat(srcpath),
|
|
30
|
+
fs.stat(dstpath)
|
|
31
|
+
]).then(([srcStat, dstStat]) => {
|
|
32
|
+
if (areIdentical(srcStat, dstStat)) return callback(null)
|
|
33
|
+
_createSymlink(srcpath, dstpath, type, callback)
|
|
34
|
+
})
|
|
35
|
+
} else _createSymlink(srcpath, dstpath, type, callback)
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function _createSymlink (srcpath, dstpath, type, callback) {
|
|
40
|
+
symlinkPaths(srcpath, dstpath, (err, relative) => {
|
|
25
41
|
if (err) return callback(err)
|
|
26
|
-
|
|
27
|
-
|
|
42
|
+
srcpath = relative.toDst
|
|
43
|
+
symlinkType(relative.toCwd, type, (err, type) => {
|
|
28
44
|
if (err) return callback(err)
|
|
29
|
-
|
|
30
|
-
|
|
45
|
+
const dir = path.dirname(dstpath)
|
|
46
|
+
pathExists(dir, (err, dirExists) => {
|
|
31
47
|
if (err) return callback(err)
|
|
32
|
-
|
|
33
|
-
|
|
48
|
+
if (dirExists) return fs.symlink(srcpath, dstpath, type, callback)
|
|
49
|
+
mkdirs(dir, err => {
|
|
34
50
|
if (err) return callback(err)
|
|
35
|
-
|
|
36
|
-
mkdirs(dir, err => {
|
|
37
|
-
if (err) return callback(err)
|
|
38
|
-
fs.symlink(srcpath, dstpath, type, callback)
|
|
39
|
-
})
|
|
51
|
+
fs.symlink(srcpath, dstpath, type, callback)
|
|
40
52
|
})
|
|
41
53
|
})
|
|
42
54
|
})
|
|
@@ -44,8 +56,15 @@ function createSymlink (srcpath, dstpath, type, callback) {
|
|
|
44
56
|
}
|
|
45
57
|
|
|
46
58
|
function createSymlinkSync (srcpath, dstpath, type) {
|
|
47
|
-
|
|
48
|
-
|
|
59
|
+
let stats
|
|
60
|
+
try {
|
|
61
|
+
stats = fs.lstatSync(dstpath)
|
|
62
|
+
} catch {}
|
|
63
|
+
if (stats && stats.isSymbolicLink()) {
|
|
64
|
+
const srcStat = fs.statSync(srcpath)
|
|
65
|
+
const dstStat = fs.statSync(dstpath)
|
|
66
|
+
if (areIdentical(srcStat, dstStat)) return
|
|
67
|
+
}
|
|
49
68
|
|
|
50
69
|
const relative = symlinkPathsSync(srcpath, dstpath)
|
|
51
70
|
srcpath = relative.toDst
|
|
@@ -47,15 +47,8 @@ const api = [
|
|
|
47
47
|
return typeof fs[key] === 'function'
|
|
48
48
|
})
|
|
49
49
|
|
|
50
|
-
// Export
|
|
51
|
-
Object.
|
|
52
|
-
if (key === 'promises') {
|
|
53
|
-
// fs.promises is a getter property that triggers ExperimentalWarning
|
|
54
|
-
// Don't re-export it here, the getter is defined in "lib/index.js"
|
|
55
|
-
return
|
|
56
|
-
}
|
|
57
|
-
exports[key] = fs[key]
|
|
58
|
-
})
|
|
50
|
+
// Export cloned fs:
|
|
51
|
+
Object.assign(exports, fs)
|
|
59
52
|
|
|
60
53
|
// Universalify async methods:
|
|
61
54
|
api.forEach(method => {
|
|
@@ -124,7 +117,12 @@ if (typeof fs.writev === 'function') {
|
|
|
124
117
|
}
|
|
125
118
|
}
|
|
126
119
|
|
|
127
|
-
// fs.realpath.native
|
|
120
|
+
// fs.realpath.native sometimes not available if fs is monkey-patched
|
|
128
121
|
if (typeof fs.realpath.native === 'function') {
|
|
129
122
|
exports.realpath.native = u(fs.realpath.native)
|
|
123
|
+
} else {
|
|
124
|
+
process.emitWarning(
|
|
125
|
+
'fs.realpath.native is not a function. Is fs being monkey-patched?',
|
|
126
|
+
'Warning', 'fs-extra-WARN0003'
|
|
127
|
+
)
|
|
130
128
|
}
|
|
@@ -4,24 +4,13 @@ module.exports = {
|
|
|
4
4
|
// Export promiseified graceful-fs:
|
|
5
5
|
...require('./fs'),
|
|
6
6
|
// Export extra methods:
|
|
7
|
-
...require('./copy-sync'),
|
|
8
7
|
...require('./copy'),
|
|
9
8
|
...require('./empty'),
|
|
10
9
|
...require('./ensure'),
|
|
11
10
|
...require('./json'),
|
|
12
11
|
...require('./mkdirs'),
|
|
13
|
-
...require('./move-sync'),
|
|
14
12
|
...require('./move'),
|
|
15
|
-
...require('./output'),
|
|
13
|
+
...require('./output-file'),
|
|
16
14
|
...require('./path-exists'),
|
|
17
15
|
...require('./remove')
|
|
18
16
|
}
|
|
19
|
-
|
|
20
|
-
// Export fs.promises as a getter property so that we don't trigger
|
|
21
|
-
// ExperimentalWarning before fs.promises is actually accessed.
|
|
22
|
-
const fs = require('fs')
|
|
23
|
-
if (Object.getOwnPropertyDescriptor(fs, 'promises')) {
|
|
24
|
-
Object.defineProperty(module.exports, 'promises', {
|
|
25
|
-
get () { return fs.promises }
|
|
26
|
-
})
|
|
27
|
-
}
|
|
@@ -1,141 +1,27 @@
|
|
|
1
|
-
// Adapted from https://github.com/sindresorhus/make-dir
|
|
2
|
-
// Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
|
3
|
-
// 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:
|
|
4
|
-
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
5
|
-
// 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.
|
|
6
1
|
'use strict'
|
|
7
2
|
const fs = require('../fs')
|
|
8
|
-
const
|
|
9
|
-
const atLeastNode = require('at-least-node')
|
|
3
|
+
const { checkPath } = require('./utils')
|
|
10
4
|
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
// https://github.com/nodejs/node/issues/8987
|
|
14
|
-
// https://github.com/libuv/libuv/pull/1088
|
|
15
|
-
const checkPath = pth => {
|
|
16
|
-
if (process.platform === 'win32') {
|
|
17
|
-
const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path.parse(pth).root, ''))
|
|
18
|
-
|
|
19
|
-
if (pathHasInvalidWinCharacters) {
|
|
20
|
-
const error = new Error(`Path contains invalid characters: ${pth}`)
|
|
21
|
-
error.code = 'EINVAL'
|
|
22
|
-
throw error
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const processOptions = options => {
|
|
5
|
+
const getMode = options => {
|
|
28
6
|
const defaults = { mode: 0o777 }
|
|
29
|
-
if (typeof options === 'number')
|
|
30
|
-
return { ...defaults, ...options }
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const permissionError = pth => {
|
|
34
|
-
// This replicates the exception of `fs.mkdir` with native the
|
|
35
|
-
// `recusive` option when run on an invalid drive under Windows.
|
|
36
|
-
const error = new Error(`operation not permitted, mkdir '${pth}'`)
|
|
37
|
-
error.code = 'EPERM'
|
|
38
|
-
error.errno = -4048
|
|
39
|
-
error.path = pth
|
|
40
|
-
error.syscall = 'mkdir'
|
|
41
|
-
return error
|
|
7
|
+
if (typeof options === 'number') return options
|
|
8
|
+
return ({ ...defaults, ...options }).mode
|
|
42
9
|
}
|
|
43
10
|
|
|
44
|
-
module.exports.makeDir = async (
|
|
45
|
-
checkPath(
|
|
46
|
-
options = processOptions(options)
|
|
47
|
-
|
|
48
|
-
if (useNativeRecursiveOption) {
|
|
49
|
-
const pth = path.resolve(input)
|
|
50
|
-
|
|
51
|
-
return fs.mkdir(pth, {
|
|
52
|
-
mode: options.mode,
|
|
53
|
-
recursive: true
|
|
54
|
-
})
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const make = async pth => {
|
|
58
|
-
try {
|
|
59
|
-
await fs.mkdir(pth, options.mode)
|
|
60
|
-
} catch (error) {
|
|
61
|
-
if (error.code === 'EPERM') {
|
|
62
|
-
throw error
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (error.code === 'ENOENT') {
|
|
66
|
-
if (path.dirname(pth) === pth) {
|
|
67
|
-
throw permissionError(pth)
|
|
68
|
-
}
|
|
11
|
+
module.exports.makeDir = async (dir, options) => {
|
|
12
|
+
checkPath(dir)
|
|
69
13
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
await make(path.dirname(pth))
|
|
75
|
-
return make(pth)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
try {
|
|
79
|
-
const stats = await fs.stat(pth)
|
|
80
|
-
if (!stats.isDirectory()) {
|
|
81
|
-
// This error is never exposed to the user
|
|
82
|
-
// it is caught below, and the original error is thrown
|
|
83
|
-
throw new Error('The path is not a directory')
|
|
84
|
-
}
|
|
85
|
-
} catch {
|
|
86
|
-
throw error
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return make(path.resolve(input))
|
|
14
|
+
return fs.mkdir(dir, {
|
|
15
|
+
mode: getMode(options),
|
|
16
|
+
recursive: true
|
|
17
|
+
})
|
|
92
18
|
}
|
|
93
19
|
|
|
94
|
-
module.exports.makeDirSync = (
|
|
95
|
-
checkPath(
|
|
96
|
-
options = processOptions(options)
|
|
97
|
-
|
|
98
|
-
if (useNativeRecursiveOption) {
|
|
99
|
-
const pth = path.resolve(input)
|
|
100
|
-
|
|
101
|
-
return fs.mkdirSync(pth, {
|
|
102
|
-
mode: options.mode,
|
|
103
|
-
recursive: true
|
|
104
|
-
})
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const make = pth => {
|
|
108
|
-
try {
|
|
109
|
-
fs.mkdirSync(pth, options.mode)
|
|
110
|
-
} catch (error) {
|
|
111
|
-
if (error.code === 'EPERM') {
|
|
112
|
-
throw error
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if (error.code === 'ENOENT') {
|
|
116
|
-
if (path.dirname(pth) === pth) {
|
|
117
|
-
throw permissionError(pth)
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
if (error.message.includes('null bytes')) {
|
|
121
|
-
throw error
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
make(path.dirname(pth))
|
|
125
|
-
return make(pth)
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
try {
|
|
129
|
-
if (!fs.statSync(pth).isDirectory()) {
|
|
130
|
-
// This error is never exposed to the user
|
|
131
|
-
// it is caught below, and the original error is thrown
|
|
132
|
-
throw new Error('The path is not a directory')
|
|
133
|
-
}
|
|
134
|
-
} catch {
|
|
135
|
-
throw error
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
20
|
+
module.exports.makeDirSync = (dir, options) => {
|
|
21
|
+
checkPath(dir)
|
|
139
22
|
|
|
140
|
-
return
|
|
23
|
+
return fs.mkdirSync(dir, {
|
|
24
|
+
mode: getMode(options),
|
|
25
|
+
recursive: true
|
|
26
|
+
})
|
|
141
27
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Adapted from https://github.com/sindresorhus/make-dir
|
|
2
|
+
// Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
|
3
|
+
// 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:
|
|
4
|
+
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
5
|
+
// 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.
|
|
6
|
+
'use strict'
|
|
7
|
+
const path = require('path')
|
|
8
|
+
|
|
9
|
+
// https://github.com/nodejs/node/issues/8987
|
|
10
|
+
// https://github.com/libuv/libuv/pull/1088
|
|
11
|
+
module.exports.checkPath = function checkPath (pth) {
|
|
12
|
+
if (process.platform === 'win32') {
|
|
13
|
+
const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path.parse(pth).root, ''))
|
|
14
|
+
|
|
15
|
+
if (pathHasInvalidWinCharacters) {
|
|
16
|
+
const error = new Error(`Path contains invalid characters: ${pth}`)
|
|
17
|
+
error.code = 'EINVAL'
|
|
18
|
+
throw error
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const fs = require('graceful-fs')
|
|
4
4
|
const path = require('path')
|
|
5
|
-
const copySync = require('../copy
|
|
5
|
+
const copySync = require('../copy').copySync
|
|
6
6
|
const removeSync = require('../remove').removeSync
|
|
7
7
|
const mkdirpSync = require('../mkdirs').mkdirpSync
|
|
8
8
|
const stat = require('../util/stat')
|
|
@@ -11,13 +11,20 @@ function moveSync (src, dest, opts) {
|
|
|
11
11
|
opts = opts || {}
|
|
12
12
|
const overwrite = opts.overwrite || opts.clobber || false
|
|
13
13
|
|
|
14
|
-
const { srcStat } = stat.checkPathsSync(src, dest, 'move')
|
|
14
|
+
const { srcStat, isChangingCase = false } = stat.checkPathsSync(src, dest, 'move', opts)
|
|
15
15
|
stat.checkParentPathsSync(src, srcStat, dest, 'move')
|
|
16
|
-
mkdirpSync(path.dirname(dest))
|
|
17
|
-
return doRename(src, dest, overwrite)
|
|
16
|
+
if (!isParentRoot(dest)) mkdirpSync(path.dirname(dest))
|
|
17
|
+
return doRename(src, dest, overwrite, isChangingCase)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
function
|
|
20
|
+
function isParentRoot (dest) {
|
|
21
|
+
const parent = path.dirname(dest)
|
|
22
|
+
const parsedPath = path.parse(parent)
|
|
23
|
+
return parsedPath.root === parent
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function doRename (src, dest, overwrite, isChangingCase) {
|
|
27
|
+
if (isChangingCase) return rename(src, dest, overwrite)
|
|
21
28
|
if (overwrite) {
|
|
22
29
|
removeSync(dest)
|
|
23
30
|
return rename(src, dest, overwrite)
|
|
@@ -14,22 +14,32 @@ function move (src, dest, opts, cb) {
|
|
|
14
14
|
opts = {}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
opts = opts || {}
|
|
18
|
+
|
|
17
19
|
const overwrite = opts.overwrite || opts.clobber || false
|
|
18
20
|
|
|
19
|
-
stat.checkPaths(src, dest, 'move', (err, stats) => {
|
|
21
|
+
stat.checkPaths(src, dest, 'move', opts, (err, stats) => {
|
|
20
22
|
if (err) return cb(err)
|
|
21
|
-
const { srcStat } = stats
|
|
23
|
+
const { srcStat, isChangingCase = false } = stats
|
|
22
24
|
stat.checkParentPaths(src, srcStat, dest, 'move', err => {
|
|
23
25
|
if (err) return cb(err)
|
|
26
|
+
if (isParentRoot(dest)) return doRename(src, dest, overwrite, isChangingCase, cb)
|
|
24
27
|
mkdirp(path.dirname(dest), err => {
|
|
25
28
|
if (err) return cb(err)
|
|
26
|
-
return doRename(src, dest, overwrite, cb)
|
|
29
|
+
return doRename(src, dest, overwrite, isChangingCase, cb)
|
|
27
30
|
})
|
|
28
31
|
})
|
|
29
32
|
})
|
|
30
33
|
}
|
|
31
34
|
|
|
32
|
-
function
|
|
35
|
+
function isParentRoot (dest) {
|
|
36
|
+
const parent = path.dirname(dest)
|
|
37
|
+
const parsedPath = path.parse(parent)
|
|
38
|
+
return parsedPath.root === parent
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function doRename (src, dest, overwrite, isChangingCase, cb) {
|
|
42
|
+
if (isChangingCase) return rename(src, dest, overwrite, cb)
|
|
33
43
|
if (overwrite) {
|
|
34
44
|
return remove(dest, err => {
|
|
35
45
|
if (err) return cb(err)
|
|
File without changes
|
|
@@ -1,9 +1,22 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const fs = require('graceful-fs')
|
|
3
4
|
const u = require('universalify').fromCallback
|
|
4
5
|
const rimraf = require('./rimraf')
|
|
5
6
|
|
|
7
|
+
function remove (path, callback) {
|
|
8
|
+
// Node 14.14.0+
|
|
9
|
+
if (fs.rm) return fs.rm(path, { recursive: true, force: true }, callback)
|
|
10
|
+
rimraf(path, callback)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function removeSync (path) {
|
|
14
|
+
// Node 14.14.0+
|
|
15
|
+
if (fs.rmSync) return fs.rmSync(path, { recursive: true, force: true })
|
|
16
|
+
rimraf.sync(path)
|
|
17
|
+
}
|
|
18
|
+
|
|
6
19
|
module.exports = {
|
|
7
|
-
remove: u(
|
|
8
|
-
removeSync
|
|
20
|
+
remove: u(remove),
|
|
21
|
+
removeSync
|
|
9
22
|
}
|