Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Auto-remove the comments from the source when packaging

  • Loading branch information...
commit dfe11af4a9679aac2e12892333b83a1aedecafb8 1 parent 7626f81
@jonleighton authored
Showing with 15 additions and 7 deletions.
  1. +12 −4 Rakefile
  2. +3 −3 jquery.date_input.js
View
16 Rakefile
@@ -11,10 +11,11 @@ class PackageGenerator
def generate
delete_previous
copy_files
- write_header
+ process_code
pack_js
minify_js
compress
+ ensure
clean_up
end
@@ -24,13 +25,20 @@ class PackageGenerator
def copy_files
FileUtils.mkdir package_dir
- FileUtils.cp root_files("date_input.css", "LICENCE", "README", "CHANGELOG", "NOTES"), package_dir
+ FileUtils.cp root_files("date_input.css", "LICENCE", "README", "CHANGELOG"), package_dir
end
- def write_header
+ def process_code
+ code = File.read(root_file(plugin_file))
+
+ code.gsub!(/\/\/[^\n]+/, "") # Remove any other '//' comments (without deleting the line)
+ code.gsub!(/\/\*.+\*\//m, "") # Remove '/* */' comments
+
+ code.gsub!(/(\n +\n)( +\n)+/) { $1 } # Remove any multiple empty lines
+
open(package_file(plugin_file), "w") do |file|
file << header
- file << File.read(root_file(plugin_file))
+ file << code
end
end
View
6 jquery.date_input.js
@@ -292,10 +292,10 @@ DateInput.prototype = {
return (end - start) / 86400000;
},
- // changeDayTo: Given a date, move along the date line in the given direction until we reach the
- // desired day of week.
-
/*
+ changeDayTo: Given a date, move along the date line in the given direction until we reach the
+ desired day of week.
+
The maths is a bit complex, here's an explanation.
Think of a continuous repeating number line like:
Please sign in to comment.
Something went wrong with that request. Please try again.