bin/jsus in jsus-0.1.22 vs bin/jsus in jsus-0.2.0
- old
+ new
@@ -10,10 +10,12 @@
require "fileutils"
require 'choice'
start_time = Time.now
Choice.options do
+ header "Jsus version #{Jsus.version}"
+
option 'input_directory', :required => true do
short "-i"
long "--input-directory=DIRECTORY"
desc "Path to directory containing your package to compile."
end
@@ -77,28 +79,49 @@
short "-v"
long "--verbose"
desc "When verbose mode is enabled, some debug information is displayed. Defaults to false."
end
+ option "validate_with", :required => false do
+ default []
+ long "--validate-with *VALIDATORS"
+ desc "performs validation of the resulting source. " <<
+ "Available validators: mooforge"
+ end
end
compile_start_time = Time.now
Jsus.verbose = Choice.choices[:verbose]
pool_load_start_time = Time.now
pool = if Choice.choices[:dependencies]
Jsus::Pool.new(Choice.choices[:dependencies])
+else
+ Jsus::Pool.new
end
pool_load_finish_time = Time.now
package = Jsus::Package.new(Choice.choices[:input_directory], :pool => pool)
package.include_dependencies! if Choice.choices[:dependencies]
output_directory = Choice.choices[:output_directory]
package.compile(output_directory)
package.generate_scripts_info(output_directory) unless Choice.choices[:without_scripts_info]
package.generate_tree(output_directory) unless Choice.choices[:without_tree]
+# Validations
+validators_map = {"mooforge" => Jsus::Validator::Mooforge}
+Choice.choices[:validate_with].each do |validator_name|
+ if validator = validators_map[validator_name.downcase]
+ errors = validator.new(pool.sources.to_a & package.source_files.to_a).validation_errors
+ unless errors.empty?
+ puts "Validator found errors: "
+ errors.each {|e| puts " * #{e}"}
+ end
+ else
+ puts "No such validator: #{validator_name}"
+ end
+end
# Hack, hack, hack :[
if Choice.choices[:generate_includes]
root = Choice.choices[:generate_includes] == true ? Choice.choices[:output_directory] : Choice.choices[:generate_includes]
File.open(File.join(Choice.choices[:output_directory], "includes.js"), "w") do |f|