diff --git a/Cakefile b/Cakefile index 8f0799c..cc58f0c 100644 --- a/Cakefile +++ b/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' diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..b63ba69 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.9