0
0
Fork 0
mirror of https://gitlab.com/Oreolek/salet-module.git synced 2024-06-26 03:50:49 +03:00
salet-module/Cakefile

42 lines
1.2 KiB
CoffeeScript

fs = require 'fs'
{exec,spawn} = require 'child_process'
util = require 'util'
sources = [
'markdown.coffee'
'utils.coffee'
'view.coffee'
'unit.coffee'
'character.coffee'
'room.coffee'
'localize.coffee'
'random.coffee'
'salet.coffee'
]
sourcestring = ""
for source in sources
sourcestring += 'src/'+source+' '
task 'watch', 'Watch source files and build changes', ->
watch = spawn "coffee", ['-c', '-w', '--no-header', '-j', 'lib/index.js', sourcestring]
watch.stdout.on 'data', (data) -> console.log data.toString().trim()
task 'compile', 'Compile all CoffeeScript files', ->
# prepare lib directory
if not fs.existsSync 'lib'
fs.mkdirSync 'lib'
# run coffee-script compile
exec "cat #{sourcestring} | coffee --compile --stdio --no-header > lib/index.js", (err, stdout, stderr) ->
if err
util.log err
process.exit 1 # abort npm packaging
util.log "Compiled CoffeeScript."
task 'build', 'Compile and minify all CoffeeScript files', ->
invoke 'compile'
exec "closure-compiler --compilation_level ECMASCRIPT5 --compilation_level SIMPLE --js_output_file lib/index.min.js lib/index.js", (err) ->
if err
util.log err
process.exit 1 # abort npm packaging
util.log "Minified JavaScript."