2011-06-14 14:28:51 +04:00
|
|
|
# List all the files in a Tree of Directories
|
2012-01-14 19:13:26 +04:00
|
|
|
system = require 'system'
|
2011-06-14 14:28:51 +04:00
|
|
|
|
2012-01-14 19:13:26 +04:00
|
|
|
if system.args.length != 2
|
|
|
|
console.log "Usage: phantomjs scandir.coffee DIRECTORY_TO_SCAN"
|
2012-05-16 11:37:26 +04:00
|
|
|
phantom.exit 1
|
2011-06-14 14:28:51 +04:00
|
|
|
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 != ".."
|
|
|
|
|
2012-01-14 19:13:26 +04:00
|
|
|
scanDirectory system.args[1]
|
2011-09-08 20:55:50 +04:00
|
|
|
phantom.exit()
|