forked from bfricka/less-preview
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGruntfile.coffee
More file actions
116 lines (96 loc) · 3.21 KB
/
Gruntfile.coffee
File metadata and controls
116 lines (96 loc) · 3.21 KB
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
#global module:false
testacular = require 'testacular'
module.exports = (grunt) ->
banner = "/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - "
+ "<%= grunt.template.today(\"yyyy-mm-dd\") %>\n"
+ "<%= pkg.homepage ? \"* \" + pkg.homepage + \"\n\" : \"\" %>"
+ "* Copyright (c) <%= grunt.template.today(\"yyyy\") %> <%= pkg.author.name %>;"
+ " Licensed <%= _.pluck(pkg.licenses, \"type\").join(\", \") %> */"
grunt.loadNpmTasks "grunt-contrib-uglify"
# grunt.loadNpmTasks "grunt-contrib-concat"
grunt.loadNpmTasks "grunt-contrib-watch"
grunt.loadNpmTasks "grunt-contrib-jshint"
grunt.loadNpmTasks "grunt-contrib-coffee"
# Project configuration.
grunt.initConfig
pkg: "<json:package.json>"
meta:
banner: banner
coffee:
compile:
options:
bare: true
files:
"public/javascripts/less2css.js": "public/coffee/less2css.coffee"
"public/javascripts/lessVersions.js": "public/coffee/lessVersions.coffee"
"app.js": "app.coffee"
watch:
coffee:
files: [
"public/coffee/**/*.coffee"
"app.coffee"
]
tasks: ["coffee"]
js:
files: [
"./public/javascripts/less2css.js"
]
tasks: ["jshint", "uglify", "test"]
tests:
files: [
"./test/**/*.spec.coffee"
]
tasks: ["test"]
uglify:
less2css:
options:
mangle: false
files:
"public/javascripts/less2css.min.js": ["<banner:meta.banner>", "public/javascripts/less2css.js"]
jshint:
options:
"curly" : true
"eqeqeq" : true
"immed" : true
"latedef" : true
"newcap" : true
"noarg" : true
"sub" : true
"undef" : true
"boss" : true
"eqnull" : true
"browser" : true
"laxcomma" : true
"laxbreak" : true
"globals":
"CodeMirror" : true
"amplify" : true
"jQuery" : true
"hljs" : true
"less" : true
"$" : true
all: ["public/javascripts/less2css.js"]
# Default task.
grunt.registerTask "default", ["coffee", "jshint", "uglify", "test"]
grunt.registerTask "testserver", "start testacular server", ->
#Mark the task as async but never call done, so the server stays up
done = @async()
testacular.server.start configFile: "test/testacular.conf.js"
grunt.registerTask "test", "run tests (make sure server task is run first)", ->
done = @async()
grunt.util.spawn
cmd: (if process.platform is "win32" then "testacular.cmd" else "testacular")
args: ["run"]
, (error, result, code) ->
if error
grunt.warn
"Make sure the testacular server is online: run `grunt server`.\n" +
"Also make sure you have a browser open to http://localhost:8080/.\n" +
error.stdout + error.stderr
#the testacular runner somehow modifies the files if it errors(??).
#this causes grunt's watch task to re-fire itself constantly,
#unless we wait for a sec
setTimeout done, 1000
else
grunt.log.write result.stdout
done()