mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
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
This commit is contained in:
parent
5df3cd5cfd
commit
c22c866e93
1 changed files with 16 additions and 28 deletions
44
Gruntfile.js
44
Gruntfile.js
|
@ -21,23 +21,6 @@ var _ = require('lodash'),
|
||||||
mochaPath = path.resolve(cwd + '/node_modules/grunt-mocha-cli/node_modules/mocha/bin/mocha'),
|
mochaPath = path.resolve(cwd + '/node_modules/grunt-mocha-cli/node_modules/mocha/bin/mocha'),
|
||||||
emberPath = path.resolve(cwd + '/core/client/node_modules/.bin/ember'),
|
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
|
// ## Grunt configuration
|
||||||
|
|
||||||
configureGrunt = function (grunt) {
|
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
|
// ### grunt-contrib-compress
|
||||||
// Zip up files for builds / releases
|
// Zip up files for builds / releases
|
||||||
compress: {
|
compress: {
|
||||||
|
@ -928,7 +901,22 @@ var _ = require('lodash'),
|
||||||
' - Copy files to release-folder/#/#{version} directory\n' +
|
' - Copy files to release-folder/#/#{version} directory\n' +
|
||||||
' - Clean out unnecessary files (travis, .git*, etc)\n' +
|
' - Clean out unnecessary files (travis, .git*, etc)\n' +
|
||||||
' - Zip files in release-folder to dist-folder/#{version} directory',
|
' - 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;
|
module.exports = configureGrunt;
|
||||||
|
|
Loading…
Add table
Reference in a new issue