-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.coffee
99 lines (87 loc) · 2.14 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
'use strict'
module.exports = (grunt)->
# load all grunt tasks
(require 'matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks)
_ = grunt.util._
path = require 'path'
# Project configuration.
grunt.initConfig
pkg: grunt.file.readJSON 'package.json'
connect:
server:
options:
port: 1337
keepalive: false # Keep it false so watch can work
copy:
main:
files: [
expand: true
src: ['**']
cwd: 'src/templates'
dest: 'app/'
]
exec: cram: 'npm run cram'
coffeelint:
gruntfile:
src: '<%= watch.gruntfile.files %>'
app:
src: '<%= watch.app.files %>'
options:
no_trailing_whitespace:
level: 'error'
max_line_length:
level: 'warn'
coffee:
app:
expand: true
cwd: 'src/'
src: ['**/*.coffee']
filter: (filepath) -> not filepath.match /^templates/
dest: 'app'
ext: '.js'
watch:
options:
spawn: false
gruntfile:
files: 'Gruntfile.coffee'
tasks: ['coffeelint:gruntfile']
app:
files: ['src/**/*.coffee']
tasks: ['coffeelint:app', 'coffee:app']
templates:
files: ['src/templates/**']
tasks: ['copy']
theme:
files: ['theme/**/*.css']
clean: ['app', '.cram', 'test']
grunt.event.on 'watch', (action, files, target)->
grunt.log.writeln "#{target}: #{files} has #{action}"
# coffeelint
grunt.config ['coffeelint', target], src: files
# coffee
if coffeeData = grunt.config ['coffee', target]
files = [files] if _.isString files
console.log "WTF?", coffeeData
files = files.map (file)-> path.relative coffeeData.cwd, file
coffeeData.src = files
grunt.config ['coffee', target], coffeeData
# tasks.
grunt.registerTask 'compile', [
'coffeelint'
'coffee'
]
grunt.registerTask 'default', [
'compile'
'copy'
]
grunt.registerTask 'cram', [
'compile'
'copy'
'exec'
]
grunt.registerTask 'start', [
'compile'
'copy'
'connect'
'watch'
]