Skip to content

Commit

Permalink
Factor out --entry_point flag parsing in order to use it in internal …
Browse files Browse the repository at this point in the history
…code.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=198023103
  • Loading branch information
nichtverstehen authored and brad4d committed May 25, 2018
1 parent 62fa1cf commit b6ac9ae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
20 changes: 12 additions & 8 deletions src/com/google/javascript/jscomp/AbstractCommandLineRunner.java
Expand Up @@ -2559,16 +2559,20 @@ static CompilerOptions.DependencyMode depModeFromClosureDepOptions(
}

/**
* Helper method to convert a list of closure entry points a list of the new
* ModuleIdentifier values
* Helper method to convert a list of entry points specifications to a list of the new
* ModuleIdentifier values. The specifications can be in form of "path/to/module" for ES6 or
* CommonJS modules, or "goog:some.Namespace" for Closure symbols.
*/
static List<ModuleIdentifier> entryPointsFromClosureEntryPoints(
List<String> closureEntryPoints) {
List<ModuleIdentifier> entryPoints = new ArrayList<>();
for (String closureEntryPoint : closureEntryPoints) {
entryPoints.add(ModuleIdentifier.forClosure(closureEntryPoint));
static List<ModuleIdentifier> moduleIdentifiersForEntryPoints(List<String> entryPoints) {
List<ModuleIdentifier> mids = new ArrayList<>();
for (String entryPoint : entryPoints) {
if (entryPoint.startsWith("goog:")) {
mids.add(ModuleIdentifier.forClosure(entryPoint));
} else {
mids.add(ModuleIdentifier.forFile(entryPoint));
}
}
return entryPoints;
return mids;
}

private List<String> outputManifests = ImmutableList.of();
Expand Down
10 changes: 3 additions & 7 deletions src/com/google/javascript/jscomp/CommandLineRunner.java
Expand Up @@ -1546,13 +1546,9 @@ private void initConfigFromFlags(String[] args, PrintStream out, PrintStream err
moduleRoots.add(ModuleLoader.DEFAULT_FILENAME_PREFIX);
}

for (String entryPoint : flags.entryPoints) {
if (entryPoint.startsWith("goog:")) {
entryPoints.add(ModuleIdentifier.forClosure(entryPoint));
} else {
entryPoints.add(ModuleIdentifier.forFile(entryPoint));
}
}
entryPoints.addAll(
AbstractCommandLineRunner.CommandLineConfig.moduleIdentifiersForEntryPoints(
flags.entryPoints));

if (flags.dependencyMode == CompilerOptions.DependencyMode.STRICT && entryPoints.isEmpty()) {
reportError(
Expand Down

0 comments on commit b6ac9ae

Please sign in to comment.