Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Commit

Permalink
Also fix run_config not being resolved and make it a more proper fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Rush committed Oct 22, 2014
1 parent 70a93e1 commit 3c6d26e
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions lib/requirejs/rails/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,21 +100,23 @@ def loader=(sym)
end

def build_config
self[:build_config] = self.run_config.merge "baseUrl" => source_dir.to_s,
"modules" => [{'name' => 'application'}]
self[:build_config].merge!(self.user_config).slice!(*self.build_config_whitelist)
case self.loader
when :requirejs
# nothing to do
when :almond
mods = self[:build_config]['modules']
unless mods.length == 1
raise Requirejs::ConfigError, "Almond build requires exactly one module, config has #{mods.length}."
end
mod = mods[0]
name = mod['name']
mod['name'] = 'almond'
mod['include'] = name
unless self.has_key?(:build_config)
self[:build_config] = self.run_config.merge "baseUrl" => source_dir.to_s,
"modules" => [{'name' => 'application'}]
self[:build_config].merge!(self.user_config).slice!(*self.build_config_whitelist)
case self.loader
when :requirejs
# nothing to do
when :almond
mods = self[:build_config]['modules']
unless mods.length == 1
raise Requirejs::ConfigError, "Almond build requires exactly one module, config has #{mods.length}."
end
mod = mods[0]
name = mod['name']
mod['name'] = 'almond'
mod['include'] = name
end
end
self[:build_config]
end
Expand All @@ -131,6 +133,9 @@ def user_config=(cfg)
if url = cfg.delete('baseUrl')
raise Requirejs::ConfigError, "baseUrl is not needed or permitted in the configuration"
end
# delete any cached configs, will be lazily resolved
self.delete(:build_config)
self.delete(:run_config)
self[:user_config] = cfg
end

Expand Down

0 comments on commit 3c6d26e

Please sign in to comment.