Skip to content

Commit 0cef3a4

Browse files
committed
Merge pull request #407 from ChadKillingsworth/master
Ensure any output_wrapper flags contain a valid marker
2 parents 337dabf + 64c61b8 commit 0cef3a4

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

src/com/google/javascript/jscomp/CommandLineRunner.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,14 @@ private void initConfigFromFlags(String[] args, PrintStream err) {
728728
flags.closureEntryPoint = Lists.newArrayList(
729729
ProcessCommonJSModules.toModuleName(flags.commonJsEntryModule));
730730
}
731+
732+
if (!(flags.outputWrapper == null ||
733+
flags.outputWrapper.contains(CommandLineRunner.OUTPUT_MARKER)))
734+
{
735+
err.println("ERROR - invalid output_wrapper specified. Missing '" +
736+
CommandLineRunner.OUTPUT_MARKER + "'.");
737+
isConfigValid = false;
738+
}
731739

732740
if (!isConfigValid || flags.displayHelp) {
733741
isConfigValid = false;

src/com/google/javascript/jscomp/ant/CompileTask.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,9 @@ public void execute() {
330330
int suffixStart = pos + CommandLineRunner.OUTPUT_MARKER.length();
331331
String suffix = this.outputWrapper.substring(suffixStart);
332332
source.append(suffix);
333+
} else {
334+
throw new BuildException("Invalid output_wrapper specified. " +
335+
"Missing '" + CommandLineRunner.OUTPUT_MARKER + "'.");
333336
}
334337
}
335338

test/com/google/javascript/jscomp/CommandLineRunnerTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,6 +1217,16 @@ public void testOutputSameAsInput() {
12171217
args.add("--js_output_file=" + getFilename(0));
12181218
test("", AbstractCommandLineRunner.OUTPUT_SAME_AS_INPUT_ERROR);
12191219
}
1220+
1221+
public void testOutputWrapperFlag() {
1222+
// if the output wrapper flag is specified without a valid output marker,
1223+
// ensure that the compiler displays an error and exits.
1224+
// See github issue 123
1225+
args.add("--output_wrapper=output");
1226+
assertFalse(
1227+
createCommandLineRunner(
1228+
new String[] {"function f() {}"}).shouldRunCompiler());
1229+
}
12201230

12211231
/* Helper functions */
12221232

0 commit comments

Comments
 (0)