-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathCakefile
50 lines (41 loc) · 1.99 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
{spawn, exec} = require 'child_process'
fs = require 'fs'
path = require 'path'
srcFolder = './src'
option '-w', '--watch' , 'continually build the docco files (in /docs'
option '-l', '--layout [LAYOUT]', 'specify the layout for Docco\'s docs'
option '-v', '--verbose' , 'show docco console out'
option '-p', '--publish' , 'auto commit and publish to github'
task 'doc', 'rebuild the Docco documentation', (options) ->
layout = options.layout or 'linear'
run_Task = ()->
console.time('docco built in')
commands = [ "node_modules/.bin/docco --layout #{layout} {#{srcFolder},test}/{**/*,*}"]
#"node_modules/.bin/docco --layout #{layout} #{srcFolder}/**/**.**"
#"node_modules/.bin/docco --layout #{layout} #{srcFolder}/**.**"]
#"sed \"s/docco.css/resources\\/#{layout}\\/docco.css/\" < docs/docco.html > index.html"
#'rm -r docs']
execResult = (err,stdout) ->
throw err if err
console.log stdout if options.verbose
(exec commands.join(' && '), execResult).on 'exit', ->
console.timeEnd 'docco built in'
if (options.publish)
console.time 'Committed and published to github in'
commands = [ "cd docs"
"git add ."
"git commit -m 'auto docs commit from cakefile' "
"git push origin gh-pages:gh-pages"
"cd .."]
(exec commands.join(' && '), execResult)
.on 'exit', (code)->
if (code is 0)
console.timeEnd 'Committed and published to github in'
if (options.watch)
console.log "Watching folder: #{srcFolder}"
fs.watch srcFolder, ()->
console.log "Folder watch on #{srcFolder} triggered"
run_Task()
process.on 'uncaughtException', (err)->
console.log err.toString() if err.toString() isnt 'Error: Command failed: ' #happens when ```git commit -m ``` is executed when no changes exist
run_Task()