UNPKG

2.59 kBtext/coffeescriptView Raw
1path = require 'path'
2
3module.exports = (grunt) ->
4 require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks)
5
6 grunt.initConfig
7 pkg: grunt.file.readJSON('package.json')
8 regarde:
9 jasmine_node:
10 files: [
11 'src/**/*.coffee'
12 'spec/*.coffee'
13 'spec/**/*.json'
14 'spec/**/*.haml'
15 'spec/**/*.html'
16 ]
17 tasks: ['jasmine_node']
18 spawn: true
19 jasmine_node:
20 specNameMatcher: '_spec'
21 extensions: 'coffee'
22 projectRoot: '.'
23 replace:
24 version:
25 src: ['dist/compiler/hamlcoffee.js']
26 dest: 'dist/compiler/hamlcoffee.js'
27 replacements: [
28 {
29 from: "require('../package.json').version"
30 to: "'<%= pkg.version %>'"
31 }
32 ]
33 changelog:
34 src: ['CHANGELOG.md']
35 dest: 'CHANGELOG.md'
36 replacements: [
37 {
38 from: "## Master"
39 to: "## Version <%= pkg.version %>, <%= grunt.template.today('mmmm dd, yyyy') %>"
40 }
41 ]
42 uglify:
43 dist:
44 files:
45 'dist/compiler/hamlcoffee.min.js': ['dist/compiler/hamlcoffee.js']
46 shell:
47 commit:
48 command: "git commit package.json CHANGELOG.md dist/compiler/hamlcoffee.js dist/compiler/hamlcoffee.min.js -m 'Release <%= pkg.version %>'"
49 tag:
50 command: "git tag v<%= pkg.version %>"
51 push:
52 command: "git push --tags origin master"
53 publish:
54 command: "npm publish"
55
56 # Use a custom task for using the latest v1 version of Browserify,
57 # since I don't like the current contraints in v2 like the need to
58 # have the `.coffee` extension within the require and that all paths
59 # are absolute.
60 #
61 grunt.registerTask 'browserify', 'Create the browser distribution', ->
62 browserify = require('browserify')()
63 browserify.ignore '../package.json'
64 browserify.ignore 'coffee-script'
65 browserify.require "#{ __dirname }/src/haml-coffee.coffee"
66 browserify.require "#{ __dirname }/src/hamlc.coffee"
67 grunt.file.write 'dist/compiler/hamlcoffee.js', browserify.bundle()
68
69 grunt.registerTask 'watch', [
70 'regarde'
71 ]
72
73 grunt.registerTask 'test', [
74 'jasmine_node'
75 ]
76
77 grunt.registerTask 'dist', 'Create the browser distribution', [
78 'browserify'
79 'replace:version'
80 'uglify:dist'
81 ]
82
83 grunt.registerTask 'publish', 'Publish a new version', [
84 'jasmine_node'
85 'dist'
86 'replace:changelog'
87 'shell:commit'
88 'shell:tag'
89 'shell:push'
90 'shell:publish'
91 ]
92
93 grunt.registerTask 'default', ['watch']