forked from ai/transition-events
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Cakefile
48 lines (40 loc) · 1.85 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
fs = require('fs-extra')
exec = require('child_process').exec
path = require('path')
glob = require('glob')
uglify = require('uglify-js')
task 'clean', 'Remove all generated files', ->
fs.removeSync('build/') if path.existsSync('build/')
fs.removeSync('pkg/') if path.existsSync('pkg/')
task 'min', 'Create minimized version of library', ->
fs.mkdirSync('pkg/') unless path.existsSync('pkg/')
version = JSON.parse(fs.readFileSync('package.json')).version
source = fs.readFileSync('lib/transition-events.js').toString()
ast = uglify.parser.parse(source)
ast = uglify.uglify.ast_mangle(ast)
ast = uglify.uglify.ast_squeeze(ast)
min = uglify.uglify.gen_code(ast)
fs.writeFileSync("pkg/transition-events-#{version}.min.js", min)
task 'gem', 'Build RubyGem package', ->
fs.removeSync('build/') if path.existsSync('build/')
fs.mkdirSync('build/lib/assets/javascripts/')
copy = require('fs-extra/lib/copy').copyFileSync
fs.removeSync('build/') if path.existsSync('build/')
fs.mkdirSync('build/lib/assets/javascripts/')
copy = require('fs-extra/lib/copy').copyFileSync
copy('lib/transition-events.js',
'build/lib/assets/javascripts/transition-events.js')
copy('gem/transition-events-js.gemspec', 'build/transition-events-js.gemspec')
copy('gem/transition-events-js.rb', 'build/lib/transition-events-js.rb')
copy('README.md', 'build/README.md')
copy('ChangeLog', 'build/ChangeLog')
copy('LICENSE', 'build/LICENSE')
exec 'cd build/; gem build transition-events-js.gemspec', (error, message) ->
if error
process.stderr.write(error.message)
process.exit(1)
else
fs.mkdirSync('pkg/') unless path.existsSync('pkg/')
gem = glob.sync('build/*.gem')[0]
copy(gem, gem.replace(/^build\//, 'pkg/'))
fs.removeSync('build/')