-
Notifications
You must be signed in to change notification settings - Fork 391
/
Cakefile
61 lines (56 loc) · 2.06 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
fs = require 'fs'
browserify = require 'browserify'
UglifyJS = require 'uglify-js'
Promise = require 'bluebird'
{spawn, exec} = require 'child_process'
util = require 'util'
writeFile = (dest, src) ->
new Promise (resolve, reject) ->
fs.writeFile dest, src, ->
fs.stat dest, (err, stats) ->
return reject(err) if err?
console.log "Wrote #{dest} - #{Math.round(stats.size / 1024)}KB"
resolve()
task 'compile-browser', 'Compile with browserify for the web', ->
browserify
noParse: [
'fs'
]
.transform('coffeeify')
.require('./shims/png.coffee', expose: './image_exports/png.coffee')
.require('./shims/init.coffee', expose: './psd/init.coffee')
.require('./lib/psd.coffee', expose: 'psd')
.bundle (err, src, map) ->
return console.log(err) if err?
writeFile('./dist/psd.js', src)
.then ->
minSrc = UglifyJS.minify './dist/psd.js',
outSourceMap: 'psd.js.map'
sourceRoot: '/'
writeFile './dist/psd.min.js', minSrc.code
minSrc
.then (minSrc) ->
writeFile './dist/psd.js.map', minSrc.map
.then ->
console.log 'Finished!'
task 'docs:generate', 'Generate documentation', ->
npm = spawn 'npm', ['run-script', 'docs']
npm.stdout.pipe(process.stdout)
npm.stderr.pipe(process.stderr)
task 'docs:deploy', 'Deploys updated documentation to GitHub Pages', ->
console.log 'Switching to gh-pages'
exec 'git checkout gh-pages', (err) ->
return console.log(err) if err?
console.log 'Checking out docs from master'
exec 'git checkout master docs', (err) ->
return console.log(err) if err?
console.log 'Committing new documentation'
exec 'git commit -a -m "Update documentation"', (err) ->
return console.log(err) if err?
console.log 'Pushing to GitHub...'
exec 'git push origin gh-pages', (err) ->
return console.log(err) if err?
console.log 'Switching back to master'
exec 'git checkout master', (err) ->
return console.log(err) if err?
console.log 'Deployed!'