]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Fix jscs warnings in grunt tasks
authorIskren Chernev <iskren.chernev@gmail.com>
Sun, 22 Mar 2015 22:17:26 +0000 (15:17 -0700)
committerIskren Chernev <iskren.chernev@gmail.com>
Wed, 25 Mar 2015 16:27:44 +0000 (09:27 -0700)
tasks/check_sauce_creds.js
tasks/embed_locales.js
tasks/history.js
tasks/nuget.js
tasks/qtest.js
tasks/size.js
tasks/transpile.js
tasks/update_index.js
tasks/zones.js

index dd9de91c577cdac40a31dfeb64aa2535ba807812..e56951d47b1d71f06edf33b0535eb4fade266711 100644 (file)
@@ -1,5 +1,4 @@
 module.exports = function (grunt) {
-
     // Pull requests do not have secure variables enabled for security reasons.
     // Use this task before launching travis-sauce-browser task, so it would
     // exit early and won't try connecting to SauceLabs without credentials.
index 7583bf803c65595c30e8a5cfba77df4144c7de5b..5027af10cd20338578342ed86180d6832b7ad1d6 100644 (file)
@@ -1,6 +1,5 @@
 
 module.exports = function (grunt) {
-
     grunt.registerTask('embedLocales', function () {
         var config = grunt.config('embedLocales');
 
@@ -44,6 +43,5 @@ module.exports = function (grunt) {
 
         return fileContents.replace(reTransform, replaceWith);
     }
-
 };
 
index fc6d3ffac2689b48487ea1ab7e37dc376069accd..85e83338fdae0c642e4e4c090e515ca780c86c2e 100644 (file)
@@ -29,11 +29,11 @@ function normalize() {
     var i,
         max = 0,
         max2 = 0;
-    for (i = 0; i < count; i ++) {
+    for (i = 0; i < count; i++) {
         max = Math.max(max, outputs[i].gzip);
         max2 = Math.max(max2, outputs[i].original);
     }
-    for (i = 0; i < count; i ++) {
+    for (i = 0; i < count; i++) {
         outputs[i].bargraph = makeBar((outputs[i].gzip / max) * 80);
         outputs[i].bargraph2 = makeBar((outputs[i].original / max2) * 80);
     }
@@ -41,7 +41,7 @@ function normalize() {
 
 function display() {
     var i;
-    for (i = 0; i < count; i ++) {
+    for (i = 0; i < count; i++) {
         console.log(outputs[i].version + ' ' + outputs[i].gzip + ' ' + outputs[i].original);
         console.log('gzip ' + outputs[i].bargraph);
         console.log('orig ' + outputs[i].bargraph2);
@@ -67,7 +67,7 @@ function getSizeAtVersion(version, path) {
                 op.version = version;
                 op.gzip = result.length;
                 op.original = data.length;
-                resolved ++;
+                resolved++;
                 check();
             });
         });
@@ -95,7 +95,7 @@ function getRemote() {
 }
 
 function getLocal() {
-    count ++;
+    count++;
     var op = {};
     outputs.push(op);
     fs.readFile(path.normalize(__dirname + '/../min/moment.min.js'), 'utf8', function (err, data) {
@@ -106,7 +106,7 @@ function getLocal() {
             op.version = '.next';
             op.gzip = result.length;
             op.original = data.length;
-            resolved ++;
+            resolved++;
             check();
         });
     });
index f5b8cedfad54befd904cf2cd89b19093fa94a650..7827b2400e02cfb5d3e32cb3abfc0a7c142a5b40 100644 (file)
@@ -11,12 +11,12 @@ module.exports = function (grunt) {
     grunt.config('nugetpack', {
         dist: {
             src: 'Moment.js.nuspec',
-            dest: './',
+            dest: './'
         }
     });
     grunt.config('nugetpush', {
         dist: {
-            src: 'Moment.js.*.nupkg',
+            src: 'Moment.js.*.nupkg'
         }
     });
     grunt.config('clean.nuget', {
index 99f78c0a42c70bb626c9047bd093269ff1768482..bff9a8fe21778a7ae908bbd12ce143c1c0a2c75b 100644 (file)
@@ -1,9 +1,8 @@
 module.exports = function (grunt) {
-    grunt.task.registerTask("qtest", "run tests locally", function () {
-
+    grunt.task.registerTask('qtest', 'run tests locally', function () {
         var done = this.async();
 
-        var testrunner = require("qunit");
+        var testrunner = require('qunit');
 
         testrunner.options.log.assertions = false;
         testrunner.options.log.tests = false;
@@ -12,10 +11,10 @@ module.exports = function (grunt) {
         testrunner.options.maxBlockDuration = 10000;
 
         testrunner.run({
-            code: "build/umd/moment.js",
-            tests: grunt.file.expand("build/umd/test/moment/*.js",
-                    "build/umd/test/locale/*.js"),
-        }, function(err, report) {
+            code: 'build/umd/moment.js',
+            tests: grunt.file.expand('build/umd/test/moment/*.js',
+                    'build/umd/test/locale/*.js')
+        }, function (err, report) {
             if (err) {
                 console.log('woot', err, report);
                 done(err);
@@ -23,10 +22,9 @@ module.exports = function (grunt) {
             }
             err = null;
             if (report.failed !== 0) {
-                err = new Error(report.failed + " tests failed");
+                err = new Error(report.failed + ' tests failed');
             }
             done(err);
         });
-
     });
 };
index 35d08ebe850ce8ff63946c08720a139983685428..2ab380e9fc26e6a6ff7d75573be5741e0fe5a1c3 100644 (file)
@@ -8,7 +8,6 @@ var stable = '1.7.1',
 
 function getVersion(path, cb) {
     var data = '',
-        
         req = https.request({
         host: 'raw.github.com',
         port: 443,
@@ -57,4 +56,4 @@ module.exports = function (grunt) {
             });
         });
     });
-};
\ No newline at end of file
+};
index 97b8ead2fd8218f412cea73b3fe2404e077da59e..8dcb1524ef5cad8644dd054edce6c2aa93b85498 100644 (file)
@@ -2,7 +2,7 @@ module.exports = function (grunt) {
     var esperanto = require('esperanto');
     var path = require('path');
     var Promise = require('es6-promise').Promise;
-    var TMP_DIR = "build/tmp";
+    var TMP_DIR = 'build/tmp';
 
     function moveComments(code) {
         var comments = [], rest = [];
@@ -26,17 +26,17 @@ module.exports = function (grunt) {
     }
 
     function transpile(opts) {
-        grunt.log.writeln("transpile", opts);
+        grunt.log.writeln('transpile', opts);
         // base, entry, skip, headerFile, skipLines, target
-        var umdName = opts.headerFile ? "not_used" : opts.umdName,
+        var umdName = opts.headerFile ? 'not_used' : opts.umdName,
             header = opts.headerFile ? getHeaderByFile(opts.headerFile) : '',
             skipLines = opts.skipLines ? opts.skipLines : 0;
 
         return esperanto.bundle({
             base: opts.base,
             entry: opts.entry,
-            skip: opts.skip || [],
-        }).then(function(bundle) {
+            skip: opts.skip || []
+        }).then(function (bundle) {
             var umd = bundle.toUmd({name: umdName}),
                 fixed = header + umd.code.split('\n').slice(skipLines).join('\n');
             if (opts.moveComments) {
@@ -52,10 +52,10 @@ module.exports = function (grunt) {
             files = grunt.file.expand({cwd: opts.base}, opts.pattern),
             i,
             transpileOne = function (i) {
-                promise = promise.then(function() {
-                    grunt.log.writeln("transpiling from", opts.pattern, i);
-                    return Promise.all(files.slice(i, i + batchSize).map(function(file) {
-                        grunt.log.writeln("transpiling", file);
+                promise = promise.then(function () {
+                    grunt.log.writeln('transpiling from', opts.pattern, i);
+                    return Promise.all(files.slice(i, i + batchSize).map(function (file) {
+                        grunt.log.writeln('transpiling', file);
                         return transpile({
                             base: opts.base,
                             entry: file,
@@ -63,7 +63,7 @@ module.exports = function (grunt) {
                             skip: opts.skip,
                             skipLines: opts.skipLines,
                             moveComments: opts.moveComments,
-                            target: path.join(opts.targetDir, file),
+                            target: path.join(opts.targetDir, file)
                         });
                     }));
                 });
@@ -77,9 +77,9 @@ module.exports = function (grunt) {
     }
 
     function prepareTemp(base) {
-        var files = grunt.file.expand({cwd: base}, "**/*.js"),
+        var files = grunt.file.expand({cwd: base}, '**/*.js'),
             tmpDir = TMP_DIR;
-        grunt.log.writeln("preparint temp", base);
+        grunt.log.writeln('preparint temp', base);
         if (grunt.file.exists(tmpDir)) {
             return;
         }
@@ -95,20 +95,20 @@ module.exports = function (grunt) {
         return transpile({
             base: TMP_DIR,
             entry: entry,
-            umdName: opts.umdName || "not_used",
+            umdName: opts.umdName || 'not_used',
             headerFile: opts.headerFile,
             skipLines: opts.skipLines,
             moveComments: opts.moveComments,
             target: opts.target,
-            skip: opts.skip,
+            skip: opts.skip
         });
     }
 
     grunt.task.registerTask('transpile', 'convert es6 to umd', function () {
         var done = this.async();
 
-        grunt.log.writeln("cleaning up build");
-        grunt.file.delete("build");
+        grunt.log.writeln('cleaning up build');
+        grunt.file.delete('build');
 
         transpile({
             base: 'src',
@@ -116,20 +116,20 @@ module.exports = function (grunt) {
             umdName: 'moment',
             target: 'build/umd/moment.js',
             moveComments: true
-        }).then(function() {
+        }).then(function () {
             return transpileMany({
                 base: 'src',
-                pattern: "locale/*.js",
+                pattern: 'locale/*.js',
                 headerFile: 'templates/locale-header.js',
                 skipLines: 5,
                 moveComments: true,
                 targetDir: 'build/umd',
                 skip: ['moment']
             });
-        }).then(function() {
+        }).then(function () {
             return transpileMany({
                 base: 'src',
-                pattern: "test/moment/*.js",
+                pattern: 'test/moment/*.js',
                 headerFile: 'templates/test-header.js',
                 skipLines: 5,
                 moveComments: true,
@@ -139,34 +139,34 @@ module.exports = function (grunt) {
         }).then(function () {
             return transpileMany({
                 base: 'src',
-                pattern: "test/locale/*.js",
-                headerFile: "templates/test-header.js",
+                pattern: 'test/locale/*.js',
+                headerFile: 'templates/test-header.js',
                 skipLines: 5,
                 moveComments: true,
-                targetDir: "build/umd",
+                targetDir: 'build/umd',
                 skip: ['moment']
             });
         }).then(function () {
-            var files = grunt.file.expand({cwd: "src"}, "locale/*.js"),
+            var files = grunt.file.expand({cwd: 'src'}, 'locale/*.js'),
                 code = files.map(function (file) {
                     var identifier = path.basename(file, '.js').replace('-', '_');
                     return 'import ' + identifier + ' from "./' + file + '";';
-                }).join("\n");
+                }).join('\n');
             return transpileCode({
                 base: 'src',
                 code: code,
                 target: 'build/umd/min/locales.js',
                 skip: ['moment'],
                 headerFile: 'templates/locale-header.js',
-                skipLines: 5,
+                skipLines: 5
             });
-        }).then(function() {
-            var files = grunt.file.expand({cwd: "src"}, "locale/*.js"),
+        }).then(function () {
+            var files = grunt.file.expand({cwd: 'src'}, 'locale/*.js'),
                 importCode = files.map(function (file) {
                     var identifier = path.basename(file, '.js').replace('-', '_');
                     var fileNoExt = file.replace('.js', '');
                     return 'import ' + identifier + ' from "./' + fileNoExt + '";';
-                }).join("\n"),
+                }).join('\n'),
                 code = 'import * as moment_export from "./moment";\n\n' +
                     importCode + '\n\n' +
                     'export default moment_export;';
@@ -175,15 +175,15 @@ module.exports = function (grunt) {
                 base: 'src',
                 code: code,
                 umdName: 'moment',
-                target: 'build/umd/min/moment-with-locales.js',
-            }).then(function() {
+                target: 'build/umd/min/moment-with-locales.js'
+            }).then(function () {
                 var code = grunt.file.read('build/umd/min/moment-with-locales.js');
                 code = code.replace('   var moment = {\n       get default () { return moment__default; }\n   };', '');
                 code = code.replace('var moment_with_locales = moment', 'var moment_with_locales = moment__default');
                 grunt.file.write('build/umd/min/moment-with-locales.js', code);
             });
-        }).then(done, function(e) {
-            grunt.log.error("error transpiling", e);
+        }).then(done, function (e) {
+            grunt.log.error('error transpiling', e);
             done(e);
         });
     });
index a9322b27f7f4efb05e657af354977deda19f9277..2a6447e9096f7c7862247d8dd0779dae21001d75 100644 (file)
@@ -7,7 +7,7 @@ module.exports = function (grunt) {
             'min/locales.js',
             'min/moment-with-locales.js'
         ],
-        dest: '.',
+        dest: '.'
     });
 
     grunt.registerTask('update-index', ['copy:index-files']);
index 72629274ac3721c7c4d62cd0838d82837194e783..7aa88b1f64401324d10042fd4c966687f71bbd6e 100644 (file)
@@ -19,7 +19,7 @@ module.exports = function (grunt) {
                     if (err != null) {
                         throw err;
                     }
-                    iterator(i+1);
+                    iterator(i + 1);
                 });
             }(0));
         });
@@ -32,9 +32,13 @@ module.exports = function (grunt) {
             }
             callback(null, content.split(/\r\n|\r|\n/)
                 // remove empty and commented lines
-                .filter(function (line) { return line && !/^#/.test(line); })
+                .filter(function (line) {
+                    return line && !/^#/.test(line);
+                })
                 // country code TAB coordinates TAB timezone
-                .map(function (line) { return line.split('\t')[2]; }));
+                .map(function (line) {
+                    return line.split('\t')[2];
+                }));
         });
     }
 
@@ -42,16 +46,22 @@ module.exports = function (grunt) {
         grunt.log.ok('Running tests in zone ' + zone);
         grunt.util.spawn({
             cmd: 'grunt',
-            opts: { env: {
-                'PATH': process.env.PATH,
-                'TZ': zone
-            } },
+            opts: {
+                env: {
+                    'PATH': process.env.PATH,
+                    'TZ': zone
+                }
+            },
             args: ['--no-color', 'nodeunit']
         }, function (err, result, code) {
             if (code !== 0) {
                 grunt.log.error(result.stdout.split(/\r\n|\r|\n/)
-                    .filter(function (line) { return /^(>>|Warning:|$)/.test(line); })
-                    .map(function (line) { return (line.substr(0, 3) === '>> ' ? line.substr(3) : line); })
+                    .filter(function (line) {
+                        return /^(>>|Warning:|$)/.test(line);
+                    })
+                    .map(function (line) {
+                        return (line.substr(0, 3) === '>> ' ? line.substr(3) : line);
+                    })
                     .join('\n'));
             }
             next();