forked from IjzerenHein/kiwi.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
119 lines (116 loc) · 3.68 KB
/
Gruntfile.js
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
/*global module:false*/
/*eslint strict:false, quotes: [2, "single"] */
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
tslint: {
files: {
src: ['src/*.ts']
}
},
'string-replace': {
dist: {
files: {
'tmp/kiwi-no-internal-modules.js': 'lib/kiwi.js'
},
options: {
// Generating docs for compiled Typescript code isn't easy...
// The following replacements were needed for jsdoc2md to do
// its processing correctly.
replacements: [{
pattern: /\(function\s\(kiwi\)\s{/ig,
replacement: ''
}, {
pattern: /}\)\(kiwi\s\|\|\s\(kiwi\s=\s{}\)\);/ig,
replacement: ''
}, {
pattern: /\(function\s\(Operator\)\s{/ig,
replacement: 'var Operator;'
}, {
pattern: /}\)\(kiwi.Operator\s\|\|\s\(kiwi.Operator\s\=\s{}\)\);/ig,
replacement: ''
}, {
pattern: /\(function\s\(Strength\)\s{/ig,
replacement: ''
}, {
pattern: /}\)\(Strength\s\=\skiwi.Strength\s\|\|\s\(kiwi.Strength\s\=\s{}\)\);/ig,
replacement: ''
}, {
pattern: /function\screate\(a,\sb,\sc,\sw\)\s{/ig,
replacement: 'Strength.create = function(a, b, c, w) {'
}]
}
}
},
jsdoc2md: {
output: {
options: {
'global-index-format': 'none',
'module-index-format': 'none'
},
src: 'tmp/kiwi-no-internal-modules.js',
dest: 'docs/Kiwi.md'
}
},
exec: {
build: 'tsc --noImplicitAny -m commonjs -d -out lib/kiwi.js src/kiwi.ts',
test: 'mocha', // --compilers ts:typescript-require' // HR: can't get internal TS modules to work with typescript-require
bench: 'node bench/main.js'
},
concat: {
extras: {
src: ['thirdparty/tsu.js', 'lib/kiwi.js'],
dest: 'lib/kiwi.js',
},
},
umd: {
all: {
options: {
src: 'lib/kiwi.js',
objectToExport: 'kiwi'
}
}
},
uglify: {
dist: {
src: './lib/kiwi.js',
dest: './lib/kiwi.min.js'
}
},
usebanner: {
minified: {
options: {
position: 'top',
banner:
'/*-----------------------------------------------------------------------------\n' +
'| Copyright (c) 2014-2016, Nucleic Development Team & H. Rutjes.\n' +
'|\n' +
'| Distributed under the terms of the Modified BSD License.\n' +
'|\n' +
'| The full license is in the file COPYING.txt, distributed with this software.\n' +
'-----------------------------------------------------------------------------*/'
},
files: {
src: ['lib/kiwi.min.js']
}
}
}
});
// These plugins provide necessary tasks.
grunt.loadNpmTasks('grunt-jsdoc-to-markdown');
grunt.loadNpmTasks('grunt-tslint');
grunt.loadNpmTasks('grunt-banner');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-exec');
grunt.loadNpmTasks('grunt-umd');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-string-replace');
// Tasks
grunt.registerTask('lint', ['tslint']);
grunt.registerTask('doc', ['string-replace', 'jsdoc2md']);
grunt.registerTask('build', ['exec:build', 'doc', 'concat', 'umd']);
grunt.registerTask('test', ['build', 'exec:test']);
grunt.registerTask('bench', ['build', 'exec:bench']);
grunt.registerTask('minify', ['uglify', 'usebanner']);
grunt.registerTask('default', ['build', 'lint', 'minify', 'exec:test']);
};