-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGruntfile.coffee
106 lines (86 loc) · 2.81 KB
/
Gruntfile.coffee
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
module.exports = (grunt) ->
grunt.loadNpmTasks 'grunt-contrib-connect'
grunt.loadNpmTasks 'grunt-contrib-coffee'
grunt.loadNpmTasks 'grunt-contrib-jasmine'
grunt.loadNpmTasks 'grunt-contrib-watch'
grunt.loadNpmTasks 'grunt-contrib-uglify'
grunt.loadNpmTasks 'grunt-coffeelint'
grunt.loadNpmTasks 'grunt-release'
grunt.initConfig
watch:
source:
files: ['src/**/*.coffee']
tasks: ['coffee:source']
specs:
files: ['spec/**/*.coffee']
tasks: ['coffee:specs']
coffee:
source:
files:
'lib/loada.js': 'src/loada.coffee'
specs:
expand: true
src: ["spec/**/*.coffee"]
dest: '.grunt'
ext: '.js'
coffeelint:
source:
files:
src: ['src/**/*.coffee']
options:
'max_line_length':
level: 'ignore'
connect:
specs:
options:
port: 8888
release:
options:
bump: false
add: false
commit: false
push: false
jasmine:
core:
options:
host: 'http://localhost:8888/'
keepRunner: true
outfile: "index.html"
vendor: 'components/sinonjs/sinon.js'
specs: ".grunt/spec/**/*_spec.js"
helpers: ".grunt/spec/helpers/**/*.js"
src: "lib/loada.js"
uglify:
core:
files:
'lib/loada.min.js': 'lib/loada.js'
grunt.registerTask 'default', ['coffee', 'connect', 'jasmine:core:build', 'watch']
grunt.registerTask 'test', ['coffee', 'connect', 'coffeelint', 'jasmine', 'bowerize']
grunt.registerTask 'publish', ['test', 'publish:ensureCommits', 'release', 'publish:gem']
grunt.registerTask 'bowerize', ->
bower = require './bower.json'
meta = require './package.json'
bower.version = meta.version
require('fs').writeFileSync 'bower.json', JSON.stringify(bower, null, 2)
grunt.registerTask 'publish:ensureCommits', ->
complete = @async()
grunt.util.spawn {cmd: "git", args: ["status", "--porcelain" ]}, (error, result) ->
if !!error || result.stdout.length > 0
console.log ""
console.log "Uncommited changes found. Please commit prior to release or use `--force`.".bold
console.log ""
complete false
else
complete true
grunt.registerTask 'publish:gem', ->
meta = require './package.json'
complete = @async()
grunt.util.spawn {cmd: "gem", args: ["build", "loada.gemspec"]}, (error, result) ->
return complete false if error
gem = "loada-#{meta.version.replace('-', '.')}.gem"
grunt.log.ok "Built #{gem}"
grunt.util.spawn {cmd: "gem", args: ["push", gem]}, (error, result) ->
return complete false if error
grunt.log.ok "Published #{gem}"
grunt.file.delete gem
complete(true)