grasscutterTools/packages/create-fast-vue3/utils/directoryTraverse.js
2022-05-02 18:38:10 +08:00

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)
}
}