This repository has been archived by the owner on Jun 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.coffee
99 lines (96 loc) · 2.79 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
module.exports = ( grunt ) ->
pkg = grunt.file.readJSON "package.json"
info =
name: pkg.name.charAt(0).toUpperCase() + pkg.name.substring(1)
version: pkg.version
npmTasks = [
"grunt-contrib-coffee"
"grunt-contrib-uglify"
"grunt-contrib-concat"
"grunt-contrib-clean"
"grunt-contrib-copy"
"grunt-contrib-jasmine"
]
grunt.initConfig
repo: info
pkg: pkg
meta:
modules: "src/modules"
proc: "src/preprocessor"
temp: ".<%= pkg.name %>-cache"
concat:
coffee:
options:
process: ( src, filepath ) ->
return src.replace /@(NAME|VERSION)/g, ( text, key ) ->
return info[key.toLowerCase()]
files:
"<%= meta.temp %>/preprocessor.coffee": [
"<%= meta.proc %>/intro.coffee"
"<%= meta.proc %>/variables.coffee"
"<%= meta.proc %>/functions.coffee"
"<%= meta.proc %>/methods.coffee"
"<%= meta.proc %>/outro.coffee"
]
"<%= pkg.name %>.coffee": [
"src/intro.coffee"
"<%= meta.temp %>/preprocessor.coffee"
"src/variables.coffee"
"src/functions.coffee"
"<%= meta.modules %>/builtin.coffee"
"<%= meta.modules %>/global.coffee"
"<%= meta.modules %>/object.coffee"
"<%= meta.modules %>/array.coffee"
"<%= meta.modules %>/string.coffee"
"<%= meta.modules %>/date.coffee"
"src/outro.coffee"
]
js:
files: "<%= pkg.name %>.js": [
"build/intro.js"
"<%= meta.temp %>/<%= pkg.name %>.js"
"build/outro.js"
]
coffee:
options:
bare: true
separator: "\x20"
build:
src: "<%= pkg.name %>.coffee"
dest: "<%= meta.temp %>/<%= pkg.name %>.js"
uglify:
options:
banner: "/*!\n" +
" * <%= repo.name %> v<%= repo.version %>\n" +
" * <%= pkg.homepage %>\n" +
" *\n" +
" * Copyright Ourai Lin, http://ourai.ws/\n" +
" *\n" +
" * Date: <%= grunt.template.today('yyyy-mm-dd') %>\n" +
" */\n"
sourceMap: false
build:
src: "<%= pkg.name %>.js"
dest: "<%= pkg.name %>.min.js"
copy:
test:
expand: true
cwd: "."
src: ["**.js"]
dest: "test"
jasmine:
test:
src: "test/<%= pkg.name %>.js"
options:
specs: "test/*Spec.js"
grunt.loadNpmTasks task for task in npmTasks
grunt.registerTask "compile", [
"concat:coffee"
"coffee:build"
"concat:js"
"uglify"
]
grunt.registerTask "default", [
"compile"
"copy"
]