Permalink
Browse files

chore: leverage es6 in gruntfile

- Add some ES6 usage in gruntfile

Closes #5076
  • Loading branch information...
1 parent 5ad08ff commit 00a7cc393a2551276becc5b21ecfa03424d95948 @wesleycho wesleycho committed Dec 15, 2015
Showing with 19 additions and 15 deletions.
  1. +4 −0 .eslintrc
  2. +15 −15 Gruntfile.js
View
@@ -1,4 +1,8 @@
{
+ "env": {
+ "browser": true,
+ "es6": true
+ },
"rules": {
"comma-dangle": 2,
"no-cond-assign": 2,
View
@@ -103,7 +103,7 @@ module.exports = function(grunt) {
module: null, // no bundle module for all the html2js templates
base: '.',
rename: function(moduleName) {
- return 'uib/' + moduleName;
+ return `uib/${moduleName}`;
}
},
files: [{
@@ -194,7 +194,7 @@ module.exports = function(grunt) {
// Default task.
grunt.registerTask('default', ['before-test', 'test', 'after-test']);
- grunt.registerTask('enforce', 'Install commit message enforce script if it doesn\'t exist', function() {
+ grunt.registerTask('enforce', `Install commit message enforce script if it doesn't exist`, function() {
if (!grunt.file.exists('.git/hooks/commit-msg')) {
grunt.file.copy('misc/validate-commit-msg.js', '.git/hooks/commit-msg');
require('fs').chmodSync('.git/hooks/commit-msg', '0755');
@@ -227,22 +227,22 @@ module.exports = function(grunt) {
var module = {
name: name,
- moduleName: enquote('ui.bootstrap.' + name),
+ moduleName: enquote(`ui.bootstrap.${name}`),
displayName: ucwords(breakup(name, ' ')),
- srcFiles: grunt.file.expand('src/'+name+'/*.js'),
- cssFiles: grunt.file.expand('src/'+name+'/*.css'),
- tplFiles: grunt.file.expand('template/'+name+'/*.html'),
- tpljsFiles: grunt.file.expand('template/'+name+'/*.html.js'),
- tplModules: grunt.file.expand('template/'+name+'/*.html').map(enquoteUibDir),
+ srcFiles: grunt.file.expand(`src/${name}/*.js`),
+ cssFiles: grunt.file.expand(`src/${name}/*.css`),
+ tplFiles: grunt.file.expand(`template/${name}/*.html`),
+ tpljsFiles: grunt.file.expand(`template/${name}/*.html.js`),
+ tplModules: grunt.file.expand(`template/${name}/*.html`).map(enquoteUibDir),
dependencies: dependenciesForModule(name),
docs: {
- md: grunt.file.expand('src/'+name+'/docs/*.md')
+ md: grunt.file.expand(`src/${name}/docs/*.md`)
.map(grunt.file.read).map(function(str) {
return marked(str);
}).join('\n'),
- js: grunt.file.expand('src/'+name+'/docs/*.js')
+ js: grunt.file.expand(`src/${name}/docs/*.js`)
.map(grunt.file.read).join('\n'),
- html: grunt.file.expand('src/'+name+'/docs/*.html')
+ html: grunt.file.expand(`src/${name}/docs/*.html`)
.map(grunt.file.read).join('\n')
}
};
@@ -399,15 +399,15 @@ module.exports = function(grunt) {
var jsContent = versions.map(function(version) {
return {
version: version,
- url: '/bootstrap/versioned-docs/' + version
+ url: `/bootstrap/versioned-docs/${version}`
};
});
jsContent.unshift({
version: 'Current',
url: '/bootstrap'
});
grunt.file.write(versionsMappingFile, JSON.stringify(jsContent));
- grunt.log.writeln('File ' + versionsMappingFile.cyan + ' created.');
+ grunt.log.writeln(`File ${versionsMappingFile.cyan} created.`);
done();
});
@@ -422,7 +422,7 @@ module.exports = function(grunt) {
js;
state.css.push(css);
- if(minify){
+ if (minify) {
css = css
.replace(/\r?\n/g, '')
.replace(/\/\*.*?\*\//g, '')
@@ -437,7 +437,7 @@ module.exports = function(grunt) {
.replace(/\\/g, '\\\\')
.replace(/'/g, "\\'")
.replace(/\r?\n/g, '\\n');
- js = "angular.module('ui.bootstrap.carousel').run(function() {!angular.$$csp() && angular.element(document).find('head').prepend('<style type=\"text/css\">" + css + "</style>'); })";
+ js = `angular.module('ui.bootstrap.carousel').run(function() {!angular.$$csp() && angular.element(document).find('head').prepend('<style type="text/css">${css}</style>'); })`;
state.js.push(js);
return state;

0 comments on commit 00a7cc3

Please sign in to comment.