Skip to content

Instantly share code, notes, and snippets.

@swannodette
Last active September 6, 2015 00:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swannodette/aad077de18309a08cff3 to your computer and use it in GitHub Desktop.
Save swannodette/aad077de18309a08cff3 to your computer and use it in GitHub Desktop.
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