-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCakefile
53 lines (42 loc) · 1.61 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
{exec} = require 'child_process'
path = require 'path'
fs = require 'fs'
{log, error} = console
{minify} = require './node_modules/uglify-js'
generateDoc = (done)->
dir = path.resolve './'
# Create a tmp directory
exec 'mktemp -d', (err, stdout, stderr)->
error err if err?
tmp = stdout.replace(/^\s*|\s*$/g, '')
# clone the git in that temp dir
exec "git clone #{dir} #{tmp}", (err, stdout, stderr)->
error err if err?
log stdout
# Change branch to gh-pages
exec "git checkout gh-pages", {cwd:tmp}, (err, stdout, stderr)->
error err if err?
log stdout
# Create doc
exec 'docco-husky timezonedetect.js', (err, stdout, stderr)->
error err if err?
log stdout
# Move the doc to the tmp dir
exec "cp #{dir}/docco-husky/* #{tmp} -r", (err, stdout, stderr)->
error err if err?
log stdout
# Commit to gh-pages
exec "git add . && git commit -am 'Generated automatically'", {cwd:tmp}, (err, stdout, stderr)->
error err if err?
log stdout
# Push to gh-pages
exec "git push origin gh-pages", {cwd:tmp}, (err, stdout, stderr)->
error err if err?
log stdout
task 'uglify', 'Uglify js file', ->
ugly = minify path.resolve('./timezonedetect.js')
fs.writeFile path.resolve('./timezonedetect.min.js'), ugly.code, (err)->
throw err if err
log 'Written!'
task 'doc', 'Generate doc in gh-pages branch', ->
generateDoc()