grasscutterTools/packages/create-fast-vue3/utils/directoryTraverse.js

15 lines
419 B
JavaScript
Raw Permalink Normal View History

2022-05-02 10:38:10 +00:00
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)
}
}