]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
fix minlang task
authorIgor Lima <igor.lima@evolut.io>
Tue, 19 Feb 2013 23:40:55 +0000 (20:40 -0300)
committerIgor Lima <igor.lima@evolut.io>
Tue, 19 Feb 2013 23:40:55 +0000 (20:40 -0300)
Gruntfile.js
tasks/minify-lang.js

index 8f8e4c12509fd51e858555c2cb546d48f9ecfa44..ddd14a41c6fc05770a9d985b9adaa008c37a2f26 100644 (file)
@@ -8,12 +8,21 @@ module.exports = function (grunt) {
         'min/moment.min.js' : ['moment.js']
     };
 
+    var minLangs = {
+        langs: {
+            src: ['min/langs.js'],
+            dest: 'min/langs.min.js'
+        }
+    };
+
     // all the lang files need to be added manually
     fs.readdirSync('./lang').forEach(function (path) {
         if (path.indexOf('.js') > -1) {
             var dest = 'min/lang/' + path,
                 src = ['lang/' + path];
+
             minifiedFiles[dest] = src;
+            minLangs[path] = {src:src, dest:dest};
         }
     });
 
@@ -31,12 +40,15 @@ module.exports = function (grunt) {
                 dest: 'min/langs.js'
             }
         },
+        minlang : minLangs,
         uglify : {
             my_target: {
                 files: minifiedFiles
             },
             options: {
-                mangle: true,
+                mangle: {
+                    toplevel: true
+                },
                 squeeze: {
                     dead_code: false
                 },
index 76b65a01636f3c2e9d40e6a1c9fafa8124d83d85..d7b3803d664166fd7fc9dd4c56463e698490898d 100644 (file)
@@ -6,6 +6,8 @@ var fs = require('fs'),
 
 module.exports = function (grunt) {
 
+    var helpers = require('grunt-lib-legacyhelpers').init(grunt);
+
     var START = [
         "(function(){",
         "    function onload (moment) {",
@@ -28,7 +30,7 @@ module.exports = function (grunt) {
     // UglifyJS does not support keeping the first line comments unless using the CLI.
     // This multi-task ensures that the first comments are kept.
     grunt.registerMultiTask('minlang', 'Minify lang files with UglifyJS.', function () {
-        var files = grunt.file.expandFiles(this.file.src),
+        var files = grunt.file.expand(this.data.src),
             min,
             code,
             comments,
@@ -36,24 +38,24 @@ module.exports = function (grunt) {
 
         // Concat specified files. This should really be a single, pre-built (and
         // linted) file, but it supports any number of files.
-        code = grunt.helper('concat', files, {separator: this.data.separator});
+        code = helpers.concat(files, {separator: this.data.separator});
 
         // Add the first comments
         tok = uglifyjs.parser.tokenizer(code);
         min = showCopyright(tok().comments_before);
 
         // Add the minified source.
-        min += grunt.helper('uglify', wrapFile(code), grunt.config('uglify'));
-        grunt.file.write(this.file.dest, min);
+        min += uglifyjs(wrapFile(code), grunt.config('uglify'));
+        grunt.file.write(this.data.dest, min);
 
         // Fail task if errors were logged.
         if (this.errorCount) { return false; }
 
         // Otherwise, print a success message....
-        grunt.log.writeln('File "' + this.file.dest + '" created.');
+        grunt.log.writeln('File "' + this.data.dest + '" created.');
 
         // ...and report some size information.
-        grunt.helper('min_max_info', min, code);
+        helpers.min_max_info(min, code);
     });
 
     // Helper for the 'mincomment' multitask