Spotted a mistake in "scandir.[js|coffee]": was still using "phantom.fs" API.

1.3
Ivan De Marino 2011-08-04 22:00:18 +01:00
parent e71a992dbd
commit 3046bd994e
2 changed files with 6 additions and 6 deletions

View File

@ -4,10 +4,10 @@ if phantom.args.length != 1
console.log "Usage: phantomjs scandir.js DIRECTORY_TO_SCAN"
phantom.exit()
scanDirectory = (path) ->
if phantom.fs.exists(path) and phantom.fs.isFile(path)
if fs.exists(path) and fs.isFile(path)
console.log path
else if phantom.fs.isDir(path)
phantom.fs.list(path).forEach (e) ->
else if fs.isDirectory(path)
fs.list(path).forEach (e) ->
scanDirectory path + "/" + e if e != "." and e != ".."
scanDirectory phantom.args[0]

View File

@ -6,10 +6,10 @@ if (phantom.args.length !== 1) {
}
var scanDirectory = function (path) {
if (phantom.fs.exists(path) && phantom.fs.isFile(path)) {
if (fs.exists(path) && fs.isFile(path)) {
console.log(path);
} else if (phantom.fs.isDir(path)) {
phantom.fs.list(path).forEach(function (e) {
} else if (fs.isDirectory(path)) {
fs.list(path).forEach(function (e) {
if ( e !== "." && e !== ".." ) { //< Avoid loops
scanDirectory(path + '/' + e);
}