Skip to content

Commit

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

Closes angular-ui#5076
  • Loading branch information
wesleycho committed Dec 15, 2015
1 parent 5ad08ff commit 00a7cc3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
4 changes: 4 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"env": {
"browser": true,
"es6": true
},
"rules": {
"comma-dangle": 2,
"no-cond-assign": 2,
Expand Down
30 changes: 15 additions & 15 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [{
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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')
}
};
Expand Down Expand Up @@ -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();
});

Expand All @@ -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, '')
Expand All @@ -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;
Expand Down

0 comments on commit 00a7cc3

Please sign in to comment.