Permalink
Browse files

Added watchr script to auto-generate file

  • Loading branch information...
1 parent b08cd7e commit eb56adc809917e59f1b61c46c1196544a946bd9a @avdgaag committed Apr 6, 2011
Showing with 17 additions and 0 deletions.
  1. +17 −0 watch.rb
View
17 watch.rb
@@ -0,0 +1,17 @@
+def expand_requirements(path)
+ File.read(path).gsub(%r{^([ \t]*)// require '([^']+)'$}) do |m|
+ [m, indent(expand_requirements(File.join(File.dirname(path), $2 + '.js')), $1)].join("\n")
+ end
+end
+
+def indent(string, whitespace)
+ string.gsub(/^/, whitespace)
+end
+
+watch('lib/mutil/(.+)\.js') do
+ File.open('lib/mutil.js', 'w') do |f|
+ f.write expand_requirements('lib/mutil/base.js')
+ end
+ print "\r-- Compiled lib/mutil.js [#{Time.now}]"
+ STDOUT.flush
+end

0 comments on commit eb56adc

Please sign in to comment.