forked from creatale/node-fv
/
Cakefile
35 lines (28 loc) · 1.23 KB
/
Cakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{spawn} = require 'child_process'
os = require 'os'
cmd = (name) ->
if os.platform() is 'win32' then name + '.cmd' else name
npm = cmd 'npm'
mocha = cmd 'mocha'
task 'build', 'Compile CoffeeScript', ->
coffee = __dirname + '/node_modules/coffeescript/bin/coffee'
spawn 'node', [coffee, '-b', '-o', 'lib', '-c', 'src'], {cwd: __dirname, stdio: 'inherit'}
task 'install', 'Install node.js packages', ->
spawn npm, ['install'], {cwd: '.', stdio: 'inherit'}
task 'update', 'Update node.js packages', ->
spawn npm, ['update'], {cwd: '.', stdio: 'inherit'}
task 'test', 'Run tests.', ->
mocha = spawn mocha, ['--reporter', 'spec', 'test/*.coffee'], {cwd: '.', stdio: 'inherit'}
mocha.on 'exit', (status) ->
return process.exit(status)
task 'test-cov', 'Run tests, generating a coverage report', ->
fs = require 'fs'
path = require 'path'
timestamp = (new Date()).toISOString().replace(/[:.]/g, '-')
filename = path.join 'test', 'log', 'cov-' + timestamp + '.log.html'
console.log 'Generating ' + filename
stream = fs.openSync filename, 'w'
mocha = spawn mocha, ['--require', './test/mocha.coverage.js', '--reporter', 'html-cov'],
{cwd: '.', stdio: ['ignore', stream, process.stderr]}
mocha.on 'exit', (status) ->
return process.exit(status)