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