forked from vakata/jstree
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gruntfile.js
106 lines (96 loc) · 2.88 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
/*global module:false, require:false, __dirname:false*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
dist: {
src: ['src/<%= pkg.name %>.js', 'src/<%= pkg.name %>.*.js'],
dest: 'dist/<%= pkg.name %>.js'
}
},
copy: {
dist : {
files : [
{ expand: true, cwd : 'src/themes/default/', src: ['*'], dest: 'dist/themes/default/' }
]
}
},
uglify: {
options: {
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %> - (<%= _.pluck(pkg.licenses, "type").join(", ") %>) */\n'
},
dist: {
src: ['<%= concat.dist.dest %>'],
dest: 'dist/<%= pkg.name %>.min.js'
}
},
qunit: {
files: ['test/**/*.html']
},
watch: {
files: '<config:lint.files>',
tasks: 'jshint qunit'
},
jshint: {
options: {
'curly' : true,
'eqeqeq' : true,
'latedef' : true,
'newcap' : true,
'noarg' : true,
'sub' : true,
'undef' : true,
'boss' : true,
'eqnull' : true,
'browser' : true,
'trailing' : true,
'globals' : {
'console' : true,
'jQuery' : true,
'browser' : true,
'XSLTProcessor' : true,
'ActiveXObject' : true
}
},
beforeconcat: ['src/**/*.js'],
afterconcat: ['dist/<%= pkg.name %>.js']
},
dox: {
files: {
src: ['src/*.js'],
dest: 'docs'
}
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-uglify');
//grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.registerMultiTask('dox', 'Generate dox output ', function() {
var exec = require('child_process').exec,
path = require('path'),
done = this.async(),
doxPath = path.resolve(__dirname),
formatter = [doxPath, 'node_modules', '.bin', 'dox'].join(path.sep),
str = grunt.file.read('dist/jstree.js');
str = str.replace(/^\s+\*/mg,'*');
str = str.replace(/^\s+\/\/ .*$/mg,'');
grunt.file.write('dist/jstree.dox.js', str);
exec(formatter + ' < "dist/jstree.dox.js" > "docs/jstree.json"', {maxBuffer: 5000*1024}, function(error, stout, sterr){
if (error) {
grunt.log.error(formatter);
grunt.log.error("WARN: "+ error);
grunt.file.delete('dist/jstree.dox.js');
}
if (!error) {
grunt.log.writeln('dist/jstree.js doxxed.');
grunt.file.delete('dist/jstree.dox.js');
done();
}
});
});
// Default task.
grunt.registerTask('default', ['jshint:beforeconcat','concat','jshint:afterconcat','copy','uglify',/*'qunit',*/'dox']);
};