lib/tasks/bower.rake in bower-rails-0.3.1 vs lib/tasks/bower.rake in bower-rails-0.3.2
- old
+ new
@@ -35,13 +35,22 @@
end
end
end
end
+def get_bower_root_path
+ if defined?(Rails)
+ return Rails.root
+ else
+ return Dir.pwd
+ end
+end
+
def dsl_perform_command remove_components = true
- BowerRails::Dsl.config = {:root_path => Rails.root}
- dsl = BowerRails::Dsl.evalute(Rails.root.join("Jsfile"))
+ bower_root = get_bower_root_path
+ BowerRails::Dsl.config = {:root_path => bower_root}
+ dsl = BowerRails::Dsl.evalute(File.join(bower_root, "Jsfile"))
if remove_components
dsl.write_bower_json
puts "bower.js files generated"
end
@@ -53,19 +62,20 @@
end
end
#run the passed bower block in appropriate folders
def perform_command remove_components = true
+ bower_root = get_bower_root_path
#load in bower json file
- txt = File.read("#{Rails.root}/bower.json")
+ txt = File.read(File.join(bower_root, "bower.json"))
json = JSON.parse(txt)
["lib", "vendor"].each do |dir|
data = json[dir]
#check folder existence and create?
- dir = "#{Rails.root}/#{dir}/assets"
+ dir = File.join(bower_root, "dir", "assets")
FileUtils.mkdir_p dir unless File.directory? dir
#go in to dir to act
Dir.chdir(dir) do
#remove old components