forked from lepture/editor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGruntfile.js
More file actions
91 lines (86 loc) · 2.56 KB
/
Gruntfile.js
File metadata and controls
91 lines (86 loc) · 2.56 KB
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
var path = require('path');
module.exports = function(grunt) {
grunt.initConfig({
jshint: {
all: [
'Gruntfile.js',
'src/*.js'
],
options: {
"eqeqeq": true,
"forin": false,
"latedef": false,
"newcap": true,
"quotmark": false,
"undef": false,
"unused": false,
"trailing": true,
"lastsemic": true,
"asi": false,
"boss": true,
"expr": true,
"strict": false,
"es5": true,
"funcscope": true,
"loopfunc": true,
"multistr": true,
"proto": false,
"smarttabs": true,
"shadow": false,
"sub": true,
"passfail": false,
"node": true,
"white": false
}
},
generate: {
seajs: {
options: {
header: 'define(function(require, exports, module) {',
footer: [
'exports = module.exports = new Editor()',
'exports.Editor = Editor',
'});'
].join('\n')
},
filename: 'seajs/editor.js'
},
window: {
filename: 'js/editor.js'
}
}
});
grunt.registerTask('concat', function() {
var data = grunt.file.read('codemirror/codemirror.js');
data = data.replace('window.CodeMirror', 'var CodeMirror');
['overlay', 'xml', 'markdown', 'gfm'].forEach(function(name) {
data += '\n' + grunt.file.read('codemirror/' + name + '.js');
});
data += '\n' + grunt.file.read('src/editor.js');
grunt.file.write('tmp/editor.js', data);
});
grunt.registerMultiTask('generate', function() {
var options = this.options({
header: '(function(global) {',
footer: 'global.Editor = Editor;\n})(this);'
});
var data = grunt.file.read('tmp/editor.js');
data = [options.header, data, options.footer].join('\n');
grunt.file.write('build/' + this.data.filename, data);
});
grunt.registerTask('utils', function() {
var dir = 'icomoon/fonts';
grunt.file.recurse(dir, function(fpath) {
var fname = path.relative(dir, fpath);
grunt.file.copy(fpath, path.join('build', 'css', 'fonts', fname));
});
var data = grunt.file.read('icomoon/style.css');
data += grunt.file.read('src/paper.css');
data += grunt.file.read('src/editor.css');
grunt.file.write('build/css/editor.css', data);
grunt.file.copy('index.html', 'build/index.html');
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.registerTask('default', ['jshint']);
grunt.registerTask('transport', ['concat', 'generate', 'utils']);
};