mirror of
https://github.com/wmn1525/grasscutterTools.git
synced 2024-11-26 01:40:45 +00:00
15 lines
419 B
JavaScript
15 lines
419 B
JavaScript
|
import fs from 'fs'
|
||
|
import path from 'path'
|
||
|
|
||
|
export function postOrderDirectoryTraverse(dir, dirCallback, fileCallback) {
|
||
|
for (const filename of fs.readdirSync(dir)) {
|
||
|
const fullpath = path.resolve(dir, filename)
|
||
|
if (fs.lstatSync(fullpath).isDirectory()) {
|
||
|
postOrderDirectoryTraverse(fullpath, dirCallback, fileCallback)
|
||
|
dirCallback(fullpath)
|
||
|
continue
|
||
|
}
|
||
|
fileCallback(fullpath)
|
||
|
}
|
||
|
}
|