2011-06-14 14:28:51 +04:00
|
|
|
# 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()
|
|
|
|
scanDirectory = (path) ->
|
2011-09-08 20:55:50 +04:00
|
|
|
fs = require 'fs'
|
2011-08-05 01:00:18 +04:00
|
|
|
if fs.exists(path) and fs.isFile(path)
|
2011-06-14 14:28:51 +04:00
|
|
|
console.log path
|
2011-08-05 01:00:18 +04:00
|
|
|
else if fs.isDirectory(path)
|
|
|
|
fs.list(path).forEach (e) ->
|
2011-06-14 14:28:51 +04:00
|
|
|
scanDirectory path + "/" + e if e != "." and e != ".."
|
|
|
|
|
|
|
|
scanDirectory phantom.args[0]
|
2011-09-08 20:55:50 +04:00
|
|
|
phantom.exit()
|