Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 6ad873f

Browse files
committed
chore: update gruntfile with ES6
- Add some ES6 usage in the gruntfile Closes #5179
1 parent 84bb118 commit 6ad873f

File tree

1 file changed

+21
-25
lines changed

1 file changed

+21
-25
lines changed

Diff for: Gruntfile.js

+21-25
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@ module.exports = function(grunt) {
2222
cssInclude: '',
2323
cssFileBanner: '/* Include this file in your html if you are using the CSP mode. */\n\n',
2424
cssFileDest: '<%= dist %>/<%= filename %>-<%= pkg.version %>-csp.css',
25-
banner: ['/*',
26-
' * <%= pkg.name %>',
27-
' * <%= pkg.homepage %>\n',
28-
' * Version: <%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>',
29-
' * License: <%= pkg.license %>',
30-
' */\n'].join('\n')
25+
banner: `/*
26+
* <%= pkg.name %>
27+
* <%= pkg.homepage %>
28+
29+
* Version: <%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>
30+
* License: <%= pkg.license %>
31+
*/
32+
`
3133
},
3234
delta: {
3335
docs: {
@@ -219,10 +221,10 @@ module.exports = function(grunt) {
219221
});
220222
}
221223
function enquote(str) {
222-
return '"' + str + '"';
224+
return `"${str}"`;
223225
}
224226
function enquoteUibDir(str) {
225-
return enquote('uib/' + str);
227+
return enquote(`uib/${str}`);
226228
}
227229

228230
var module = {
@@ -237,9 +239,7 @@ module.exports = function(grunt) {
237239
dependencies: dependenciesForModule(name),
238240
docs: {
239241
md: grunt.file.expand(`src/${name}/docs/*.md`)
240-
.map(grunt.file.read).map(function(str) {
241-
return marked(str);
242-
}).join('\n'),
242+
.map(grunt.file.read).map((str) => marked(str)).join('\n'),
243243
js: grunt.file.expand(`src/${name}/docs/*.js`)
244244
.map(grunt.file.read).join('\n'),
245245
html: grunt.file.expand(`src/${name}/docs/*.html`)
@@ -301,19 +301,17 @@ module.exports = function(grunt) {
301301
} else {
302302
grunt.file.expand({
303303
filter: 'isDirectory', cwd: '.'
304-
}, 'src/*').forEach(function(dir) {
304+
}, 'src/*').forEach((dir) => {
305305
findModule(dir.split('/')[1]);
306306
});
307307
}
308308

309309
var modules = grunt.config('modules');
310310
grunt.config('srcModules', _.pluck(modules, 'moduleName'));
311-
grunt.config('tplModules', _.pluck(modules, 'tplModules').filter(function(tpls) { return tpls.length > 0;} ));
311+
grunt.config('tplModules', _.pluck(modules, 'tplModules').filter((tpls) => tpls.length > 0));
312312
grunt.config('demoModules', modules
313-
.filter(function(module) {
314-
return module.docs.md && module.docs.js && module.docs.html;
315-
})
316-
.sort(function(a, b) {
313+
.filter((module) => module.docs.md && module.docs.js && module.docs.html)
314+
.sort((a, b) => {
317315
if (a.name < b.name) { return -1; }
318316
if (a.name > b.name) { return 1; }
319317
return 0;
@@ -332,9 +330,7 @@ module.exports = function(grunt) {
332330
}
333331

334332
var moduleFileMapping = _.clone(modules, true);
335-
moduleFileMapping.forEach(function (module) {
336-
delete module.docs;
337-
});
333+
moduleFileMapping.forEach((module) => delete module.docs);
338334

339335
grunt.config('moduleFileMapping', moduleFileMapping);
340336

@@ -350,14 +346,14 @@ module.exports = function(grunt) {
350346
grunt.task.run(['concat', 'uglify', 'makeModuleMappingFile', 'makeRawFilesJs', 'makeVersionsMappingFile']);
351347
});
352348

353-
grunt.registerTask('test', 'Run tests on singleRun karma server', function () {
349+
grunt.registerTask('test', 'Run tests on singleRun karma server', function() {
354350
//this task can be executed in 3 different environments: local, Travis-CI and Jenkins-CI
355351
//we need to take settings for each one into account
356352
if (process.env.TRAVIS) {
357353
grunt.task.run('karma:travis');
358354
} else {
359355
var isToRunJenkinsTask = !!this.args.length;
360-
if(grunt.option('coverage')) {
356+
if (grunt.option('coverage')) {
361357
var karmaOptions = grunt.config.get('karma.options'),
362358
coverageOpts = grunt.config.get('karma.coverage');
363359
grunt.util._.extend(karmaOptions, coverageOpts);
@@ -367,7 +363,7 @@ module.exports = function(grunt) {
367363
}
368364
});
369365

370-
grunt.registerTask('makeModuleMappingFile', function () {
366+
grunt.registerTask('makeModuleMappingFile', function() {
371367
var _ = grunt.util._;
372368
var moduleMappingJs = 'dist/assets/module-mapping.json';
373369
var moduleMappings = grunt.config('moduleFileMapping');
@@ -377,7 +373,7 @@ module.exports = function(grunt) {
377373
grunt.log.writeln('File ' + moduleMappingJs.cyan + ' created.');
378374
});
379375

380-
grunt.registerTask('makeRawFilesJs', function () {
376+
grunt.registerTask('makeRawFilesJs', function() {
381377
var _ = grunt.util._;
382378
var jsFilename = 'dist/assets/raw-files.json';
383379
var genRawFilesJs = require('./misc/raw-files-generator');
@@ -386,7 +382,7 @@ module.exports = function(grunt) {
386382
grunt.config('meta.banner'), grunt.config('meta.cssFileBanner'));
387383
});
388384

389-
grunt.registerTask('makeVersionsMappingFile', function () {
385+
grunt.registerTask('makeVersionsMappingFile', function() {
390386
var done = this.async();
391387

392388
var exec = require('child_process').exec;

0 commit comments

Comments
 (0)