lib/judojs/project.rb in judojs-0.9.2 vs lib/judojs/project.rb in judojs-0.9.3
- old
+ new
@@ -54,11 +54,12 @@
def update
get_modules
compile_modules
update_application_file
compress_application if @config.output == 'compressed'
- puts "#{@color_start}>>>#{@color_end} application updated"
+ puts "#{@color_start}>>>#{@color_end} application updated" unless @errors
+ @errors = false
end
def create_project_structure
Dir.mkdir "#{@project_path}" unless File.exists? "#{@project_path}"
@@ -73,14 +74,14 @@
:root => "#{Judojs.base_directory}",
:asset_root => "#{@config.asset_root}",
:load_path => ["repository"],
:source_files => ["repository/judojs/core/judo.js"]
)
-
+
judo_lib = judo_lib_secretary.concatenation
judo_lib.save_to "#{@project_path}lib/judo.js"
-
+
puts "lib/judo.js created"
end
def create_utility_lib_file
utility_lib_secretary = Sprockets::Secretary.new(
@@ -124,25 +125,31 @@
create_module_file module_file, module_filename
end
end
def create_module_file(module_file, module_name)
- module_src = "#{@project_path}modules/#{module_file}"
-
- judo_lib_secretary = Sprockets::Secretary.new(
- :root => "#{Judojs.base_directory}",
- :asset_root => "#{@config.asset_root}",
- :load_path => ["repository"],
- :source_files => ["#{module_src}"]
- )
+ begin
+ module_src = "#{@project_path}modules/#{module_file}"
- module_file = judo_lib_secretary.concatenation
- message = File.exists?("#{@project_path}application/#{module_name}.js") ? "application/#{module_name}.js updated" : "application/#{module_name}.js created"
- module_file.save_to "#{@project_path}application/#{module_name}.js"
- judo_lib_secretary.install_assets
+ judo_lib_secretary = Sprockets::Secretary.new(
+ :root => "#{Judojs.base_directory}",
+ :asset_root => "#{@config.asset_root}",
+ :load_path => ["repository"],
+ :source_files => ["#{module_src}"]
+ )
- #puts message
+ module_file = judo_lib_secretary.concatenation
+ message = File.exists?("#{@project_path}application/#{module_name}.js") ? "application/#{module_name}.js updated" : "application/#{module_name}.js created"
+ module_file.save_to "#{@project_path}application/#{module_name}.js"
+ judo_lib_secretary.install_assets
+
+ #puts message
+ rescue Exception => error
+ @errors = true
+ puts "Sprockets error: #{error.message}"
+ end
+
end
def update_application_file
message = File.exists?("#{@project_path}application/#{@app_filename}.js") ? "application/#{@app_filename}.js updated" : "application/#{@app_filename}.js created"
@@ -159,21 +166,24 @@
file << "\n//= require #{auto_file}\n" if auto_file.match(/^\<.+\>$/)
file << "\n//= require \"#{auto_file}\"\n" if auto_file.match(/^[^\<].+|[^\>]$/)
end
end
- judo_lib_secretary = Sprockets::Secretary.new(
- :root => "#{Judojs.base_directory}",
- :asset_root => "#{@config.asset_root}",
- :load_path => ["repository"],
- :source_files => ["#{filename}"]
- )
-
- application_file = judo_lib_secretary.concatenation
- judo_lib_secretary.install_assets
- application_file.save_to "#{filename}"
-
- #puts message
+ begin
+ judo_lib_secretary = Sprockets::Secretary.new(
+ :root => "#{Judojs.base_directory}",
+ :asset_root => "#{@config.asset_root}",
+ :load_path => ["repository"],
+ :source_files => ["#{filename}"]
+ )
+
+ application_file = judo_lib_secretary.concatenation
+ judo_lib_secretary.install_assets
+ application_file.save_to "#{filename}"
+ rescue Exception => error
+ @errors = true
+ puts "\e[0;31m!!!\e[0m Sprockets error: #{error.message}"
+ end
end
def compress_application
application = @project_path + 'application'
modules = Dir.entries(application)
\ No newline at end of file