Permalink
Browse files

Remove IIFEs on each file and wrap a single IIFE around the built files

  • Loading branch information...
1 parent a604fd7 commit 24e4022558f3b6ed161914612caf748da0a365ed @kborchers kborchers committed Mar 11, 2013
View
@@ -86,17 +86,27 @@ module.exports = function(grunt) {
}
});
+ // IIFE wrapper task
+ grunt.registerTask('iife', function( custom ) {
+ var fs = require("fs"),
+ fileName = "dist/" + grunt.config("pkg").name + (custom ? ".custom" : "") + ".js",
+ fileText = fs.readFileSync( fileName, "utf-8" );
+
+ fileText = fileText.replace( /\*\//, "*/\n(function( window, undefined ) {\n" );
+ fs.writeFileSync( fileName, fileText + "})( this );\n", "utf-8" );
+ });
+
// grunt-contrib tasks
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-qunit');
grunt.loadNpmTasks('grunt-contrib-concat');
// Default task
- grunt.registerTask('default', ['jshint', 'qunit', 'concat:dist', 'uglify:all']);
- grunt.registerTask('dev', ['jshint', 'concat:dist', 'uglify:all']);
- grunt.registerTask('pipeline', ['jshint', 'qunit', 'concat:pipeline', 'uglify:custom']);
- grunt.registerTask('data-manager', ['jshint', 'qunit', 'concat:dataManager', 'uglify:custom']);
- grunt.registerTask('auth', ['jshint', 'qunit', 'concat:auth', 'uglify:custom']);
+ grunt.registerTask('default', ['jshint', 'qunit', 'concat:dist', 'iife', 'uglify:all']);
+ grunt.registerTask('dev', ['jshint', 'concat:dist', 'iife', 'uglify:all']);
+ grunt.registerTask('pipeline', ['jshint', 'qunit', 'concat:pipeline', 'iife:custom', 'uglify:custom']);
+ grunt.registerTask('data-manager', ['jshint', 'qunit', 'concat:dataManager', 'iife:custom', 'uglify:custom']);
+ grunt.registerTask('auth', ['jshint', 'qunit', 'concat:auth', 'iife:custom', 'uglify:custom']);
};
View
@@ -17,7 +17,7 @@
The AeroGear namespace provides a way to encapsulate the library's properties and methods away from the global namespace
@namespace
*/
-var AeroGear = {};
+this.AeroGear = {};
/**
AeroGear.Core is a base for all of the library modules to extend. It is not to be instantiated and will throw an error when attempted
Oops, something went wrong.

0 comments on commit 24e4022

Please sign in to comment.