月球漫步是一个简单的事件驱动的目录树walker。以下是使用示例:


// This program walks all files and directories under /home/sixpounder

var Moonwalker = require('moonwalk');

var m = new Moonwalker('/home/sixpounder');

m.on('file', function(path) {

  console.log('Found file: ' + path);

});

m.on('directory', function(path) {

  console.log('Found directory: ' + path);

});

m.on('end', function() {

  console.log('Finished walking the directory tree.');

});

该工具允许你以事件驱动的方式遍历目录结构,并对文件和目录做出响应。