Skip to content

Loading…

Add requireAll support to minispade filter #35

Merged
merged 2 commits into from

3 participants

@renz45

I noticed wycats had added requireAll to minispade, this just adds that functionality to the rake-pipeline-web-filters.

@ahawkins

+1 This is especially useful when you have large amounts of files.

@wycats wycats merged commit e14e78a into wycats:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Showing with 13 additions and 0 deletions.
  1. +1 −0 lib/rake-pipeline-web-filters/minispade_filter.rb
  2. +12 −0 spec/minispade_filter_spec.rb
View
1 lib/rake-pipeline-web-filters/minispade_filter.rb
@@ -45,6 +45,7 @@ def generate_output(inputs, output)
inputs.each do |input|
code = input.read
code.gsub!(%r{^\s*require\s*\(\s*}, 'minispade.require(') if @rewrite_requires
+ code.gsub!(%r{^\s*requireAll\s*\(\s*}, 'minispade.requireAll(') if @rewrite_requires
code = %["use strict";\n] + code if @use_strict
module_id = @module_id_generator.call(input)
View
12 spec/minispade_filter_spec.rb
@@ -64,4 +64,16 @@ def make_filter(input_file, *args)
output_file.body.should ==
"minispade.register('/path/to/input/foo.js', function() {minispade.require('octopus');\n});"
end
+
+ it "rewrites requireAll if asked" do
+ filter = make_filter(input_file("requireAll('octopus');"), :rewrite_requires => true)
+ output_file.body.should ==
+ "minispade.register('/path/to/input/foo.js', function() {minispade.requireAll('octopus');\n});"
+ end
+
+ it "rewrites requireAll if asked even spaces wrap tokens in the require statement" do
+ filter = make_filter(input_file("requireAll ( 'octopus');"), :rewrite_requires => true)
+ output_file.body.should ==
+ "minispade.register('/path/to/input/foo.js', function() {minispade.requireAll('octopus');\n});"
+ end
end
Something went wrong with that request. Please try again.