Further changes for the Use cases on the live site.
[yaffs-website] / node_modules / phantomjs-prebuilt / lib / phantom / examples / scandir.js
1 // List all the files in a Tree of Directories
2
3 "use strict";
4 var system = require('system');
5
6 if (system.args.length !== 2) {
7     console.log("Usage: phantomjs scandir.js DIRECTORY_TO_SCAN");
8     phantom.exit(1);
9 }
10
11 var scanDirectory = function (path) {
12     var fs = require('fs');
13     if (fs.exists(path) && fs.isFile(path)) {
14         console.log(path);
15     } else if (fs.isDirectory(path)) {
16         fs.list(path).forEach(function (e) {
17             if ( e !== "." && e !== ".." ) {    //< Avoid loops
18                 scanDirectory(path + '/' + e);
19             }
20         });
21     }
22 };
23 scanDirectory(system.args[1]);
24 phantom.exit();