bare-fs 4.5.5 → 4.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/index.d.ts +2 -0
- package/index.js +44 -20
- package/package.json +5 -2
- package/prebuilds/android-arm/bare-fs.bare +0 -0
- package/prebuilds/android-arm64/bare-fs.bare +0 -0
- package/prebuilds/android-ia32/bare-fs.bare +0 -0
- package/prebuilds/android-x64/bare-fs.bare +0 -0
- package/prebuilds/darwin-arm64/bare-fs.bare +0 -0
- package/prebuilds/darwin-x64/bare-fs.bare +0 -0
- package/prebuilds/ios-arm64/bare-fs.bare +0 -0
- package/prebuilds/ios-arm64-simulator/bare-fs.bare +0 -0
- package/prebuilds/ios-x64-simulator/bare-fs.bare +0 -0
- package/prebuilds/linux-arm64/bare-fs.bare +0 -0
- package/prebuilds/linux-x64/bare-fs.bare +0 -0
- package/prebuilds/win32-arm64/bare-fs.bare +0 -0
- package/prebuilds/win32-x64/bare-fs.bare +0 -0
- package/promises.js +3 -1
package/index.d.ts
CHANGED
|
@@ -271,6 +271,8 @@ export function cp(src: Path, dst: Path, opts: CpOptions, cb: Callback): void
|
|
|
271
271
|
|
|
272
272
|
export function cp(src: Path, dst: Path, cb: Callback): void
|
|
273
273
|
|
|
274
|
+
export function cpSync(src: Path, dst: Path, opts?: CpOptions): void
|
|
275
|
+
|
|
274
276
|
export function exists(filepath: Path): Promise<boolean>
|
|
275
277
|
|
|
276
278
|
export function exists(filepath: Path, cb: (exists: boolean) => void): void
|
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const FIFO = require('fast-fifo')
|
|
2
2
|
const EventEmitter = require('bare-events')
|
|
3
3
|
const path = require('bare-path')
|
|
4
|
-
const { fileURLToPath } = require('bare-url')
|
|
4
|
+
const { isURL, fileURLToPath } = require('bare-url')
|
|
5
5
|
const { Readable, Writable } = require('bare-stream')
|
|
6
6
|
const binding = require('./binding')
|
|
7
7
|
const constants = require('./lib/constants')
|
|
@@ -1150,21 +1150,15 @@ async function cp(src, dst, opts, cb) {
|
|
|
1150
1150
|
|
|
1151
1151
|
if (st.isDirectory()) {
|
|
1152
1152
|
if (opts.recursive !== true) {
|
|
1153
|
-
throw new FileError('is a directory', {
|
|
1154
|
-
operation: 'cp',
|
|
1155
|
-
code: 'EISDIR',
|
|
1156
|
-
path: src
|
|
1157
|
-
})
|
|
1153
|
+
throw new FileError('is a directory', { operation: 'cp', code: 'EISDIR', path: src })
|
|
1158
1154
|
}
|
|
1159
1155
|
|
|
1160
1156
|
try {
|
|
1161
1157
|
await lstat(dst)
|
|
1162
1158
|
} catch (e) {
|
|
1163
|
-
if (e.code
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
throw e
|
|
1167
|
-
}
|
|
1159
|
+
if (e.code !== 'ENOENT') throw e
|
|
1160
|
+
|
|
1161
|
+
await mkdir(dst, { mode: st.mode, recursive: true })
|
|
1168
1162
|
}
|
|
1169
1163
|
|
|
1170
1164
|
const dir = await opendir(src)
|
|
@@ -1182,6 +1176,35 @@ async function cp(src, dst, opts, cb) {
|
|
|
1182
1176
|
return done(err, cb)
|
|
1183
1177
|
}
|
|
1184
1178
|
|
|
1179
|
+
function cpSync(src, dst, opts = {}) {
|
|
1180
|
+
src = toNamespacedPath(src)
|
|
1181
|
+
dst = toNamespacedPath(dst)
|
|
1182
|
+
|
|
1183
|
+
const st = lstatSync(src)
|
|
1184
|
+
|
|
1185
|
+
if (st.isDirectory()) {
|
|
1186
|
+
if (opts.recursive !== true) {
|
|
1187
|
+
throw new FileError('is a directory', { operation: 'cp', code: 'EISDIR', path: src })
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
try {
|
|
1191
|
+
lstatSync(dst)
|
|
1192
|
+
} catch (e) {
|
|
1193
|
+
if (e.code !== 'ENOENT') throw e
|
|
1194
|
+
|
|
1195
|
+
mkdirSync(dst, { mode: st.mode, recursive: true })
|
|
1196
|
+
}
|
|
1197
|
+
|
|
1198
|
+
const dir = opendirSync(src)
|
|
1199
|
+
for (const { name } of dir) {
|
|
1200
|
+
cpSync(path.join(src, name), path.join(dst, name), opts)
|
|
1201
|
+
}
|
|
1202
|
+
} else if (st.isFile()) {
|
|
1203
|
+
copyFileSync(src, dst)
|
|
1204
|
+
chmodSync(dst, st.mode)
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1185
1208
|
async function realpath(filepath, opts, cb) {
|
|
1186
1209
|
if (typeof opts === 'function') {
|
|
1187
1210
|
cb = opts
|
|
@@ -1338,16 +1361,16 @@ async function symlink(target, filepath, type, cb) {
|
|
|
1338
1361
|
|
|
1339
1362
|
if (typeof type === 'string') {
|
|
1340
1363
|
switch (type) {
|
|
1341
|
-
case 'file':
|
|
1342
|
-
default:
|
|
1343
|
-
type = 0
|
|
1344
|
-
break
|
|
1345
1364
|
case 'dir':
|
|
1346
1365
|
type = constants.UV_FS_SYMLINK_DIR
|
|
1347
1366
|
break
|
|
1348
1367
|
case 'junction':
|
|
1349
1368
|
type = constants.UV_FS_SYMLINK_JUNCTION
|
|
1350
1369
|
break
|
|
1370
|
+
case 'file':
|
|
1371
|
+
default:
|
|
1372
|
+
type = 0
|
|
1373
|
+
break
|
|
1351
1374
|
}
|
|
1352
1375
|
} else if (typeof type !== 'number') {
|
|
1353
1376
|
if (isWindows) {
|
|
@@ -1393,16 +1416,16 @@ function symlinkSync(target, filepath, type) {
|
|
|
1393
1416
|
|
|
1394
1417
|
if (typeof type === 'string') {
|
|
1395
1418
|
switch (type) {
|
|
1396
|
-
case 'file':
|
|
1397
|
-
default:
|
|
1398
|
-
type = 0
|
|
1399
|
-
break
|
|
1400
1419
|
case 'dir':
|
|
1401
1420
|
type = constants.UV_FS_SYMLINK_DIR
|
|
1402
1421
|
break
|
|
1403
1422
|
case 'junction':
|
|
1404
1423
|
type = constants.UV_FS_SYMLINK_JUNCTION
|
|
1405
1424
|
break
|
|
1425
|
+
case 'file':
|
|
1426
|
+
default:
|
|
1427
|
+
type = 0
|
|
1428
|
+
break
|
|
1406
1429
|
}
|
|
1407
1430
|
} else if (typeof type !== 'number') {
|
|
1408
1431
|
if (isWindows) {
|
|
@@ -2309,6 +2332,7 @@ exports.chmodSync = chmodSync
|
|
|
2309
2332
|
// exports.chownSync = chownSync TODO
|
|
2310
2333
|
exports.closeSync = closeSync
|
|
2311
2334
|
exports.copyFileSync = copyFileSync
|
|
2335
|
+
exports.cpSync = cpSync
|
|
2312
2336
|
exports.existsSync = existsSync
|
|
2313
2337
|
exports.fchmodSync = fchmodSync
|
|
2314
2338
|
// exports.fchownSync = fchownSync TODO
|
|
@@ -2366,7 +2390,7 @@ exports.createWriteStream = function createWriteStream(path, opts) {
|
|
|
2366
2390
|
|
|
2367
2391
|
function toNamespacedPath(filepath) {
|
|
2368
2392
|
if (typeof filepath !== 'string') {
|
|
2369
|
-
if (
|
|
2393
|
+
if (isURL(filepath)) filepath = fileURLToPath(filepath)
|
|
2370
2394
|
else filepath = filepath.toString()
|
|
2371
2395
|
}
|
|
2372
2396
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bare-fs",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.6.0",
|
|
4
4
|
"description": "Native file system operations for Javascript",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./package": "./package.json",
|
|
@@ -30,7 +30,9 @@
|
|
|
30
30
|
],
|
|
31
31
|
"addon": true,
|
|
32
32
|
"scripts": {
|
|
33
|
-
"
|
|
33
|
+
"format": "prettier --write . && lunte --fix",
|
|
34
|
+
"lint": "prettier --check . && lunte",
|
|
35
|
+
"test": "brittle-bare --coverage test.js"
|
|
34
36
|
},
|
|
35
37
|
"repository": {
|
|
36
38
|
"type": "git",
|
|
@@ -57,6 +59,7 @@
|
|
|
57
59
|
"bare-crypto": "^1.11.2",
|
|
58
60
|
"brittle": "^3.1.1",
|
|
59
61
|
"cmake-bare": "^1.1.7",
|
|
62
|
+
"lunte": "^1.6.0",
|
|
60
63
|
"prettier": "^3.4.1",
|
|
61
64
|
"prettier-config-holepunch": "^2.0.0"
|
|
62
65
|
},
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/promises.js
CHANGED