mirror of
https://github.com/photonstorm/phaser
synced 2024-11-10 15:14:47 +00:00
The Phaser Gruntfile is now split up into option tasks (thanks @xtian, #638)
This commit is contained in:
parent
3d92513f08
commit
1f32ef721d
3 changed files with 4 additions and 83 deletions
|
@ -72,6 +72,7 @@ Updated
|
|||
* Fix for 'jagged' strokes on custom fonts. (thanks @nickryall, #677)
|
||||
* The State.update function (and thus the update of any sub-classed Sprites or other objects) is now called before Stage, Tweens, Sound, Input, etc (#662)
|
||||
* The Phaser jshint process is now running on Travis (thanks @xtian, #656)
|
||||
* The Phaser Gruntfile is now split up into option tasks (thanks @xtian, #638)
|
||||
|
||||
|
||||
New Features
|
||||
|
|
|
@ -1,81 +0,0 @@
|
|||
var _ = require('lodash');
|
||||
|
||||
function pathToArray(parts) {
|
||||
var part = parts.shift();
|
||||
if (parts.length > 0) {
|
||||
var obj = {};
|
||||
obj[part] = pathToArray(parts);
|
||||
return obj;
|
||||
} else {
|
||||
return part;
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function(grunt) {
|
||||
grunt.registerMultiTask('examples', 'Build examples site.', function() {
|
||||
var options = this.options({
|
||||
base: '',
|
||||
excludes: []
|
||||
});
|
||||
|
||||
this.files.forEach(function(f) {
|
||||
if (grunt.option('verbose')) {
|
||||
if (grunt.file.exists(f.dest)) {
|
||||
grunt.verbose.writeln();
|
||||
grunt.verbose.warn('Destination file "%s" will be overridden.', f.dest);
|
||||
}
|
||||
grunt.verbose.writeln();
|
||||
}
|
||||
|
||||
var results = {};
|
||||
var files = f.src.filter(function(filepath) {
|
||||
if (!grunt.file.exists(filepath)) {
|
||||
grunt.log.warn('Source file "' + filepath + '" not found.');
|
||||
return false;
|
||||
} else {
|
||||
return options.excludes.every(function(dir) {
|
||||
var keep = filepath.indexOf(options.base + '/' + dir + '/') < 0;
|
||||
if (!keep) {
|
||||
grunt.verbose.writeln('Skipping %s/%s/%s...', options.base, dir.inverse.red, filepath.substr(options.base.length + dir.length + 2));
|
||||
}
|
||||
return keep;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (grunt.option('verbose')) {
|
||||
grunt.verbose.writeln();
|
||||
grunt.verbose.writeln('Found ' + files.length.toString().cyan + ' examples:');
|
||||
files.forEach(function(file) {
|
||||
grunt.verbose.writeln(' * '.cyan + file);
|
||||
});
|
||||
}
|
||||
|
||||
files.map(function(filepath) {
|
||||
return pathToArray(filepath.substr(options.base.length + 1).split('/'));
|
||||
}).forEach(function(parts) {
|
||||
_.merge(results, parts, function(a, b) {
|
||||
var example = {
|
||||
file: encodeURIComponent(b).replace(/%20/g, '+'),
|
||||
title: b.substr(0, b.length - 3)
|
||||
};
|
||||
return _.isArray(a) ? a.concat(example) : [example];
|
||||
});
|
||||
});
|
||||
|
||||
if (grunt.option('verbose')) {
|
||||
var categories = Object.keys(results);
|
||||
grunt.verbose.writeln();
|
||||
grunt.verbose.writeln('Extracted ' + categories.length.toString().cyan + ' categories:');
|
||||
categories.forEach(function(cat) {
|
||||
grunt.verbose.writeln(' * '.cyan + cat);
|
||||
});
|
||||
}
|
||||
|
||||
grunt.verbose.writeln();
|
||||
grunt.verbose.or.write('Writing ' + f.dest + '...');
|
||||
grunt.file.write(f.dest, JSON.stringify(results, null, ' '));
|
||||
grunt.verbose.or.ok();
|
||||
});
|
||||
});
|
||||
};
|
|
@ -6,7 +6,8 @@ module.exports = {
|
|||
'!src/Intro.js',
|
||||
'!src/Outro.js',
|
||||
'!src/pixi/**/*',
|
||||
'!src/physics/p2/p2.js'
|
||||
'!src/physics/p2/p2.js',
|
||||
'!plugins/AStar.js'
|
||||
],
|
||||
options: { jshintrc: '.jshintrc' }
|
||||
},
|
||||
|
@ -25,6 +26,6 @@ module.exports = {
|
|||
},
|
||||
|
||||
options: {
|
||||
force: true
|
||||
force: (process.env.NODE_ENV !== 'test')
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue