From 891e55c265f155127f9712fcaa9debc77b7aef69 Mon Sep 17 00:00:00 2001 From: Matt Enlow Date: Tue, 2 Sep 2014 20:58:20 -0600 Subject: [PATCH] Smarter `buildAboutPage` task No issue - Only run the buildAboutPage task if the `-contributors.hbs` template doesn't exist, - ... or if the `--force` option is supplied on the CLI - Adds the contributors img dir and the contributors template to `grunt clean:built` task --- Gruntfile.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 98f1365ce4..9f581cee45 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -367,7 +367,11 @@ var _ = require('lodash'), // Clean up files as part of other tasks clean: { built: { - src: ['core/built/**'] + src: [ + 'core/built/**', + 'core/client/assets/img/contributors/**', + 'core/client/templates/-contributors.hbs' + ] }, release: { src: ['<%= paths.releaseBuild %>/**'] @@ -874,8 +878,19 @@ var _ = require('lodash'), // Run by any task that compiles the ember assets (emberBuildDev, emberBuildProd) // or manually via `grunt buildAboutPage`. // Change which version you're working against by setting the "releaseTag" below. + // + // Only builds if the contributors template does not exist. + // To force a build regardless, supply the --force option. + // `grunt buildAboutPage --force` grunt.registerTask('buildAboutPage', 'Compile assets for the About Ghost page', function () { - var done = this.async(); + var done = this.async(), + templatePath = 'core/client/templates/-contributors.hbs'; + + if (fs.existsSync(templatePath) && !grunt.option('force')) { + grunt.log.writeln('Contributors template already exists.'); + grunt.log.writeln('Skipped'.bold); + return done(); + } grunt.verbose.writeln('Downloading release and contributor information from GitHub'); getTopContribs({ @@ -889,7 +904,7 @@ var _ = require('lodash'), '\t\n'; grunt.verbose.writeln('Creating contributors template.'); - grunt.file.write('core/client/templates/-contributors.hbs', + grunt.file.write(templatePath, //Map contributors to the template. _.map(contributors, function (contributor) { return contributorTemplate