-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGruntfile.js
82 lines (78 loc) · 3.15 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
require('shelljs/global');
module.exports = function (grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
files: [
"kive/*.js",
"kive/**/*.js"
],
options: {
freeze: true,
futurehostile: true,
ignores: [
"kive/**/*.min.js",
"kive/**/*.pack.js",
"kive/**/imagediff.js",
"kive/**/jsil8n.js",
"kive/**/jasmine.js",
"kive/**/jasmine-jquery.js",
"kive/**/system.js",
"kive/**/noxss.js",
"kive/pipeline/**/*.js",
"kive/pipeline/*.js",
"kive/sandbox/static/sandbox/PipelineRunTable.js",
"kive/sandbox/static/sandbox/view_run.js"
],
maxerr: 20,
nonbsp: true,
globals: {
jQuery: true,
"$": true,
"window": true,
"permissions": true
}
}
},
"regex-replace": {
inlinedpngs: {
src: ['kive/container/static/container/canvas/drydock_objects.ts'],
actions: [
{
name: 'inlinedpngs',
search: /\/\*inline ([^\*\r\n]+):\*\/"[^"\r\n]*"/g,
replace: function (match, p1) {
var filename = 'raw_assets/' + p1 + '.png';
if (!test('-e', filename)) {
grunt.fail.fatal('"' + filename + '" not found', 3);
} else {
if (which('base64')) {
var cmd = 'cat "' + filename + '" | ';
if (which('pngquant')) {
console.log('Inlining ' + p1 + ' using pngquant...');
cmd += 'pngquant -s1 - | ';
} else {
console.log('Inlining ' + p1 + '...');
}
cmd += 'base64';
img = exec(cmd, {silent: true}).stdout.replace(/\s/g, '');
} else {
console.log('Inlining ' + p1 + '...');
img = grunt.file.read(filename, {encoding: "base64"});
}
return "\/*inline " + p1 + ":*\/\"" + img + "\"";
}
}
}
]
}
}
});
// Load plugins
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-regex-replace');
// Default task(s).
grunt.registerTask('default', ['jshint']);
grunt.registerTask('pngicons', ['regex-replace']);
};