snowflake/proxy/Cakefile
2019-05-08 11:23:49 -04:00

66 lines
1.7 KiB
CoffeeScript

fs = require 'fs'
{ exec, spawn, execSync } = require 'child_process'
# All coffeescript files required.
FILES = [
'shims.coffee'
'util.coffee'
'init.coffee'
'proxypair.coffee'
'websocket.coffee'
'broker.coffee'
'ui.coffee'
'snowflake.coffee'
]
FILES_SPEC = [
'spec/util.spec.coffee'
'spec/ui.spec.coffee'
'spec/broker.spec.coffee'
'spec/proxypair.spec.coffee'
'spec/snowflake.spec.coffee'
'spec/websocket.spec.coffee'
]
FILES_ALL = FILES.concat FILES_SPEC
OUTFILE = 'snowflake.js'
STATIC = 'static'
copyStaticFiles = ->
exec 'cp ' + STATIC + '/* build/'
compileCoffee = (outDir) ->
exec 'cat ' + FILES.join(' ') + ' | coffee -cs > ' + outDir + '/' + OUTFILE, (err, stdout, stderr) ->
throw err if err
task 'test', 'snowflake unit tests', ->
exec 'mkdir -p test'
exec 'jasmine init >&-'
# Simply concat all the files because we're not using node exports.
jasmineFiles = FILES_ALL
outFile = 'test/bundle.spec.coffee'
exec 'echo "TESTING = true" > ' + outFile
exec 'cat ' + jasmineFiles.join(' ') + ' | cat >> ' + outFile
execSync 'coffee -cb ' + outFile
proc = spawn 'jasmine', ['test/bundle.spec.js'], {
stdio: 'inherit'
}
proc.on "exit", (code) -> process.exit code
task 'build', 'build the snowflake proxy', ->
exec 'mkdir -p build'
copyStaticFiles()
compileCoffee('build')
console.log 'Snowflake prepared.'
task 'webext', 'build the webextension', ->
compileCoffee('webext')
console.log 'Webextension prepared.'
task 'lint', 'ensure idiomatic coffeescript', ->
proc = spawn 'coffeelint', FILES_ALL, {
file: 'coffeelint.json'
stdio: 'inherit'
}
proc.on "exit", (code) -> process.exit code
task 'clean', 'remove all built files', ->
exec 'rm -r build'