1 // List all the files in a Tree of Directories
2 var system = require('system');
4 if (system.args.length !== 2) {
5 console.log("Usage: phantomjs scandir.js DIRECTORY_TO_SCAN");
9 var scanDirectory = function (path) {
10 var fs = require('fs');
11 if (fs.exists(path) && fs.isFile(path)) {
13 } else if (fs.isDirectory(path)) {
14 fs.list(path).forEach(function (e) {
15 if ( e !== "." && e !== ".." ) { //< Avoid loops
16 scanDirectory(path + '/' + e);
21 scanDirectory(system.args[1]);