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

Commit

Permalink
chore: update gruntfile with ES6
Browse files Browse the repository at this point in the history
- Add some ES6 usage in the gruntfile

Closes #5179
  • Loading branch information
wesleycho committed Jan 9, 2016
1 parent 84bb118 commit 6ad873f
Showing 1 changed file with 21 additions and 25 deletions.
46 changes: 21 additions & 25 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ module.exports = function(grunt) {
cssInclude: '',
cssFileBanner: '/* Include this file in your html if you are using the CSP mode. */\n\n',
cssFileDest: '<%= dist %>/<%= filename %>-<%= pkg.version %>-csp.css',
banner: ['/*',
' * <%= pkg.name %>',
' * <%= pkg.homepage %>\n',
' * Version: <%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>',
' * License: <%= pkg.license %>',
' */\n'].join('\n')
banner: `/*
* <%= pkg.name %>
* <%= pkg.homepage %>
* Version: <%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>
* License: <%= pkg.license %>
*/
`
},
delta: {
docs: {
Expand Down Expand Up @@ -219,10 +221,10 @@ module.exports = function(grunt) {
});
}
function enquote(str) {
return '"' + str + '"';
return `"${str}"`;
}
function enquoteUibDir(str) {
return enquote('uib/' + str);
return enquote(`uib/${str}`);
}

var module = {
Expand All @@ -237,9 +239,7 @@ module.exports = function(grunt) {
dependencies: dependenciesForModule(name),
docs: {
md: grunt.file.expand(`src/${name}/docs/*.md`)
.map(grunt.file.read).map(function(str) {
return marked(str);
}).join('\n'),
.map(grunt.file.read).map((str) => marked(str)).join('\n'),
js: grunt.file.expand(`src/${name}/docs/*.js`)
.map(grunt.file.read).join('\n'),
html: grunt.file.expand(`src/${name}/docs/*.html`)
Expand Down Expand Up @@ -301,19 +301,17 @@ module.exports = function(grunt) {
} else {
grunt.file.expand({
filter: 'isDirectory', cwd: '.'
}, 'src/*').forEach(function(dir) {
}, 'src/*').forEach((dir) => {
findModule(dir.split('/')[1]);
});
}

var modules = grunt.config('modules');
grunt.config('srcModules', _.pluck(modules, 'moduleName'));
grunt.config('tplModules', _.pluck(modules, 'tplModules').filter(function(tpls) { return tpls.length > 0;} ));
grunt.config('tplModules', _.pluck(modules, 'tplModules').filter((tpls) => tpls.length > 0));
grunt.config('demoModules', modules
.filter(function(module) {
return module.docs.md && module.docs.js && module.docs.html;
})
.sort(function(a, b) {
.filter((module) => module.docs.md && module.docs.js && module.docs.html)
.sort((a, b) => {
if (a.name < b.name) { return -1; }
if (a.name > b.name) { return 1; }
return 0;
Expand All @@ -332,9 +330,7 @@ module.exports = function(grunt) {
}

var moduleFileMapping = _.clone(modules, true);
moduleFileMapping.forEach(function (module) {
delete module.docs;
});
moduleFileMapping.forEach((module) => delete module.docs);

grunt.config('moduleFileMapping', moduleFileMapping);

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

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

grunt.registerTask('makeModuleMappingFile', function () {
grunt.registerTask('makeModuleMappingFile', function() {
var _ = grunt.util._;
var moduleMappingJs = 'dist/assets/module-mapping.json';
var moduleMappings = grunt.config('moduleFileMapping');
Expand All @@ -377,7 +373,7 @@ module.exports = function(grunt) {
grunt.log.writeln('File ' + moduleMappingJs.cyan + ' created.');
});

grunt.registerTask('makeRawFilesJs', function () {
grunt.registerTask('makeRawFilesJs', function() {
var _ = grunt.util._;
var jsFilename = 'dist/assets/raw-files.json';
var genRawFilesJs = require('./misc/raw-files-generator');
Expand All @@ -386,7 +382,7 @@ module.exports = function(grunt) {
grunt.config('meta.banner'), grunt.config('meta.cssFileBanner'));
});

grunt.registerTask('makeVersionsMappingFile', function () {
grunt.registerTask('makeVersionsMappingFile', function() {
var done = this.async();

var exec = require('child_process').exec;
Expand Down

0 comments on commit 6ad873f

Please sign in to comment.