Skip to content

Commit

Permalink
using files params to rake task
Browse files Browse the repository at this point in the history
  • Loading branch information
celsodantas committed May 10, 2015
1 parent 468c879 commit 489ab55
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Only removes old assets (keeps the most recent 3 copies) from `public/assets`. U

Nuke `public/assets`.

**`rake 'assets:generate_nondigests[app_sdk.js, app_sdk.css]''`**
**`rake 'assets:generate_nondigests[app_sdk.js app_sdk.css]''`**

Will generate non-digest files of the files passed in the parameters of the task (`app_sdk.js` and `app_sdk.css` in the example above). Useful if you need some of your assets to be available for developers outside of your application (Javascript SDK for example).

Expand Down
7 changes: 4 additions & 3 deletions lib/sprockets/rails/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ def define
end

desc "Compile non-digest files"
task :generate_nondigest => :environment do |t, args|
files = args.extras
raise MissingParamsError.new("You must pass the files you want to generate nondigests (e.g. rake 'assets:generate_nondigests[file1.js, file2.js]')") if files.empty?
task :generate_nondigest, [:files_list] => :environment do |t, args|
raise MissingParamsError.new("You must pass the files you want to generate nondigests (e.g. rake assets:generate_nondigests['file1.js, file2.js'])") if args.files_list.nil?

files = args.files_list.split(' ')

with_logger do
generate_nondigests(files)
Expand Down
2 changes: 1 addition & 1 deletion test/test_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def test_generate_nondigests
assert File.exist?("#{@dir}/#{digest2_path}")
refute File.exist?("#{@dir}/#{asset2_name}")

@rake['assets:generate_nondigest'].invoke(asset1_name, asset2_name)
@rake['assets:generate_nondigest'].invoke("#{asset1_name} #{asset2_name}")

assert @environment_ran
assert File.exist?("#{@dir}/#{digest1_path}"), "digest file 1 not found"
Expand Down

0 comments on commit 489ab55

Please sign in to comment.