Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


allowing multiple --externs options to be passed #11

merged 1 commit into from

2 participants


As initializer takes hash, it was not possible to pass multiple attributes of the same kind.
I made it possible to pass an array of --extern (or other attributes). See comments of commit on Github.


Google closure allows to add multiple --externs options like below
"--externs library1.js --externs library2.js"

Till now constructor was receiving options as a hash which was not allowing to pass multiple attributes of the same kind ({:externs => "library1", :externs => "library2"}).

I made a changes allowing to pass an array of such attributes. For example:
{:externs => ["library1.js", "library2.js"]
which produces :

"--externs library1.js --externs library2.js"

as options

@jashkenas jashkenas merged commit 0243477 into from

Looks good -- thanks.


at your services ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 12, 2011
  1. @xiazek
This page is out of date. Refresh to see the latest.
Showing with 16 additions and 1 deletion.
  1. +7 −1 lib/closure/compiler.rb
  2. +9 −0 test/unit/test_closure_compiler.rb
8 lib/closure/compiler.rb
@@ -51,7 +51,13 @@ def compile(io)
# Serialize hash options to the command-line format.
def serialize_options(options)
- {|k, v| ["--#{k}", v.to_s] }.flatten
+ do |k, v|
+ if (v.is_a?(Array))
+ {|v2| ["--#{k}", v2.to_s]}
+ else
+ ["--#{k}", v.to_s]
+ end
+ end.flatten
def command
9 test/unit/test_closure_compiler.rb
@@ -60,4 +60,13 @@ def test_permissions
assert File.executable?(COMPILER_JAR)
+ def test_serialize_options
+ assert_equal ["--externs", "library1.js", "--compilation_level", "ADVANCED_OPTIMIZATIONS"],, 'externs' => 'library1.js', "compilation_level" => "ADVANCED_OPTIMIZATIONS")
+ end
+ def test_serialize_options_for_arrays
+ compiler ='externs' => ['library1.js', "library2.js"])
+ assert_equal ["--externs", "library1.js", "--externs", "library2.js"], compiler.send(:serialize_options, 'externs' => ['library1.js', "library2.js"])
+ end
Something went wrong with that request. Please try again.