1 |
|
2 |
|
3 |
|
4 |
|
5 | module.exports = function (grunt) {
|
6 |
|
7 | if (grunt.option('q') || grunt.option('quiet')) {
|
8 | require('quiet-grunt');
|
9 | }
|
10 |
|
11 |
|
12 | var config = {
|
13 | pkg: grunt.file.readJSON('package.json'),
|
14 |
|
15 | concat: {
|
16 | options: {
|
17 | sourceMap: true,
|
18 | banner: ';/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n(function(){\n',
|
19 | footer: '}).call(this);\n'
|
20 | },
|
21 | dist: {
|
22 | src: [
|
23 | 'src/options.js',
|
24 | 'src/showdown.js',
|
25 | 'src/helpers.js',
|
26 | 'src/converter.js',
|
27 | 'src/subParsers/*.js',
|
28 | 'src/loader.js'
|
29 | ],
|
30 | dest: 'dist/<%= pkg.name %>.js'
|
31 | },
|
32 | test: {
|
33 | src: '<%= concat.dist.src %>',
|
34 | dest: '.build/<%= pkg.name %>.js',
|
35 | options: {
|
36 | sourceMap: false
|
37 | }
|
38 | }
|
39 | },
|
40 |
|
41 | clean: ['.build/'],
|
42 |
|
43 | uglify: {
|
44 | options: {
|
45 | sourceMap: true,
|
46 | banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n'
|
47 | },
|
48 | dist: {
|
49 | files: {
|
50 | 'dist/<%= pkg.name %>.min.js': ['<%= concat.dist.dest %>']
|
51 | }
|
52 | }
|
53 | },
|
54 |
|
55 | endline: {
|
56 | dist: {
|
57 | files: {
|
58 | 'dist/<%= pkg.name %>.js': 'dist/<%= pkg.name %>.js',
|
59 | 'dist/<%= pkg.name %>.min.js': 'dist/<%= pkg.name %>.min.js'
|
60 | }
|
61 | }
|
62 | },
|
63 |
|
64 | jshint: {
|
65 | options: {
|
66 | jshintrc: '.jshintrc',
|
67 | reporterOutput: ''
|
68 | },
|
69 | files: [
|
70 | 'Gruntfile.js',
|
71 | 'src/**/*.js',
|
72 | 'test/**/*.js'
|
73 | ]
|
74 | },
|
75 |
|
76 | eslint: {
|
77 | options: {
|
78 | config: '.eslintrc.json'
|
79 | },
|
80 | target: [
|
81 | 'Gruntfile.js',
|
82 | 'src/**/*.js',
|
83 | 'test/**/*.js'
|
84 | ]
|
85 | },
|
86 |
|
87 | conventionalChangelog: {
|
88 | options: {
|
89 | changelogOpts: {
|
90 | preset: 'angular'
|
91 | }
|
92 | },
|
93 | release: {
|
94 | src: 'CHANGELOG.md'
|
95 | }
|
96 | },
|
97 |
|
98 | conventionalGithubReleaser: {
|
99 | release: {
|
100 | options: {
|
101 | auth: {
|
102 | type: 'oauth',
|
103 | token: process.env.GH_TOEKN
|
104 | },
|
105 | changelogOpts: {
|
106 | preset: 'angular'
|
107 | }
|
108 | }
|
109 | }
|
110 | },
|
111 |
|
112 | simplemocha: {
|
113 | node: {
|
114 | src: 'test/node/**/*.js',
|
115 | options: {
|
116 | globals: ['should'],
|
117 | timeout: 3000,
|
118 | ignoreLeaks: true,
|
119 | reporter: 'spec'
|
120 | }
|
121 | },
|
122 | karlcow: {
|
123 | src: 'test/node/testsuite.karlcow.js',
|
124 | options: {
|
125 | globals: ['should'],
|
126 | timeout: 3000,
|
127 | ignoreLeaks: false,
|
128 | reporter: 'spec'
|
129 | }
|
130 | },
|
131 | issues: {
|
132 | src: 'test/node/testsuite.issues.js',
|
133 | options: {
|
134 | globals: ['should'],
|
135 | timeout: 3000,
|
136 | ignoreLeaks: false,
|
137 | reporter: 'spec'
|
138 | }
|
139 | },
|
140 | standard: {
|
141 | src: 'test/node/testsuite.standard.js',
|
142 | options: {
|
143 | globals: ['should'],
|
144 | timeout: 3000,
|
145 | ignoreLeaks: false,
|
146 | reporter: 'spec'
|
147 | }
|
148 | },
|
149 | features: {
|
150 | src: 'test/node/testsuite.features.js',
|
151 | options: {
|
152 | globals: ['should'],
|
153 | timeout: 3000,
|
154 | ignoreLeaks: false,
|
155 | reporter: 'spec'
|
156 | }
|
157 | },
|
158 | single: {
|
159 | src: 'test/node/**/*.js',
|
160 | options: {
|
161 | globals: ['should'],
|
162 | timeout: 3000,
|
163 | ignoreLeaks: false,
|
164 | reporter: 'spec'
|
165 | }
|
166 | }
|
167 | }
|
168 | };
|
169 |
|
170 | grunt.initConfig(config);
|
171 |
|
172 | |
173 |
|
174 |
|
175 | grunt.loadNpmTasks('grunt-contrib-clean');
|
176 | grunt.loadNpmTasks('grunt-contrib-concat');
|
177 | grunt.loadNpmTasks('grunt-contrib-uglify');
|
178 | grunt.loadNpmTasks('grunt-simple-mocha');
|
179 | grunt.loadNpmTasks('grunt-endline');
|
180 | grunt.loadNpmTasks('grunt-contrib-jshint');
|
181 |
|
182 | |
183 |
|
184 |
|
185 | grunt.registerTask('generate-changelog', function () {
|
186 | 'use strict';
|
187 | grunt.loadNpmTasks('grunt-conventional-changelog');
|
188 | grunt.loadNpmTasks('grunt-conventional-github-releaser');
|
189 | grunt.task.run('conventionalChangelog');
|
190 | });
|
191 |
|
192 | |
193 |
|
194 |
|
195 | grunt.registerTask('lint', function () {
|
196 | 'use strict';
|
197 | grunt.loadNpmTasks('grunt-eslint');
|
198 | grunt.task.run('jshint', 'eslint');
|
199 | });
|
200 |
|
201 | |
202 |
|
203 |
|
204 | grunt.registerTask('performancejs', function () {
|
205 | 'use strict';
|
206 | var perf = require('./test/node/performance.js');
|
207 | perf.runTests();
|
208 | perf.generateLogs();
|
209 | });
|
210 |
|
211 | |
212 |
|
213 |
|
214 | grunt.registerTask('single-test', function (grep) {
|
215 | 'use strict';
|
216 | grunt.config.merge({
|
217 | simplemocha: {
|
218 | single: {
|
219 | options: {
|
220 | grep: grep
|
221 | }
|
222 | }
|
223 | }
|
224 | });
|
225 |
|
226 | grunt.task.run(['lint', 'concat:test', 'simplemocha:single', 'clean']);
|
227 | });
|
228 |
|
229 |
|
230 | |
231 |
|
232 |
|
233 | grunt.registerTask('test-old', ['concat:test', 'simplemocha:node', 'clean']);
|
234 |
|
235 | |
236 |
|
237 |
|
238 | grunt.registerTask('test', ['clean', 'lint', 'concat:test', 'simplemocha:node', 'clean']);
|
239 | grunt.registerTask('performance', ['concat:test', 'performancejs', 'clean']);
|
240 | grunt.registerTask('build', ['test', 'concat:dist', 'uglify', 'endline']);
|
241 | grunt.registerTask('prep-release', ['build', 'generate-changelog']);
|
242 |
|
243 |
|
244 | grunt.registerTask('default', ['test']);
|
245 | };
|