forked from Roll20/roll20-api-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGruntfile.js
98 lines (93 loc) · 2.5 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
'use strict';
module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('script.json'),
concat: {
dist: {
src: [
'src/index.js',
'src/Commands.js',
'src/Config.js',
'src/Events.js',
'src/Macros.js',
'src/Paths.js',
'src/State.js',
'src/Templates.js',
'src/Wizard.js',
'src/utils/index.js',
'src/utils/Chat.js',
'src/utils/Menu.js'
],
dest: '<%= pkg.version %>/<%= pkg.script %>'
}
},
jshint: {
dist: {
src: ['src/**/*.js']
},
options: {
eqeqeq: true,
esversion: 6,
freeze: true,
globals: {
// Symbols defined by API scripts
CustomStatusMarkers: true,
PathMath: false,
// Symbols defined by Roll20
_: false,
createObj: false,
findObjs: false,
getObj: false,
globalconfig: true,
playerIsGM: false,
log: false,
on: false,
sendChat: false,
state: true,
toBack: false,
toFront: false
},
nonbsp: true,
nonew: true,
strict: true,
undef: true,
unused: true
}
},
'string-replace': {
dist: {
files: {
'<%= pkg.version %>/<%= pkg.script %>': '<%= pkg.version %>/<%= pkg.script %>'
}
},
options: {
replacements: [
{
pattern: 'SCRIPT_VERSION',
replacement: '<%= pkg.version %>'
},
// Convert unicode characters to HTML entities.
{
pattern: /[\u{00FF}-\u{FFFFF}]/gu,
replacement: function(match) {
if (match.length === 2) {
let highSurrogate = match.charCodeAt(0);
let lowSurrogate = match.charCodeAt(1);
let astralCodePoint = (highSurrogate - 0xD800) * 0x400 + lowSurrogate - 0xDC00 + 0x10000;
return '&#' + astralCodePoint + ';';
}
else if (match.length === 1) {
let charCode = match.charCodeAt(0);
return '&#' + charCode + ';';
}
}
}
]
}
}
});
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-string-replace');
grunt.registerTask('default', ['jshint', 'concat', 'string-replace']);
};