Explorar el Código

adapt to momentjs new locale file format

Adam Shaw hace 10 años
padre
commit
a26e17f1fb
Se han modificado 1 ficheros con 8 adiciones y 6 borrados
  1. 8 6
      build/tasks/generateLanguages.js

+ 8 - 6
build/tasks/generateLanguages.js

@@ -125,19 +125,21 @@ module.exports = function(grunt) {
 
 		var js = grunt.file.read(path);
 
-		js = js.replace( // remove the UMD wrap
+		// remove the UMD wrap
+		js = js.replace(
 			/\(\s*function[\S\s]*?function\s*\(\s*moment\s*\)\s*\{([\S\s]*)\}\)\);?/,
 			function(m0, body) {
-				body = body.replace(/^    /mg, ''); // remove 1 level of indentation
 				return body;
 			}
 		);
 
-		// replace the `return` statement so execution continues
-		// compatible with moment-pre-2.8
+		// the JS will return a value. wrap in a closure to avoid haulting execution
+		js = '(function() {\n' + js + '})();\n';
+
+		// make the defineLocale statement compatible with moment-pre-2.8
 		js = js.replace(
-			/^(\s*)return moment\.(defineLocale|lang)\(/m,
-			'$1(moment.defineLocale || moment.lang).call(moment, '
+			/moment\.(defineLocale|lang)\(/m,
+			'(moment.defineLocale || moment.lang).call(moment, '
 		);
 
 		return js;