forked from gka/chroma.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
84 lines (76 loc) · 2 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
"use strict";
var fs = require('fs'),
pkgInfo = JSON.parse(fs.readFileSync(__dirname + '/package.json'));
module.exports = function(grunt) {
grunt.initConfig({
clean: {
pre: [
'chroma.js',
'chroma.min.js',
'license.coffee',
],
post: ['chroma.coffee']
},
coffee: {
compile: {
options: {
join: true
},
files: {
'chroma.js': [
'license.coffee',
'chroma.coffee'
],
},
}
},
replace: {
dist: {
options: { patterns: [{ match: 'version', replacement: pkgInfo.version }] },
files: [{expand: true, flatten: true, src: ['chroma.js'], dest: '.'}]
}
},
uglify: {
options: {
banner: "/*\n" + fs.readFileSync("LICENSE", {encoding: "utf8"}) + "\n*/\n",
},
my_target: {
files: {
'chroma.min.js': ['chroma.js']
},
},
},
copy: {
main: {
files: [
// copy build files into docs folder
{expand: true, src: ['chroma*.js'], dest: 'docs/libs/', filter: 'isFile'},
],
},
},
});
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-coffee');
grunt.loadNpmTasks('grunt-replace');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.registerTask('license', function() {
var license = [
"###*",
" * @license",
" *",
].concat(fs.readFileSync('LICENSE', {encoding: "utf8"}).split("\n").map(function(line) {
return " * " + line;
}));
license.push("###\n");
fs.writeFileSync('license.coffee', license.join("\n"));
});
grunt.registerTask('catty', function() {
require("catty")({ global: true })
.coffee(true)
.addLibrary("src")
.cat("src/index.coffee", "./chroma.coffee");
});
grunt.registerTask('default', ['clean:pre', 'license', 'catty', 'coffee', 'replace',
'uglify', 'copy', 'clean:post']);
};