walk.js/bin/walk.mjs

25 lines
543 B
JavaScript
Raw Normal View History

2020-12-09 00:28:11 +00:00
import Walk from "../walk.mjs";
import path from "path";
var rootpath = process.argv[2] || ".";
Walk.walk(rootpath, async function (err, pathname, dirent) {
if (err) {
throw err;
}
var entType;
if (dirent.isDirectory()) {
entType = " dir";
} else if (dirent.isFile()) {
entType = "file";
} else if (dirent.isSymbolicLink()) {
entType = "link";
} else {
entType = "----";
}
console.info("[%s] %s", entType, path.dirname(pathname), dirent.name);
}).catch(function (err) {
console.error(err.stack);
});