-
Notifications
You must be signed in to change notification settings - Fork 6
/
Gruntfile.coffee
72 lines (57 loc) · 1.76 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
fs = require "fs"
module.exports = (grunt) ->
# ===== Directories =====
TEST_DIR = "test"
PUBLIC_DIR = "#{TEST_DIR}/public"
BIN_DIR = "node_modules/.bin"
DIST_DIR = "dist"
# ===== Files =====
VERSION_FILE = "VERSION"
VERSION = fs.readFileSync(VERSION_FILE)
PEGCOFFEE_DIST_FILE_DEV = "#{DIST_DIR}/pegjs-coffee-plugin-#{VERSION}.js"
PEGCOFFEE_DIST_FILE_MIN = "#{DIST_DIR}/pegjs-coffee-plugin-#{VERSION}.min.js"
LICENSE_FILE = "LICENSE"
CHANGELOG_FILE = "CHANGELOG.md"
README_FILE = "README.md"
require("load-grunt-tasks")(grunt)
grunt.registerTask "default", "build", ["build"]
grunt.registerTask "build", "build", ["browserify"]
grunt.registerTask "test", "test", ["mochaTest"]
grunt.registerTask "test-browser" ,"test in browser", ["build", "copy:browser", "http-server"]
grunt.registerTask "dist", "dist", ["build", "uglify"]
grunt.registerTask "distclean", "dist clean", ["clean"]
pkg = grunt.file.readJSON "package.json"
grunt.initConfig
pkg: pkg
browserify:
build:
src: "index.js"
dest: PEGCOFFEE_DIST_FILE_DEV
options:
browserifyOptions:
standalone: "PEGjs-coffee-plugin"
mochaTest:
test:
options:
reporter: "spec"
require: "coffee-script/register"
ui: "tdd"
src: ["test/*.js"]
copy:
browser:
src: PEGCOFFEE_DIST_FILE_DEV
dest: "#{PUBLIC_DIR}/pegjs-coffee-plugin.js"
"http-server":
"test-browser":
root: TEST_DIR
port: 3000
host: "localhost"
openBrowser: true
uglify:
dist:
src: PEGCOFFEE_DIST_FILE_DEV
dest: PEGCOFFEE_DIST_FILE_MIN
options:
ASCIIOnly: true
clean:
distclean: [DIST_DIR]