@magic/fs 0.0.34 → 0.0.36
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 +10 -1
- package/package.json +2 -2
- package/src/getDirectories.js +4 -0
- package/src/getFiles.js +6 -7
package/README.md
CHANGED
|
@@ -325,7 +325,16 @@ update dependencies
|
|
|
325
325
|
|
|
326
326
|
- update types
|
|
327
327
|
|
|
328
|
-
##### 0.0.35
|
|
328
|
+
##### 0.0.35
|
|
329
|
+
|
|
330
|
+
- fs.getDirectories maxDepth will be at least 2 if noRoot is set.
|
|
331
|
+
- update dependencies
|
|
332
|
+
|
|
333
|
+
##### 0.0.36
|
|
334
|
+
|
|
335
|
+
- getFiles: options.root can be undefined, leading to correct depth calculations
|
|
336
|
+
|
|
337
|
+
##### 0.0.37 - unreleased
|
|
329
338
|
|
|
330
339
|
...
|
|
331
340
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magic/fs",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.36",
|
|
4
4
|
"author": "Wizards & Witches",
|
|
5
5
|
"description": "nodejs fs promises + goodies",
|
|
6
6
|
"license": "AGPL-3.0",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@magic/core": "0.0.156",
|
|
44
44
|
"@magic/format": "0.0.68",
|
|
45
45
|
"@magic/test": "0.2.24",
|
|
46
|
-
"@types/node": "24.
|
|
46
|
+
"@types/node": "24.9.2",
|
|
47
47
|
"typescript": "5.9.3"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
package/src/getDirectories.js
CHANGED
|
@@ -38,6 +38,10 @@ export const getDirectories = async (dir, options = {}) => {
|
|
|
38
38
|
minDepth = 0
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
if (noRoot && maxDepth === 1) {
|
|
42
|
+
maxDepth += 1
|
|
43
|
+
}
|
|
44
|
+
|
|
41
45
|
if (!is.array(dir) && !is.string(dir)) {
|
|
42
46
|
throw error(`${libName}: need an array or a string as first argument`, 'E_ARG_TYPE')
|
|
43
47
|
}
|
package/src/getFiles.js
CHANGED
|
@@ -27,7 +27,7 @@ export const getFiles = async (dir, options = {}) => {
|
|
|
27
27
|
depth = false,
|
|
28
28
|
extension = false,
|
|
29
29
|
ext = false,
|
|
30
|
-
root
|
|
30
|
+
root,
|
|
31
31
|
} = options
|
|
32
32
|
|
|
33
33
|
if (ext && !extension) {
|
|
@@ -50,15 +50,14 @@ export const getFiles = async (dir, options = {}) => {
|
|
|
50
50
|
throw error(`${libName}: dir: first argument must be a string.`, 'E_ARG_TYPE')
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
if (is.
|
|
53
|
+
if (is.undefined(root)) {
|
|
54
54
|
root = dir
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
const currentDepth =
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
.filter(a => a).length - 1
|
|
57
|
+
const currentDepth = dir
|
|
58
|
+
.replace(root, '')
|
|
59
|
+
.split(path.sep)
|
|
60
|
+
.filter(a => a).length
|
|
62
61
|
|
|
63
62
|
if (currentDepth > maxDepth) {
|
|
64
63
|
return []
|