vaderjs 1.3.3 → 1.3.4
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/create-vader-app/example_proj/dist/vaderjs/index.js +5 -0
- package/create-vader-app/example_proj/dist/vaderjs/vader-min.js +1115 -0
- package/create-vader-app/example_proj/dist/vaderjs/vaderRouter-min.js +1 -0
- package/create-vader-app/example_proj/dist/vaderjs/worker.js +327 -0
- package/create-vader-app/example_proj/index.html +20 -0
- package/create-vader-app/example_proj/readme.md +2 -0
- package/create-vader-app/example_proj/src/pages/Index.js +13 -0
- package/create-vader-app/example_proj/src/views/app.html +16 -0
- package/create-vader-app/index.js +20 -0
- package/create-vader-app/node_modules/.package-lock.json +350 -0
- package/create-vader-app/node_modules/chalk/license +9 -0
- package/create-vader-app/node_modules/chalk/package.json +83 -0
- package/create-vader-app/node_modules/chalk/readme.md +325 -0
- package/create-vader-app/node_modules/chalk/source/index.d.ts +320 -0
- package/create-vader-app/node_modules/chalk/source/index.js +225 -0
- package/create-vader-app/node_modules/chalk/source/utilities.js +33 -0
- package/create-vader-app/node_modules/chalk/source/vendor/ansi-styles/index.d.ts +236 -0
- package/create-vader-app/node_modules/chalk/source/vendor/ansi-styles/index.js +223 -0
- package/create-vader-app/node_modules/chalk/source/vendor/supports-color/browser.d.ts +1 -0
- package/create-vader-app/node_modules/chalk/source/vendor/supports-color/browser.js +30 -0
- package/create-vader-app/node_modules/chalk/source/vendor/supports-color/index.d.ts +55 -0
- package/create-vader-app/node_modules/chalk/source/vendor/supports-color/index.js +182 -0
- package/create-vader-app/node_modules/commander/LICENSE +22 -0
- package/create-vader-app/node_modules/commander/Readme.md +1146 -0
- package/create-vader-app/node_modules/commander/esm.mjs +16 -0
- package/create-vader-app/node_modules/commander/index.js +27 -0
- package/create-vader-app/node_modules/commander/lib/argument.js +147 -0
- package/create-vader-app/node_modules/commander/lib/command.js +2196 -0
- package/create-vader-app/node_modules/commander/lib/error.js +45 -0
- package/create-vader-app/node_modules/commander/lib/help.js +464 -0
- package/create-vader-app/node_modules/commander/lib/option.js +331 -0
- package/create-vader-app/node_modules/commander/lib/suggestSimilar.js +100 -0
- package/create-vader-app/node_modules/commander/package-support.json +16 -0
- package/create-vader-app/node_modules/commander/package.json +90 -0
- package/create-vader-app/node_modules/commander/typings/esm.d.mts +3 -0
- package/create-vader-app/node_modules/commander/typings/index.d.ts +889 -0
- package/create-vader-app/node_modules/fs-extra/LICENSE +15 -0
- package/create-vader-app/node_modules/fs-extra/README.md +292 -0
- package/create-vader-app/node_modules/fs-extra/lib/copy/copy-sync.js +161 -0
- package/create-vader-app/node_modules/fs-extra/lib/copy/copy.js +238 -0
- package/create-vader-app/node_modules/fs-extra/lib/copy/index.js +7 -0
- package/create-vader-app/node_modules/fs-extra/lib/empty/index.js +39 -0
- package/create-vader-app/node_modules/fs-extra/lib/ensure/file.js +69 -0
- package/create-vader-app/node_modules/fs-extra/lib/ensure/index.js +23 -0
- package/create-vader-app/node_modules/fs-extra/lib/ensure/link.js +64 -0
- package/create-vader-app/node_modules/fs-extra/lib/ensure/symlink-paths.js +99 -0
- package/create-vader-app/node_modules/fs-extra/lib/ensure/symlink-type.js +31 -0
- package/create-vader-app/node_modules/fs-extra/lib/ensure/symlink.js +82 -0
- package/create-vader-app/node_modules/fs-extra/lib/esm.mjs +68 -0
- package/create-vader-app/node_modules/fs-extra/lib/fs/index.js +140 -0
- package/create-vader-app/node_modules/fs-extra/lib/index.js +16 -0
- package/create-vader-app/node_modules/fs-extra/lib/json/index.js +16 -0
- package/create-vader-app/node_modules/fs-extra/lib/json/jsonfile.js +11 -0
- package/create-vader-app/node_modules/fs-extra/lib/json/output-json-sync.js +12 -0
- package/create-vader-app/node_modules/fs-extra/lib/json/output-json.js +12 -0
- package/create-vader-app/node_modules/fs-extra/lib/mkdirs/index.js +14 -0
- package/create-vader-app/node_modules/fs-extra/lib/mkdirs/make-dir.js +27 -0
- package/create-vader-app/node_modules/fs-extra/lib/mkdirs/utils.js +21 -0
- package/create-vader-app/node_modules/fs-extra/lib/move/index.js +7 -0
- package/create-vader-app/node_modules/fs-extra/lib/move/move-sync.js +55 -0
- package/create-vader-app/node_modules/fs-extra/lib/move/move.js +76 -0
- package/create-vader-app/node_modules/fs-extra/lib/output-file/index.js +40 -0
- package/create-vader-app/node_modules/fs-extra/lib/path-exists/index.js +12 -0
- package/create-vader-app/node_modules/fs-extra/lib/remove/index.js +17 -0
- package/create-vader-app/node_modules/fs-extra/lib/util/stat.js +154 -0
- package/create-vader-app/node_modules/fs-extra/lib/util/utimes.js +26 -0
- package/create-vader-app/node_modules/fs-extra/package.json +71 -0
- package/create-vader-app/node_modules/graceful-fs/LICENSE +15 -0
- package/create-vader-app/node_modules/graceful-fs/README.md +143 -0
- package/create-vader-app/node_modules/graceful-fs/clone.js +23 -0
- package/create-vader-app/node_modules/graceful-fs/graceful-fs.js +448 -0
- package/create-vader-app/node_modules/graceful-fs/legacy-streams.js +118 -0
- package/create-vader-app/node_modules/graceful-fs/package.json +53 -0
- package/create-vader-app/node_modules/graceful-fs/polyfills.js +355 -0
- package/create-vader-app/node_modules/inherits/LICENSE +16 -0
- package/create-vader-app/node_modules/inherits/README.md +42 -0
- package/create-vader-app/node_modules/inherits/inherits.js +7 -0
- package/create-vader-app/node_modules/inherits/inherits_browser.js +23 -0
- package/create-vader-app/node_modules/inherits/package.json +29 -0
- package/create-vader-app/node_modules/jsonfile/CHANGELOG.md +171 -0
- package/create-vader-app/node_modules/jsonfile/LICENSE +15 -0
- package/create-vader-app/node_modules/jsonfile/README.md +230 -0
- package/create-vader-app/node_modules/jsonfile/index.js +88 -0
- package/create-vader-app/node_modules/jsonfile/package.json +40 -0
- package/create-vader-app/node_modules/jsonfile/utils.js +14 -0
- package/create-vader-app/node_modules/path/LICENSE +18 -0
- package/create-vader-app/node_modules/path/README.md +15 -0
- package/create-vader-app/node_modules/path/package.json +24 -0
- package/create-vader-app/node_modules/path/path.js +628 -0
- package/create-vader-app/node_modules/process/.eslintrc +21 -0
- package/create-vader-app/node_modules/process/LICENSE +22 -0
- package/create-vader-app/node_modules/process/README.md +26 -0
- package/create-vader-app/node_modules/process/browser.js +184 -0
- package/create-vader-app/node_modules/process/index.js +2 -0
- package/create-vader-app/node_modules/process/package.json +27 -0
- package/create-vader-app/node_modules/process/test.js +199 -0
- package/create-vader-app/node_modules/universalify/LICENSE +20 -0
- package/create-vader-app/node_modules/universalify/README.md +76 -0
- package/create-vader-app/node_modules/universalify/index.js +24 -0
- package/create-vader-app/node_modules/universalify/package.json +34 -0
- package/create-vader-app/node_modules/util/LICENSE +18 -0
- package/create-vader-app/node_modules/util/README.md +15 -0
- package/create-vader-app/node_modules/util/package.json +35 -0
- package/create-vader-app/node_modules/util/support/isBuffer.js +3 -0
- package/create-vader-app/node_modules/util/support/isBufferBrowser.js +6 -0
- package/create-vader-app/node_modules/util/util.js +586 -0
- package/create-vader-app/package-lock.json +384 -0
- package/create-vader-app/package.json +18 -0
- package/package.json +1 -1
- package/vader-min.js +1 -1
- package/vader.js +4 -4
- package/worker-min.js +1 -1
- package/worker.js +49 -24
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import _copy from './copy/index.js'
|
|
2
|
+
import _empty from './empty/index.js'
|
|
3
|
+
import _ensure from './ensure/index.js'
|
|
4
|
+
import _json from './json/index.js'
|
|
5
|
+
import _mkdirs from './mkdirs/index.js'
|
|
6
|
+
import _move from './move/index.js'
|
|
7
|
+
import _outputFile from './output-file/index.js'
|
|
8
|
+
import _pathExists from './path-exists/index.js'
|
|
9
|
+
import _remove from './remove/index.js'
|
|
10
|
+
|
|
11
|
+
// NOTE: Only exports fs-extra's functions; fs functions must be imported from "node:fs" or "node:fs/promises"
|
|
12
|
+
|
|
13
|
+
export const copy = _copy.copy
|
|
14
|
+
export const copySync = _copy.copySync
|
|
15
|
+
export const emptyDirSync = _empty.emptyDirSync
|
|
16
|
+
export const emptydirSync = _empty.emptydirSync
|
|
17
|
+
export const emptyDir = _empty.emptyDir
|
|
18
|
+
export const emptydir = _empty.emptydir
|
|
19
|
+
export const createFile = _ensure.createFile
|
|
20
|
+
export const createFileSync = _ensure.createFileSync
|
|
21
|
+
export const ensureFile = _ensure.ensureFile
|
|
22
|
+
export const ensureFileSync = _ensure.ensureFileSync
|
|
23
|
+
export const createLink = _ensure.createLink
|
|
24
|
+
export const createLinkSync = _ensure.createLinkSync
|
|
25
|
+
export const ensureLink = _ensure.ensureLink
|
|
26
|
+
export const ensureLinkSync = _ensure.ensureLinkSync
|
|
27
|
+
export const createSymlink = _ensure.createSymlink
|
|
28
|
+
export const createSymlinkSync = _ensure.createSymlinkSync
|
|
29
|
+
export const ensureSymlink = _ensure.ensureSymlink
|
|
30
|
+
export const ensureSymlinkSync = _ensure.ensureSymlinkSync
|
|
31
|
+
export const readJson = _json.readJson
|
|
32
|
+
export const readJSON = _json.readJSON
|
|
33
|
+
export const readJsonSync = _json.readJsonSync
|
|
34
|
+
export const readJSONSync = _json.readJSONSync
|
|
35
|
+
export const writeJson = _json.writeJson
|
|
36
|
+
export const writeJSON = _json.writeJSON
|
|
37
|
+
export const writeJsonSync = _json.writeJsonSync
|
|
38
|
+
export const writeJSONSync = _json.writeJSONSync
|
|
39
|
+
export const outputJson = _json.outputJson
|
|
40
|
+
export const outputJSON = _json.outputJSON
|
|
41
|
+
export const outputJsonSync = _json.outputJsonSync
|
|
42
|
+
export const outputJSONSync = _json.outputJSONSync
|
|
43
|
+
export const mkdirs = _mkdirs.mkdirs
|
|
44
|
+
export const mkdirsSync = _mkdirs.mkdirsSync
|
|
45
|
+
export const mkdirp = _mkdirs.mkdirp
|
|
46
|
+
export const mkdirpSync = _mkdirs.mkdirpSync
|
|
47
|
+
export const ensureDir = _mkdirs.ensureDir
|
|
48
|
+
export const ensureDirSync = _mkdirs.ensureDirSync
|
|
49
|
+
export const move = _move.move
|
|
50
|
+
export const moveSync = _move.moveSync
|
|
51
|
+
export const outputFile = _outputFile.outputFile
|
|
52
|
+
export const outputFileSync = _outputFile.outputFileSync
|
|
53
|
+
export const pathExists = _pathExists.pathExists
|
|
54
|
+
export const pathExistsSync = _pathExists.pathExistsSync
|
|
55
|
+
export const remove = _remove.remove
|
|
56
|
+
export const removeSync = _remove.removeSync
|
|
57
|
+
|
|
58
|
+
export default {
|
|
59
|
+
..._copy,
|
|
60
|
+
..._empty,
|
|
61
|
+
..._ensure,
|
|
62
|
+
..._json,
|
|
63
|
+
..._mkdirs,
|
|
64
|
+
..._move,
|
|
65
|
+
..._outputFile,
|
|
66
|
+
..._pathExists,
|
|
67
|
+
..._remove
|
|
68
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
// This is adapted from https://github.com/normalize/mz
|
|
3
|
+
// Copyright (c) 2014-2016 Jonathan Ong me@jongleberry.com and Contributors
|
|
4
|
+
const u = require('universalify').fromCallback
|
|
5
|
+
const fs = require('graceful-fs')
|
|
6
|
+
|
|
7
|
+
const api = [
|
|
8
|
+
'access',
|
|
9
|
+
'appendFile',
|
|
10
|
+
'chmod',
|
|
11
|
+
'chown',
|
|
12
|
+
'close',
|
|
13
|
+
'copyFile',
|
|
14
|
+
'fchmod',
|
|
15
|
+
'fchown',
|
|
16
|
+
'fdatasync',
|
|
17
|
+
'fstat',
|
|
18
|
+
'fsync',
|
|
19
|
+
'ftruncate',
|
|
20
|
+
'futimes',
|
|
21
|
+
'lchmod',
|
|
22
|
+
'lchown',
|
|
23
|
+
'link',
|
|
24
|
+
'lstat',
|
|
25
|
+
'mkdir',
|
|
26
|
+
'mkdtemp',
|
|
27
|
+
'open',
|
|
28
|
+
'opendir',
|
|
29
|
+
'readdir',
|
|
30
|
+
'readFile',
|
|
31
|
+
'readlink',
|
|
32
|
+
'realpath',
|
|
33
|
+
'rename',
|
|
34
|
+
'rm',
|
|
35
|
+
'rmdir',
|
|
36
|
+
'stat',
|
|
37
|
+
'symlink',
|
|
38
|
+
'truncate',
|
|
39
|
+
'unlink',
|
|
40
|
+
'utimes',
|
|
41
|
+
'writeFile'
|
|
42
|
+
].filter(key => {
|
|
43
|
+
// Some commands are not available on some systems. Ex:
|
|
44
|
+
// fs.cp was added in Node.js v16.7.0
|
|
45
|
+
// fs.lchown is not available on at least some Linux
|
|
46
|
+
return typeof fs[key] === 'function'
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
// Export cloned fs:
|
|
50
|
+
Object.assign(exports, fs)
|
|
51
|
+
|
|
52
|
+
// Universalify async methods:
|
|
53
|
+
api.forEach(method => {
|
|
54
|
+
exports[method] = u(fs[method])
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
// We differ from mz/fs in that we still ship the old, broken, fs.exists()
|
|
58
|
+
// since we are a drop-in replacement for the native module
|
|
59
|
+
exports.exists = function (filename, callback) {
|
|
60
|
+
if (typeof callback === 'function') {
|
|
61
|
+
return fs.exists(filename, callback)
|
|
62
|
+
}
|
|
63
|
+
return new Promise(resolve => {
|
|
64
|
+
return fs.exists(filename, resolve)
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// fs.read(), fs.write(), fs.readv(), & fs.writev() need special treatment due to multiple callback args
|
|
69
|
+
|
|
70
|
+
exports.read = function (fd, buffer, offset, length, position, callback) {
|
|
71
|
+
if (typeof callback === 'function') {
|
|
72
|
+
return fs.read(fd, buffer, offset, length, position, callback)
|
|
73
|
+
}
|
|
74
|
+
return new Promise((resolve, reject) => {
|
|
75
|
+
fs.read(fd, buffer, offset, length, position, (err, bytesRead, buffer) => {
|
|
76
|
+
if (err) return reject(err)
|
|
77
|
+
resolve({ bytesRead, buffer })
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Function signature can be
|
|
83
|
+
// fs.write(fd, buffer[, offset[, length[, position]]], callback)
|
|
84
|
+
// OR
|
|
85
|
+
// fs.write(fd, string[, position[, encoding]], callback)
|
|
86
|
+
// We need to handle both cases, so we use ...args
|
|
87
|
+
exports.write = function (fd, buffer, ...args) {
|
|
88
|
+
if (typeof args[args.length - 1] === 'function') {
|
|
89
|
+
return fs.write(fd, buffer, ...args)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return new Promise((resolve, reject) => {
|
|
93
|
+
fs.write(fd, buffer, ...args, (err, bytesWritten, buffer) => {
|
|
94
|
+
if (err) return reject(err)
|
|
95
|
+
resolve({ bytesWritten, buffer })
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Function signature is
|
|
101
|
+
// s.readv(fd, buffers[, position], callback)
|
|
102
|
+
// We need to handle the optional arg, so we use ...args
|
|
103
|
+
exports.readv = function (fd, buffers, ...args) {
|
|
104
|
+
if (typeof args[args.length - 1] === 'function') {
|
|
105
|
+
return fs.readv(fd, buffers, ...args)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return new Promise((resolve, reject) => {
|
|
109
|
+
fs.readv(fd, buffers, ...args, (err, bytesRead, buffers) => {
|
|
110
|
+
if (err) return reject(err)
|
|
111
|
+
resolve({ bytesRead, buffers })
|
|
112
|
+
})
|
|
113
|
+
})
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Function signature is
|
|
117
|
+
// s.writev(fd, buffers[, position], callback)
|
|
118
|
+
// We need to handle the optional arg, so we use ...args
|
|
119
|
+
exports.writev = function (fd, buffers, ...args) {
|
|
120
|
+
if (typeof args[args.length - 1] === 'function') {
|
|
121
|
+
return fs.writev(fd, buffers, ...args)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return new Promise((resolve, reject) => {
|
|
125
|
+
fs.writev(fd, buffers, ...args, (err, bytesWritten, buffers) => {
|
|
126
|
+
if (err) return reject(err)
|
|
127
|
+
resolve({ bytesWritten, buffers })
|
|
128
|
+
})
|
|
129
|
+
})
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// fs.realpath.native sometimes not available if fs is monkey-patched
|
|
133
|
+
if (typeof fs.realpath.native === 'function') {
|
|
134
|
+
exports.realpath.native = u(fs.realpath.native)
|
|
135
|
+
} else {
|
|
136
|
+
process.emitWarning(
|
|
137
|
+
'fs.realpath.native is not a function. Is fs being monkey-patched?',
|
|
138
|
+
'Warning', 'fs-extra-WARN0003'
|
|
139
|
+
)
|
|
140
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
// Export promiseified graceful-fs:
|
|
5
|
+
...require('./fs'),
|
|
6
|
+
// Export extra methods:
|
|
7
|
+
...require('./copy'),
|
|
8
|
+
...require('./empty'),
|
|
9
|
+
...require('./ensure'),
|
|
10
|
+
...require('./json'),
|
|
11
|
+
...require('./mkdirs'),
|
|
12
|
+
...require('./move'),
|
|
13
|
+
...require('./output-file'),
|
|
14
|
+
...require('./path-exists'),
|
|
15
|
+
...require('./remove')
|
|
16
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const u = require('universalify').fromPromise
|
|
4
|
+
const jsonFile = require('./jsonfile')
|
|
5
|
+
|
|
6
|
+
jsonFile.outputJson = u(require('./output-json'))
|
|
7
|
+
jsonFile.outputJsonSync = require('./output-json-sync')
|
|
8
|
+
// aliases
|
|
9
|
+
jsonFile.outputJSON = jsonFile.outputJson
|
|
10
|
+
jsonFile.outputJSONSync = jsonFile.outputJsonSync
|
|
11
|
+
jsonFile.writeJSON = jsonFile.writeJson
|
|
12
|
+
jsonFile.writeJSONSync = jsonFile.writeJsonSync
|
|
13
|
+
jsonFile.readJSON = jsonFile.readJson
|
|
14
|
+
jsonFile.readJSONSync = jsonFile.readJsonSync
|
|
15
|
+
|
|
16
|
+
module.exports = jsonFile
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { stringify } = require('jsonfile/utils')
|
|
4
|
+
const { outputFileSync } = require('../output-file')
|
|
5
|
+
|
|
6
|
+
function outputJsonSync (file, data, options) {
|
|
7
|
+
const str = stringify(data, options)
|
|
8
|
+
|
|
9
|
+
outputFileSync(file, str, options)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
module.exports = outputJsonSync
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { stringify } = require('jsonfile/utils')
|
|
4
|
+
const { outputFile } = require('../output-file')
|
|
5
|
+
|
|
6
|
+
async function outputJson (file, data, options = {}) {
|
|
7
|
+
const str = stringify(data, options)
|
|
8
|
+
|
|
9
|
+
await outputFile(file, str, options)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
module.exports = outputJson
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
const u = require('universalify').fromPromise
|
|
3
|
+
const { makeDir: _makeDir, makeDirSync } = require('./make-dir')
|
|
4
|
+
const makeDir = u(_makeDir)
|
|
5
|
+
|
|
6
|
+
module.exports = {
|
|
7
|
+
mkdirs: makeDir,
|
|
8
|
+
mkdirsSync: makeDirSync,
|
|
9
|
+
// alias
|
|
10
|
+
mkdirp: makeDir,
|
|
11
|
+
mkdirpSync: makeDirSync,
|
|
12
|
+
ensureDir: makeDir,
|
|
13
|
+
ensureDirSync: makeDirSync
|
|
14
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
const fs = require('../fs')
|
|
3
|
+
const { checkPath } = require('./utils')
|
|
4
|
+
|
|
5
|
+
const getMode = options => {
|
|
6
|
+
const defaults = { mode: 0o777 }
|
|
7
|
+
if (typeof options === 'number') return options
|
|
8
|
+
return ({ ...defaults, ...options }).mode
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports.makeDir = async (dir, options) => {
|
|
12
|
+
checkPath(dir)
|
|
13
|
+
|
|
14
|
+
return fs.mkdir(dir, {
|
|
15
|
+
mode: getMode(options),
|
|
16
|
+
recursive: true
|
|
17
|
+
})
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module.exports.makeDirSync = (dir, options) => {
|
|
21
|
+
checkPath(dir)
|
|
22
|
+
|
|
23
|
+
return fs.mkdirSync(dir, {
|
|
24
|
+
mode: getMode(options),
|
|
25
|
+
recursive: true
|
|
26
|
+
})
|
|
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
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const fs = require('graceful-fs')
|
|
4
|
+
const path = require('path')
|
|
5
|
+
const copySync = require('../copy').copySync
|
|
6
|
+
const removeSync = require('../remove').removeSync
|
|
7
|
+
const mkdirpSync = require('../mkdirs').mkdirpSync
|
|
8
|
+
const stat = require('../util/stat')
|
|
9
|
+
|
|
10
|
+
function moveSync (src, dest, opts) {
|
|
11
|
+
opts = opts || {}
|
|
12
|
+
const overwrite = opts.overwrite || opts.clobber || false
|
|
13
|
+
|
|
14
|
+
const { srcStat, isChangingCase = false } = stat.checkPathsSync(src, dest, 'move', opts)
|
|
15
|
+
stat.checkParentPathsSync(src, srcStat, dest, 'move')
|
|
16
|
+
if (!isParentRoot(dest)) mkdirpSync(path.dirname(dest))
|
|
17
|
+
return doRename(src, dest, overwrite, isChangingCase)
|
|
18
|
+
}
|
|
19
|
+
|
|
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)
|
|
28
|
+
if (overwrite) {
|
|
29
|
+
removeSync(dest)
|
|
30
|
+
return rename(src, dest, overwrite)
|
|
31
|
+
}
|
|
32
|
+
if (fs.existsSync(dest)) throw new Error('dest already exists.')
|
|
33
|
+
return rename(src, dest, overwrite)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function rename (src, dest, overwrite) {
|
|
37
|
+
try {
|
|
38
|
+
fs.renameSync(src, dest)
|
|
39
|
+
} catch (err) {
|
|
40
|
+
if (err.code !== 'EXDEV') throw err
|
|
41
|
+
return moveAcrossDevice(src, dest, overwrite)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function moveAcrossDevice (src, dest, overwrite) {
|
|
46
|
+
const opts = {
|
|
47
|
+
overwrite,
|
|
48
|
+
errorOnExist: true,
|
|
49
|
+
preserveTimestamps: true
|
|
50
|
+
}
|
|
51
|
+
copySync(src, dest, opts)
|
|
52
|
+
return removeSync(src)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
module.exports = moveSync
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const fs = require('graceful-fs')
|
|
4
|
+
const path = require('path')
|
|
5
|
+
const copy = require('../copy').copy
|
|
6
|
+
const remove = require('../remove').remove
|
|
7
|
+
const mkdirp = require('../mkdirs').mkdirp
|
|
8
|
+
const pathExists = require('../path-exists').pathExists
|
|
9
|
+
const stat = require('../util/stat')
|
|
10
|
+
|
|
11
|
+
function move (src, dest, opts, cb) {
|
|
12
|
+
if (typeof opts === 'function') {
|
|
13
|
+
cb = opts
|
|
14
|
+
opts = {}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
opts = opts || {}
|
|
18
|
+
|
|
19
|
+
const overwrite = opts.overwrite || opts.clobber || false
|
|
20
|
+
|
|
21
|
+
stat.checkPaths(src, dest, 'move', opts, (err, stats) => {
|
|
22
|
+
if (err) return cb(err)
|
|
23
|
+
const { srcStat, isChangingCase = false } = stats
|
|
24
|
+
stat.checkParentPaths(src, srcStat, dest, 'move', err => {
|
|
25
|
+
if (err) return cb(err)
|
|
26
|
+
if (isParentRoot(dest)) return doRename(src, dest, overwrite, isChangingCase, cb)
|
|
27
|
+
mkdirp(path.dirname(dest), err => {
|
|
28
|
+
if (err) return cb(err)
|
|
29
|
+
return doRename(src, dest, overwrite, isChangingCase, cb)
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
|
|
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)
|
|
43
|
+
if (overwrite) {
|
|
44
|
+
return remove(dest, err => {
|
|
45
|
+
if (err) return cb(err)
|
|
46
|
+
return rename(src, dest, overwrite, cb)
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
pathExists(dest, (err, destExists) => {
|
|
50
|
+
if (err) return cb(err)
|
|
51
|
+
if (destExists) return cb(new Error('dest already exists.'))
|
|
52
|
+
return rename(src, dest, overwrite, cb)
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function rename (src, dest, overwrite, cb) {
|
|
57
|
+
fs.rename(src, dest, err => {
|
|
58
|
+
if (!err) return cb()
|
|
59
|
+
if (err.code !== 'EXDEV') return cb(err)
|
|
60
|
+
return moveAcrossDevice(src, dest, overwrite, cb)
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function moveAcrossDevice (src, dest, overwrite, cb) {
|
|
65
|
+
const opts = {
|
|
66
|
+
overwrite,
|
|
67
|
+
errorOnExist: true,
|
|
68
|
+
preserveTimestamps: true
|
|
69
|
+
}
|
|
70
|
+
copy(src, dest, opts, err => {
|
|
71
|
+
if (err) return cb(err)
|
|
72
|
+
return remove(src, cb)
|
|
73
|
+
})
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
module.exports = move
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const u = require('universalify').fromCallback
|
|
4
|
+
const fs = require('graceful-fs')
|
|
5
|
+
const path = require('path')
|
|
6
|
+
const mkdir = require('../mkdirs')
|
|
7
|
+
const pathExists = require('../path-exists').pathExists
|
|
8
|
+
|
|
9
|
+
function outputFile (file, data, encoding, callback) {
|
|
10
|
+
if (typeof encoding === 'function') {
|
|
11
|
+
callback = encoding
|
|
12
|
+
encoding = 'utf8'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const dir = path.dirname(file)
|
|
16
|
+
pathExists(dir, (err, itDoes) => {
|
|
17
|
+
if (err) return callback(err)
|
|
18
|
+
if (itDoes) return fs.writeFile(file, data, encoding, callback)
|
|
19
|
+
|
|
20
|
+
mkdir.mkdirs(dir, err => {
|
|
21
|
+
if (err) return callback(err)
|
|
22
|
+
|
|
23
|
+
fs.writeFile(file, data, encoding, callback)
|
|
24
|
+
})
|
|
25
|
+
})
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function outputFileSync (file, ...args) {
|
|
29
|
+
const dir = path.dirname(file)
|
|
30
|
+
if (fs.existsSync(dir)) {
|
|
31
|
+
return fs.writeFileSync(file, ...args)
|
|
32
|
+
}
|
|
33
|
+
mkdir.mkdirsSync(dir)
|
|
34
|
+
fs.writeFileSync(file, ...args)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = {
|
|
38
|
+
outputFile: u(outputFile),
|
|
39
|
+
outputFileSync
|
|
40
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
const u = require('universalify').fromPromise
|
|
3
|
+
const fs = require('../fs')
|
|
4
|
+
|
|
5
|
+
function pathExists (path) {
|
|
6
|
+
return fs.access(path).then(() => true).catch(() => false)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
module.exports = {
|
|
10
|
+
pathExists: u(pathExists),
|
|
11
|
+
pathExistsSync: fs.existsSync
|
|
12
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const fs = require('graceful-fs')
|
|
4
|
+
const u = require('universalify').fromCallback
|
|
5
|
+
|
|
6
|
+
function remove (path, callback) {
|
|
7
|
+
fs.rm(path, { recursive: true, force: true }, callback)
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function removeSync (path) {
|
|
11
|
+
fs.rmSync(path, { recursive: true, force: true })
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module.exports = {
|
|
15
|
+
remove: u(remove),
|
|
16
|
+
removeSync
|
|
17
|
+
}
|