Add a version file and header to generated javascripts

abstract-chosen
Matthew Beale 2011-07-29 12:25:31 +02:00
parent b793dd3a61
commit 9e1e84f421
2 changed files with 20 additions and 3 deletions

View File

@ -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'

1
VERSION Normal file
View File

@ -0,0 +1 @@
0.9