@fullstackunicorn/filesystem 1.0.7 → 1.0.9

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/modules/fsa.js CHANGED
@@ -52,5 +52,32 @@ export const fsa = {
52
52
  'thumbs.db', 'ehthumbs.db', 'desktop.ini', '$recycle.bin', 'system volume information',
53
53
  'lost+found', '__macosx', '.swp', '.swo', '.#', '.cache'
54
54
  ].some(bad => lower === bad || lower.startsWith(bad))
55
+ },
56
+ copyFile: fsAsync.copyFile,
57
+ copyDir: async (src, dest) => {
58
+ await fsa.ensureDir(dest)
59
+ const entries = await fsa.readDir(src)
60
+ for (const entry of entries) {
61
+ const srcPath = `${src}/${entry}`
62
+ const destPath = `${dest}/${entry}`
63
+ const stat = await fsa.stat(srcPath)
64
+ if (stat.isDirectory()) await fsa.copyDir(srcPath, destPath)
65
+ else await fsAsync.copyFile(srcPath, destPath)
66
+ }
67
+ },
68
+ getDirPaths: async (basePath) => {
69
+ const files = []
70
+ const scan = async dir => {
71
+ const entries = await fsa.readDir(dir)
72
+ for (const entry of entries) {
73
+ if (fsa.isJunk(entry)) continue
74
+ const fullPath = path.join(dir, entry)
75
+ const stat = await fsa.stat(fullPath)
76
+ if (stat.isDirectory()) await scan(fullPath)
77
+ else files.push(path.relative(basePath, fullPath))
78
+ }
79
+ }
80
+ await scan(basePath)
81
+ return files
55
82
  }
56
83
  }
package/modules/fss.js CHANGED
@@ -49,5 +49,32 @@ export const fss = {
49
49
  'thumbs.db', 'ehthumbs.db', 'desktop.ini', '$recycle.bin', 'system volume information',
50
50
  'lost+found', '__macosx', '.swp', '.swo', '.#', '.cache'
51
51
  ].some(bad => lower === bad || lower.startsWith(bad))
52
+ },
53
+ copyFile: fsSync.copyFileSync,
54
+ copyDir: (src, dest) => {
55
+ fss.ensureDir(dest)
56
+ const entries = fss.readDir(src)
57
+ for (const entry of entries) {
58
+ const srcPath = `${src}/${entry}`
59
+ const destPath = `${dest}/${entry}`
60
+ const stat = fss.stat(srcPath)
61
+ if (stat.isDirectory()) fss.copyDir(srcPath, destPath)
62
+ else fsSync.copyFileSync(srcPath, destPath)
63
+ }
64
+ },
65
+ getDirPaths: (basePath) => {
66
+ const files = []
67
+ const scan = dir => {
68
+ const entries = fss.readDir(dir)
69
+ for (const entry of entries) {
70
+ if (fss.isJunk(entry)) continue
71
+ const fullPath = path.join(dir, entry)
72
+ const stat = fss.stat(fullPath)
73
+ if (stat.isDirectory()) scan(fullPath)
74
+ else files.push(path.relative(basePath, fullPath))
75
+ }
76
+ }
77
+ scan(basePath)
78
+ return files
52
79
  }
53
80
  }
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.0.7",
2
+ "version": "1.0.9",
3
3
  "name": "@fullstackunicorn/filesystem",
4
4
  "author": "lucanigido (https://fullstackunicorn.dev/author/lucanigido)",
5
5
  "description": "A simple sync/async file system wrapper for Node.js",