This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Cakefile
73 lines (60 loc) · 2 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
fs = require 'fs'
{spawn, exec} = require 'child_process'
{basename, join} = require 'path'
task 'build', "Build CoffeeScript source files", ->
coffee = spawn 'coffee', ['-cw', '-o', 'lib', 'src']
coffee.stdout.on 'data', (data) -> process.stderr.write data.toString()
task 'pretest', "Install test dependencies", ->
exec 'which ruby gem', (err) ->
throw "ruby not found" if err
exec 'ruby -rubygems -e \'require "rack"\'', (err) ->
if err
exec 'gem install rack', (err, stdout, stderr) ->
throw err if err
task 'test', "Run test suite", ->
process.chdir __dirname
{reporters} = require 'nodeunit'
reporters.default.run ['test']
task 'man', "Build manuals", ->
fs.readdir "doc/", (err, files) ->
for file in files when /\.md/.test file
source = join "doc", file
target = join "man", basename source, ".md"
exec "ronn --pipe --roff #{source} > #{target}", (err) ->
throw err if err
task 'pages', "Build pages", ->
{series, parallel} = require 'async'
sh = (command) -> (k) -> exec command, k
buildMan = (callback) ->
series [
(sh "cp README.md doc/index.md")
(sh "ronn -stoc -5 doc/*.md")
(sh "mv doc/*.html pages/")
(sh "rm doc/index.md")
], callback
buildAnnotations = (callback) ->
series [
(sh "docco src/**/*.coffee")
(sh "mv docs/* pages/annotations")
(sh "rm -rf docs/")
], callback
build = (callback) ->
parallel [buildMan, buildAnnotations], callback
checkoutBranch = (callback) ->
series [
(sh "rm -rf pages/")
(sh "git clone -q -b gh-pages [email protected]:josh/nack.git pages")
(sh "rm -rf pages/*")
], callback
publish = (callback) ->
series [
(sh "cd pages/ && git commit -am 'rebuild manual' || true")
(sh "cd pages/ && git push [email protected]:josh/nack.git gh-pages")
(sh "rm -rf pages/")
], callback
series [
checkoutBranch
(sh "mkdir -p pages/annotations")
build
publish
], (err) -> throw err if err