-
Notifications
You must be signed in to change notification settings - Fork 51
/
Gruntfile.coffee
93 lines (85 loc) · 2.53 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
path = require 'path'
module.exports = (grunt) ->
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks)
grunt.initConfig
pkg: grunt.file.readJSON('package.json')
regarde:
jasmine_node:
files: [
'src/**/*.coffee'
'spec/*.coffee'
'spec/**/*.json'
'spec/**/*.haml'
'spec/**/*.html'
]
tasks: ['jasmine_node']
spawn: true
jasmine_node:
specNameMatcher: '_spec'
extensions: 'coffee'
projectRoot: '.'
replace:
version:
src: ['dist/compiler/hamlcoffee.js']
dest: 'dist/compiler/hamlcoffee.js'
replacements: [
{
from: "require('../package.json').version"
to: "'<%= pkg.version %>'"
}
]
changelog:
src: ['CHANGELOG.md']
dest: 'CHANGELOG.md'
replacements: [
{
from: "## Master"
to: "## Version <%= pkg.version %>, <%= grunt.template.today('mmmm dd, yyyy') %>"
}
]
uglify:
dist:
files:
'dist/compiler/hamlcoffee.min.js': ['dist/compiler/hamlcoffee.js']
shell:
commit:
command: "git commit package.json CHANGELOG.md dist/compiler/hamlcoffee.js dist/compiler/hamlcoffee.min.js -m 'Release <%= pkg.version %>'"
tag:
command: "git tag v<%= pkg.version %>"
push:
command: "git push --tags origin master"
publish:
command: "npm publish"
# Use a custom task for using the latest v1 version of Browserify,
# since I don't like the current contraints in v2 like the need to
# have the `.coffee` extension within the require and that all paths
# are absolute.
#
grunt.registerTask 'browserify', 'Create the browser distribution', ->
browserify = require('browserify')()
browserify.ignore '../package.json'
browserify.ignore 'coffee-script'
browserify.require "#{ __dirname }/src/haml-coffee.coffee"
browserify.require "#{ __dirname }/src/hamlc.coffee"
grunt.file.write 'dist/compiler/hamlcoffee.js', browserify.bundle()
grunt.registerTask 'watch', [
'regarde'
]
grunt.registerTask 'test', [
'jasmine_node'
]
grunt.registerTask 'dist', 'Create the browser distribution', [
'browserify'
'replace:version'
'uglify:dist'
]
grunt.registerTask 'publish', 'Publish a new version', [
'jasmine_node'
'dist'
'replace:changelog'
'shell:commit'
'shell:tag'
'shell:push'
'shell:publish'
]
grunt.registerTask 'default', ['watch']