-
Notifications
You must be signed in to change notification settings - Fork 32
/
gruntfile.coffee
143 lines (97 loc) · 5.03 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
###
hopsoft\screeps-statsd
Licensed under the MIT license
For full copyright and license information, please see the LICENSE file
@author Bryan Conrad <[email protected]>
@copyright 2016 Bryan Conrad
@link https://github.com/hopsoft/docker-graphite-statsd
@license http://choosealicense.com/licenses/MIT MIT License
###
module.exports = ( grunt ) ->
### ALIASES ###
jsonFile = grunt.file.readJSON # Read a json file
define = grunt.registerTask # Register a local task
log = grunt.log.writeln # Write a single line to STDOUT
### GRUNT CONFIGURATION ###
config =
# Define aliases for known fs locations
srcDir: 'src/' # CoffeeScript or other source files to be compiled or processed
tstDir: 'test/' # Project's tests
resDir: 'res/' # Static resources - images, text files, external deps etc.
docDir: 'docs/' # Automatically-generated or compiled documentation
srcFiles: ['<%= srcDir %>**/*.coffee', 'index.coffee']
tstFiles: '<%= tstDir %>**/*.test.coffee'
pkg: jsonFile 'package.json'
### TASKS DEFINITION ###
# grunt-contrib-watch: Run tasks on filesystem changes
watch:
options:
# Define default tasks here, then point targets' "tasks" attribute here: '<%= watch.options.tasks %>'
tasks: ['lint', 'test'] # Run these tasks when a change is detected
interrupt: true # Restarts any running tasks on next event
atBegin: true # Runs all defined watch tasks on startup
dateFormat: ( time ) -> log "Done in #{time}ms"
# Targets
gruntfile: # Watch the gruntfile for changes ( also dynamically reloads grunt-watch config )
files: 'gruntfile.coffee'
tasks: '<%= watch.options.tasks %>'
project: # Watch the project's source files for changes
files: ['<%= srcFiles %>', '<%= tstFiles %>']
tasks: '<%= watch.options.tasks %>'
# grunt-coffeelint: Lint CoffeeScript files
coffeelint:
options: jsonFile 'coffeelint.json'
# Targets
gruntfile: 'gruntfile.coffee' # Lint this file
project: ['<%= srcFiles %>', '<%= tstFiles %>'] # Lint application's project files
# grunt-mocha-cli: Run tests with Mocha framework
mochacli:
options:
reporter: 'spec' # This report is nice and human-readable
require: ['should'] # Run the tests using Should.js
compilers: ['coffee:coffee-script/register']
# Targets
project: # Run the project's tests
src: ['<%= tstFiles %>']
# grunt-codo: CoffeeScript API documentation generator
codo:
options:
title: 'screeps-statsd'
debug: false
inputs: ['<%= srcDir %>']
output: '<%= docDir %>'
# grunt-contrib-coffee: Compile CoffeeScript into native JavaScript
coffee:
# Targets
build: # Compile CoffeeScript into target build directory
expand: true
ext: '.js'
src: '<%= srcFiles %>'
dest: '<%= libDir %>'
# grunt-contrib-uglify: Compress and mangle JavaScript files
uglify:
# Targets
build:
files: [
expand: true
src: '<%= srcDir %>**/*.js'
]
# grunt-contrib-clean: Clean the target files & folders, deleting anything inside
clean:
# Targets
build: ['<%= srcDir %>**/*.js', 'index.js'] # Clean the build products
docs: ['<%= docDir %>']
###############################################################################
### CUSTOM FUNCTIONS ###
### GRUNT MODULES ###
# Loads all grunt tasks from devDependencies starting with "grunt-"
require( 'load-grunt-tasks' )( grunt )
### GRUNT TASKS ###
define 'lint', ['coffeelint']
define 'test', ['mochacli']
define 'docs', ['codo']
define 'build:dev', ['clean:build', 'lint', 'test', 'coffee:build']
define 'build', ['build:dev', 'uglify:build']
define 'default', ['build']
###############################################################################
grunt.initConfig config