Skip to content
This repository
Browse code

Cakefile now reports more of what's going on.

  • Loading branch information...
commit a95a1c98baa73c3d0e0ffbff42594a5b381e2d71 1 parent 17c3656
Assaf Arkin authored

Showing 1 changed file with 26 additions and 15 deletions. Show diff stats Hide diff stats

  1. +26 15 Cakefile
41 Cakefile
@@ -2,6 +2,7 @@ fs = require("fs")
2 2 path = require("path")
3 3 {spawn, exec} = require("child_process")
4 4 markdown = require("node-markdown").Markdown
  5 +sys = require("sys")
5 6
6 7 # ANSI Terminal Colors.
7 8 bold = "\033[0;1m"
@@ -16,8 +17,8 @@ log = (message, color, explanation) ->
16 17 # Handle error, do nothing if null
17 18 onerror = (err)->
18 19 if err
19   - log err.stack, red
20   - process.exit -1
  20 + sys.puts "#{red}#{err.stack}#{reset}"
  21 + process.stdout.on "drain", -> process.exit -1
21 22
22 23
23 24 ## Setup ##
@@ -40,13 +41,15 @@ task "setup", "Install development dependencies", ->
40 41
41 42 build = (callback)->
42 43 log "Compiling CoffeeScript to JavaScript ...", green
43   - exec "rm -rf lib && coffee -c -l -b -o lib src", callback
  44 + exec "rm -rf lib && coffee -c -l -b -o lib src", (err, stdout)->
  45 + log stdout + "Done", green
  46 + callback err
44 47 task "build", "Compile CoffeeScript to JavaScript", -> build onerror
45 48
46 49 task "watch", "Continously compile CoffeeScript to JavaScript", ->
47 50 cmd = spawn("coffee", ["-cw", "-o", "lib", "src"])
48   - cmd.stdout.on "data", (data)-> log data, green
49   - cmd.stderr.on "data", (data)-> log data, red
  51 + cmd.stdout.on "data", (data)-> sys.print green + data + reset
  52 + cmd.on "error", onerror
50 53
51 54
52 55 task "clean", "Remove temporary files and such", ->
@@ -57,9 +60,8 @@ task "clean", "Remove temporary files and such", ->
57 60
58 61 runTests = (callback)->
59 62 log "Running test suite ...", green
60   - exec "vows --spec", (err, stdout, stderr)->
61   - log stdout, green
62   - log stderr, red
  63 + exec "vows --spec", (err, stdout)->
  64 + sys.puts stdout
63 65 callback err
64 66 task "test", "Run all tests", -> runTests onerror
65 67
@@ -75,7 +77,7 @@ toHTML = (source, title, callback)->
75 77 onerror err
76 78 fs.readFile source, "utf8", (err, text)->
77 79 onerror err
78   - log "Creating #{target} ...", green
  80 + log "Creating #{target}", green
79 81 exec "ronn --html #{source}", (err, stdout, stderr)->
80 82 onerror err
81 83 title ||= stdout.match(/<h1>(.*)<\/h1>/)[1]
@@ -93,13 +95,15 @@ documentPages = (callback)->
93 95 onerror err
94 96 toHTML "CHANGELOG.md", null, (err)->
95 97 onerror err
  98 + sys.puts ""
96 99 exec "cp -f doc/*.css html/", callback
97 100
98 101 documentSource = (callback)->
99 102 log "Documenting source files ...", green
100   - exec "docco src/*.coffee src/**/*.coffee", (err)->
  103 + exec "docco src/*.coffee src/**/*.coffee", (err, stdout, stderr)->
  104 + log stdout, green
101 105 onerror err
102   - log "Copying to html/source ...", green
  106 + log "Copying to html/source", green
103 107 exec "mkdir -p html && cp -rf docs/ html/source && rm -rf docs", callback
104 108
105 109 generateMan = (callback)->
@@ -107,6 +111,7 @@ generateMan = (callback)->
107 111 fs.mkdir "man1", 0777, ->
108 112 exec "ronn --roff README.md", (err, stdout, stderr)->
109 113 onerror err
  114 + log "Done", green
110 115 fs.writeFile "man1/zombie.1", stdout, "utf8", callback
111 116
112 117 generateDocs = (callback)->
@@ -129,7 +134,9 @@ publishDocs = (callback)->
129 134 generateDocs (err)->
130 135 onerror err
131 136 log "Uploading documentation ...", green
132   - exec "rsync -cr --del --progress html/ labnotes.org:/var/www/zombie/", callback
  137 + exec "rsync -cr --del --progress html/ labnotes.org:/var/www/zombie/", (err, stdout, stderr)->
  138 + log stdout, green
  139 + callback err
133 140 task "doc:publish", "Publish documentation to site", -> publishDocs onerror
134 141
135 142 task "publish", "Publish new version (Git, NPM, site)", ->
@@ -138,13 +145,17 @@ task "publish", "Publish new version (Git, NPM, site)", ->
138 145 fs.readFile "package.json", "utf8", (err, package)->
139 146 version = JSON.parse(package).version
140 147 log "Tagging v#{version} ...", green
141   - exec "git tag v#{version}", ->
142   - exec "git push --tags origin master"
  148 + exec "git tag v#{version}", (err, stdout, stderr)->
  149 + log stdout, green
  150 + exec "git push --tags origin master", (err, stdout, stderr)->
  151 + log stdout, green
143 152
144 153 log "Publishing to NPM ...", green
145 154 build (err)->
146 155 onerror err
147   - exec "npm publish ./", onerror
  156 + exec "npm publish ./", (err, stdout, stderr)->
  157 + log stdout, green
  158 + onerror err
148 159
149 160 # Publish documentation
150 161 publishDocs onerror

0 comments on commit a95a1c9

Please sign in to comment.
Something went wrong with that request. Please try again.