mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 21:24:09 +00:00
35 lines
947 B
JavaScript
35 lines
947 B
JavaScript
var umdBefore = [
|
|
'!function(root, factory) {',
|
|
' if (typeof define === "function" && define.amd) {',
|
|
' define(factory);',
|
|
' } else if (typeof exports === "object") {',
|
|
' module.exports = factory();',
|
|
' } else {',
|
|
' root.Phaser = factory();',
|
|
' }',
|
|
'}(this, function() {'
|
|
].join('\n');
|
|
|
|
var umdAfter = [
|
|
' return Phaser;',
|
|
'});'
|
|
].join('\n');
|
|
|
|
module.exports = function(grunt) {
|
|
grunt.registerMultiTask('umd', 'Create an UMD wrapper.', function() {
|
|
this.files.forEach(function(f) {
|
|
var src = umdBefore + '\n' + f.src.filter(function(filepath) {
|
|
if (!grunt.file.exists(filepath)) {
|
|
grunt.log.warn('Source file "' + filepath + '" not found.');
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
}).map(function(filepath) {
|
|
return grunt.file.read(filepath);
|
|
}).join('\n') + umdAfter;
|
|
|
|
grunt.file.write(f.dest, src);
|
|
});
|
|
});
|
|
};
|