-
Notifications
You must be signed in to change notification settings - Fork 2
/
Gruntfile.js
147 lines (124 loc) · 4.24 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
module.exports = function(grunt) {
'use strict';
var path = require('path'),
assert = require('assert');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
eslint: {
options: {
configFile: 'eslint.json'
},
src: [
'conkitty.js',
'parser.js',
'generator.js',
'types.js',
'errors.js',
'utils.js',
'bin/conkitty',
'Gruntfile.js'
]
},
/* eslint: {
all: {
src: [
'conkitty.js',
'parser.js',
'generator.js',
'types.js',
'errors.js',
'utils.js',
'bin/conkitty',
'Gruntfile.js'
],
options: {
jshintrc: '.jshintrc'
}
}
},*/
clean: {
tmp: ['tmp']
},
conkitty: {
test: {
files: {
'tmp/test.ctpl.js': [
'test/basic.ctpl',
'test/selectors.ctpl',
'test/nodes.ctpl',
'test/ret.ctpl',
'test/namespaces.ctpl',
'test/classes.ctpl',
'test/precompileexpr.ctpl'
]
}
}
},
uglify: {
options: {
preserveComments: 'some'
},
build: {
files: {
'tmp/test.ctpl.min.js': 'tmp/test.ctpl.js',
'tmp/test.common.min.js': 'tmp/test.common.js'
}
}
},
qunit: {
all: ['test/**/*.html']
}
});
grunt.loadNpmTasks('grunt-eslint');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.registerMultiTask('conkitty', function() {
var Conkitty = require(__dirname + '/conkitty.js');
this.files.forEach(function(f) {
var conkitty = new Conkitty({prop1: 100500, prop2: 'yo', prop3: 4});
f.src.map(function(filename) {
conkitty.push(path.resolve(filename));
});
conkitty.generate('test.ctpl.map');
assert.deepEqual(
conkitty.getIncludes(),
[
'test/includes/ns1_file1.css',
'test/includes/ns1_file1.js',
'test/includes/logo-img.png',
'test/includes/logo.png',
'test/includes/logo.css',
'test/includes/ns2_file1.css',
'test/includes/ns2_file1.js',
'test/includes/button.css',
'test/includes/textarea.css',
'test/includes/c.css',
'test/includes/file1.css',
'test/includes/file5yo.css'
].map(function(filename) { return path.normalize(path.join(__dirname, filename)); }),
'Incorrect test includes'
);
var common = f.dest.replace(/ctpl\.js$/, 'common.js'),
sourceMap = 'tmp/test.ctpl.map';
grunt.file.write(common, conkitty.getCommonCode());
grunt.log.writeln('File "' + common + '" created.');
grunt.file.write(f.dest, conkitty.getTemplatesCode());
grunt.log.writeln('File "' + f.dest + '" created.');
grunt.file.write(sourceMap, conkitty.getSourceMap());
grunt.log.writeln('File "' + sourceMap + '" created.');
});
});
grunt.registerTask('assert-version', function() {
var assertVersion = require('assert-version'),
error;
error = assertVersion({
'conkitty.js': ''
});
if (error) {
grunt.log.error(error);
return false;
}
});
grunt.registerTask('default', ['eslint', 'clean', 'assert-version', 'conkitty', 'uglify', 'qunit']);
};