Created
January 29, 2017 08:23
-
-
Save ichiriac/9b622420f3af9da370b2cb0706b19d34 to your computer and use it in GitHub Desktop.
Scan a path with PHP files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
// https://www.npmjs.com/package/php-parser | |
var parser = require('php-parser'); | |
// https://www.npmjs.com/package/glob | |
var glob = require('glob'); | |
glob("**/*.php", options, function (er, files) { | |
for(var i = 0; i < files.length; i++) { | |
var file = files[i]; | |
try { | |
var AST = parser.parseCode( | |
fs.readFileSync(file, { encoding: 'utf8' }), file | |
); | |
scanNode(AST, file); | |
} catch(e) { | |
console.error(e.stack); | |
} | |
} | |
}); | |
function scanNode(node, file) { | |
// here do the magic stuff | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment