From c22c866e93c43c480224e206c2910b5e7cbe1ab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6nnemann?= Date: Mon, 23 Nov 2015 22:20:59 +0100 Subject: [PATCH] Dynamically build file patterns for release task - converted release task to function task - dynamically setting config for copy task by reading `.npmignore` on demand - speeds up all other tasks because `.npmignore` is no longer read from filesystem --- Gruntfile.js | 44 ++++++++++++++++---------------------------- 1 file changed, 16 insertions(+), 28 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 9f6c9494a7..95b22f5a8f 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -21,23 +21,6 @@ var _ = require('lodash'), mochaPath = path.resolve(cwd + '/node_modules/grunt-mocha-cli/node_modules/mocha/bin/mocha'), emberPath = path.resolve(cwd + '/core/client/node_modules/.bin/ember'), - // ## Build File Patterns - // A list of files and patterns to include when creating a release zip. - // This is read from the `.npmignore` file and all patterns are inverted as the `.npmignore` - // file defines what to ignore, whereas we want to define what to include. - buildGlob = (function () { - /*jslint stupid:true */ - return fs.readFileSync('.npmignore', {encoding: 'utf8'}).split('\n').map(function (pattern) { - if (pattern[0] === '!') { - return pattern.substr(1); - } - return '!' + pattern; - }).filter(function (pattern) { - // Remove empty patterns - return pattern !== '!'; - }); - }()), - // ## Grunt configuration configureGrunt = function (grunt) { @@ -402,16 +385,6 @@ var _ = require('lodash'), } }, - // ### grunt-contrib-copy - // Copy files into their correct locations as part of building assets, or creating release zips - copy: { - release: { - expand: true, - src: buildGlob, - dest: '<%= paths.releaseBuild %>/' - } - }, - // ### grunt-contrib-compress // Zip up files for builds / releases compress: { @@ -928,7 +901,22 @@ var _ = require('lodash'), ' - Copy files to release-folder/#/#{version} directory\n' + ' - Clean out unnecessary files (travis, .git*, etc)\n' + ' - Zip files in release-folder to dist-folder/#{version} directory', - ['init', 'shell:ember:prod', 'clean:release', 'shell:dedupe', 'shell:shrinkwrap', 'copy:release', 'compress:release']); + function () { + grunt.config.set('copy.release', { + expand: true, + // #### Build File Patterns + // A list of files and patterns to include when creating a release zip. + // This is read from the `.npmignore` file and all patterns are inverted as the `.npmignore` + // file defines what to ignore, whereas we want to define what to include. + src: fs.readFileSync('.npmignore', 'utf8').split('\n').filter(Boolean).map(function (pattern) { + return pattern[0] === '!' ? pattern.substr(1) : '!' + pattern; + }), + dest: '<%= paths.releaseBuild %>/' + }); + + grunt.task.run(['init', 'shell:ember:prod', 'clean:release', 'shell:dedupe', 'shell:shrinkwrap', 'copy:release', 'compress:release']); + } + ); }; module.exports = configureGrunt;