Permalink
Browse files

Add a version file and header to generated javascripts

  • Loading branch information...
1 parent b793dd3 commit 9e1e84f421694cc55cb881515ba96a7beb0375a8 @mixonic mixonic committed Jul 29, 2011
Showing with 20 additions and 3 deletions.
  1. +19 −3 Cakefile
  2. +1 −0 VERSION
View
22 Cakefile
@@ -34,16 +34,32 @@ source_files = ->
all_sources.push source
all_sources.unique()
+# Get the version number
+#
+version = ->
+ "#{fs.readFileSync('VERSION')}".replace /[^0-9a-zA-Z.]*/gm, ''
+
+# Write chosen files with a header
+#
+write_chosen_javascript = (filename, body) ->
+ fs.writeFileSync filename, """
+// Chosen #{version()} https://github.com/harvesthq/chosen
+// Copyright (c) 2011 Harvest http://getharvest.com
+// MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
+// This file is generated by `cake build`, do not edit it by hand.
+#{body}
+"""
+
# Build Chosen.
#
task 'build', 'build Chosen from source', build = (cb) ->
for javascript, sources of javascripts
code = ''
for source in sources
- code += CoffeeScript.compile "\n#{fs.readFileSync source}"
- fs.writeFileSync javascript, code
+ code += CoffeeScript.compile "#{fs.readFileSync source}"
+ write_chosen_javascript javascript, code
unless process.env.MINIFY is 'false'
- fs.writeFileSync javascript.replace(/\.js$/,'.min.js'), (
+ write_chosen_javascript javascript.replace(/\.js$/,'.min.js'), (
uglify.gen_code uglify.ast_squeeze uglify.ast_mangle parser.parse code
)
cb() if typeof cb is 'function'
View
1 VERSION
@@ -0,0 +1 @@
+0.9

0 comments on commit 9e1e84f

Please sign in to comment.