Last active
September 6, 2015 00:27
-
-
Save swannodette/aad077de18309a08cff3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 ArrayList = Packages.java.util.ArrayList, | |
File = Packages.java.io.File, | |
jscomp = Packages.com.google.javascript.jscomp, | |
SourceFile = jscomp.SourceFile, | |
BasicErrorManager = jscomp.BasicErrorManager, | |
DepsGenerator = jscomp.deps.DepsGenerator, | |
InclusionStrategy = DepsGenerator.InclusionStrategy; | |
function jsFilesInDir(dir) { | |
var ret = new ArrayList(), | |
files = (new File(dir)).listFiles(); | |
for(var i = 0; i < files.length; i++) { | |
var file = files[i]; | |
if(file.isDirectory()) { | |
ret.addAll(jsFilesInDir(file)); | |
} else { | |
if(file.getName().endsWith(".js")) { | |
ret.add(SourceFile.fromFile(file)); | |
} | |
} | |
} | |
return ret; | |
} | |
function jsFilesInDirs(dirs) { | |
var ret = new ArrayList(); | |
for(var i = 0; i < dirs.length; i++) { | |
ret.addAll(jsFilesInDir(new File(dirs[i]))); | |
} | |
return ret; | |
} | |
var deps = new ArrayList(); | |
deps.add(SourceFile.fromFile(new File("deps/closure-library/closure/goog/deps.js"))); | |
var dg = new DepsGenerator( | |
deps, | |
jsFilesInDirs(["src"]), | |
InclusionStrategy.ALWAYS, | |
(new File("deps/closure-library/closure/goog")).getAbsolutePath(), | |
new BasicErrorManager() { | |
report: function(level, error) { | |
print(error); | |
}, | |
println: function(level, error) { | |
print(error); | |
} | |
} | |
); | |
print(dg.computeDependencyCalls()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment