gulpfile - more ES2015ify

forgot to make use of template literals
This commit is contained in:
Sindre Sorhus 2015-10-02 23:04:18 +07:00
parent b4b05ffbed
commit 10d6e7d2e0

View File

@ -166,7 +166,7 @@ gulp.task('styletemplates', () => {
// Minify Styles
.pipe($.if('*.css.template', $.csso()))
.pipe($.concat('material.min.css.template'))
.pipe($.header(banner, {pkg: pkg}))
.pipe($.header(banner, {pkg}))
.pipe($.sourcemaps.write('.'))
.pipe(gulp.dest('dist'))
.pipe($.size({title: 'styles'}));
@ -187,12 +187,12 @@ gulp.task('styles', () => {
.pipe(gulp.dest('.tmp'))
// Concatenate Styles
.pipe($.concat('material.css'))
.pipe($.header(banner, {pkg: pkg}))
.pipe($.header(banner, {pkg}))
.pipe(gulp.dest('dist'))
// Minify Styles
.pipe($.if('*.css', $.csso()))
.pipe($.concat('material.min.css'))
.pipe($.header(banner, {pkg: pkg}))
.pipe($.header(banner, {pkg}))
.pipe($.sourcemaps.write('.'))
.pipe(gulp.dest('dist'))
.pipe($.size({title: 'styles'}));
@ -209,12 +209,12 @@ gulp.task('styles-grid', () => {
.pipe(gulp.dest('.tmp'))
// Concatenate Styles
.pipe($.concat('material-grid.css'))
.pipe($.header(banner, {pkg: pkg}))
.pipe($.header(banner, {pkg}))
.pipe(gulp.dest('dist'))
// Minify Styles
.pipe($.if('*.css', $.csso()))
.pipe($.concat('material-grid.min.css'))
.pipe($.header(banner, {pkg: pkg}))
.pipe($.header(banner, {pkg}))
.pipe(gulp.dest('dist'))
.pipe($.size({title: 'styles-grid'}));
});
@ -251,7 +251,7 @@ gulp.task('scripts', ['jscs', 'jshint'], () => {
sourceRoot: '.',
sourceMapIncludeSources: true
}))
.pipe($.header(banner, {pkg: pkg}))
.pipe($.header(banner, {pkg}))
.pipe($.concat('material.min.js'))
// Write Source Maps
.pipe($.sourcemaps.write('.'))
@ -342,7 +342,7 @@ const site = {};
function applyTemplate() {
return through.obj((file, enc, cb) => {
const data = {
site: site,
site,
page: file.page,
content: file.contents.toString()
};
@ -566,13 +566,13 @@ gulp.task('zip:templates', () => {
// Generate a zip file for each template.
const generateZips = templates.map(template => {
return gulp.src([
'dist/templates/' + template + '/**/*.*',
`dist/templates/${template}/**/*.*`,
'LICENSE'
])
.pipe($.rename(path => {
path.dirname = path.dirname.replace('dist/templates/' + template, '');
path.dirname = path.dirname.replace(`dist/templates/${template}`, '');
}))
.pipe($.zip(templateArchivePrefix + template + '.zip'))
.pipe($.zip(`${templateArchivePrefix}${template}.zip`))
.pipe(gulp.dest('dist'));
});
@ -588,10 +588,10 @@ gulp.task('genCodeFiles', () => {
return gulp.src([
'dist/material.*@(js|css)?(.map)',
'dist/mdl.zip',
'dist/' + templateArchivePrefix + '*.zip'
`dist/${templateArchivePrefix}*.zip`
], {read: false})
.pipe($.tap(file => {
codeFiles += ' dist/' + path.basename(file.path);
codeFiles += ` dist/${path.basename(file.path)}`;
}));
});
@ -602,7 +602,7 @@ gulp.task('genCodeFiles', () => {
// For info on gsutil: https://cloud.google.com/storage/docs/gsutil.
gulp.task('pushCodeFiles', () => {
const dest = bucketCode;
process.stdout.write('Publishing ' + pkg.version + ' to CDN (' + dest + ')\n');
console.log(`Publishing ${pkg.version} to CDN (${dest})`);
// Build cache control and gsutil cmd to copy
// each object into a GCS bucket. The dest is a version specific path.
@ -613,15 +613,15 @@ gulp.task('pushCodeFiles', () => {
// 30 days caching is a safe value.
const cacheControl = '-h "Cache-Control:public,max-age=2592000"';
const gsutilCpCmd = 'gsutil -m cp -z js,css,map ';
const gsutilCacheCmd = 'gsutil -m setmeta -R ' + cacheControl;
const gsutilCacheCmd = `gsutil -m setmeta -R ${cacheControl}`;
// Upload the goodies to a separate GCS bucket with versioning.
// Using a sep bucket avoids the risk of accidentally blowing away
// old versions in the microsite bucket.
return gulp.src('')
.pipe($.shell([
gsutilCpCmd + codeFiles + ' ' + dest + '/' + pkg.version,
gsutilCacheCmd + ' ' + dest + '/' + pkg.version
`${gsutilCpCmd}${codeFiles} ${dest}/${pkg.version}`,
`${gsutilCacheCmd} ${dest}/${pkg.version}`
]));
});
@ -656,23 +656,23 @@ function mdlPublish(pubScope) {
} else if (pubScope === 'promote') {
// Set promote (essentially prod) specific vars here.
cacheTtl = 60;
src = bucketStaging + '/*';
src = `${bucketStaging}/*`;
dest = bucketProd;
}
let infoMsg = 'Publishing ' + pubScope + '/' + pkg.version + ' to GCS (' + dest + ')';
let infoMsg = `Publishing ${pubScope}/${pkg.version} to GCS (${dest})`;
if (src) {
infoMsg += ' from ' + src;
infoMsg += ` from ${src}`;
}
process.stdout.write(infoMsg + '\n');
console.log(infoMsg);
// Build gsutil commands:
// The gsutil -h option is used to set metadata headers.
// The gsutil -m option requests parallel copies.
// The gsutil -R option is used for recursive file copy.
const cacheControl = '-h "Cache-Control:public,max-age=' + cacheTtl + '"';
const gsutilCacheCmd = 'gsutil -m setmeta ' + cacheControl + ' ' + dest + '/**';
const gsutilCpCmd = 'gsutil -m cp -r -z html,css,js,svg ' + src + ' ' + dest;
const cacheControl = `-h "Cache-Control:public,max-age=${cacheTtl}"`;
const gsutilCacheCmd = `gsutil -m setmeta ${cacheControl} ${dest}/**`;
const gsutilCpCmd = `gsutil -m cp -r -z html,css,js,svg ${src} ${dest}`;
gulp.src('').pipe($.shell([gsutilCpCmd, gsutilCacheCmd]));
}
@ -804,7 +804,7 @@ gulp.task('styles:gen', ['styles'], () => {
const accentName = accent.toLowerCase().replace(' ', '_');
stream = stream.pipe($.file(
'material.' + primaryName + '-' + accentName + '.min.css',
`material.${primaryName}-${accentName}.min.css`,
mc.processTemplate(primary, accent)
));
});