mirror of https://github.com/vitalif/phantomjs
Spotted a mistake in "scandir.[js|coffee]": was still using "phantom.fs" API.
parent
e71a992dbd
commit
3046bd994e
|
@ -4,10 +4,10 @@ if phantom.args.length != 1
|
||||||
console.log "Usage: phantomjs scandir.js DIRECTORY_TO_SCAN"
|
console.log "Usage: phantomjs scandir.js DIRECTORY_TO_SCAN"
|
||||||
phantom.exit()
|
phantom.exit()
|
||||||
scanDirectory = (path) ->
|
scanDirectory = (path) ->
|
||||||
if phantom.fs.exists(path) and phantom.fs.isFile(path)
|
if fs.exists(path) and fs.isFile(path)
|
||||||
console.log path
|
console.log path
|
||||||
else if phantom.fs.isDir(path)
|
else if fs.isDirectory(path)
|
||||||
phantom.fs.list(path).forEach (e) ->
|
fs.list(path).forEach (e) ->
|
||||||
scanDirectory path + "/" + e if e != "." and e != ".."
|
scanDirectory path + "/" + e if e != "." and e != ".."
|
||||||
|
|
||||||
scanDirectory phantom.args[0]
|
scanDirectory phantom.args[0]
|
||||||
|
|
|
@ -6,10 +6,10 @@ if (phantom.args.length !== 1) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var scanDirectory = function (path) {
|
var scanDirectory = function (path) {
|
||||||
if (phantom.fs.exists(path) && phantom.fs.isFile(path)) {
|
if (fs.exists(path) && fs.isFile(path)) {
|
||||||
console.log(path);
|
console.log(path);
|
||||||
} else if (phantom.fs.isDir(path)) {
|
} else if (fs.isDirectory(path)) {
|
||||||
phantom.fs.list(path).forEach(function (e) {
|
fs.list(path).forEach(function (e) {
|
||||||
if ( e !== "." && e !== ".." ) { //< Avoid loops
|
if ( e !== "." && e !== ".." ) { //< Avoid loops
|
||||||
scanDirectory(path + '/' + e);
|
scanDirectory(path + '/' + e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue