Skip to content

Commit 6c0862d

Browse files
committed
Resolve paths and get directory info using withFileTypes
1 parent 5cc3db1 commit 6c0862d

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

buildFiles.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const {
22
existsSync
33
} = require('fs');
44
const {
5-
join
5+
resolve
66
} = require('path')
77
const fs = require('fs')
88

@@ -34,17 +34,19 @@ function getBuildFiles(externalFiles, debugLog) {
3434
}
3535

3636
const getAllBuildFiles = function (dirPath, arrayOfFiles) {
37-
const files = fs.readdirSync(dirPath)
37+
const files = fs.readdirSync(dirPath, {
38+
withFileTypes: true
39+
})
40+
.filter(it => !it.name.startsWith('.') && !it.name.startsWith('node_modules'))
3841

3942
arrayOfFiles = arrayOfFiles || []
4043

41-
files.forEach((file) => {
42-
const fsStat = fs.statSync(join(dirPath, "/", file))
43-
44-
if (fsStat.isDirectory()) {
45-
arrayOfFiles = getAllBuildFiles(join(dirPath, "/", file), arrayOfFiles)
44+
files.forEach((dirent) => {
45+
const resolvedFile = resolve(dirPath, dirent.name);
46+
if (dirent.isDirectory()) {
47+
arrayOfFiles = getAllBuildFiles(resolvedFile, arrayOfFiles)
4648
} else {
47-
arrayOfFiles.push(join(dirPath, "/", file))
49+
arrayOfFiles.push(resolvedFile)
4850
}
4951
})
5052

0 commit comments

Comments
 (0)