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