Sha256: a00904a10b529a2ad4544feca516f297d96949ee802d446aeb9d0222fa17d3ad

Contents?: true

Size: 587 Bytes

Versions: 2

Compression:

Stored size: 587 Bytes

Contents

// List all the files in a Tree of Directories

if (phantom.args.length !== 1) {
    console.log("Usage: phantomjs scandir.js DIRECTORY_TO_SCAN");
    phantom.exit();
}

var scanDirectory = function (path) {
    var fs = require('fs');
    if (fs.exists(path) && fs.isFile(path)) {
        console.log(path);
    } else if (fs.isDirectory(path)) {
        fs.list(path).forEach(function (e) {
            if ( e !== "." && e !== ".." ) {    //< Avoid loops
                scanDirectory(path + '/' + e);
            }
        });
    }
};
scanDirectory(phantom.args[0]);
phantom.exit();

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
phantomjs.rb-0.0.2 vendor/phantomjs-1.4.1_OSX/examples/scandir.js
phantomjs.rb-0.0.1 vendor/phantomjs-1.4.1_OSX/examples/scandir.js