]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Add Broccoli build pipeline.
authorTim Wood <washwithcare@gmail.com>
Sun, 11 Jan 2015 19:14:35 +0000 (11:14 -0800)
committerIskren Chernev <iskren.chernev@gmail.com>
Wed, 25 Mar 2015 16:27:42 +0000 (09:27 -0700)
.gitignore
Brocfile.js [new file with mode: 0644]
package.json
test/helpers/each.js [new file with mode: 0644]
test/qunit.js [new file with mode: 0644]

index 8ec4b029bcb8b11d30913a8891859321a8a3553c..3f7127b9d98a3cf1fd79783174d4e3949da316ab 100644 (file)
@@ -7,3 +7,4 @@ sauce_connect.log
 .sauce-labs.creds
 npm-debug.log
 .build*
+temp
diff --git a/Brocfile.js b/Brocfile.js
new file mode 100644 (file)
index 0000000..b353a7e
--- /dev/null
@@ -0,0 +1,58 @@
+var compileModules = require('broccoli-es6-module-transpiler');
+var compile6to5 = require('broccoli-6to5-transpiler');
+var uglify = require('broccoli-uglify-js');
+var merge = require('broccoli-merge-trees');
+var Funnel = require('broccoli-funnel');
+
+var testFiles = new Funnel('.', {
+    include: [/^test\/(moment|qunit|helpers)/]
+});
+
+var libAndTests = merge(['lib', testFiles]);
+
+var tests = compileModules(libAndTests, {
+    formatter: 'bundle',
+    output: 'test/moment-and-tests.js'
+});
+
+function bundle (file) {
+    var template = new Funnel('templates', {
+        include : [new RegExp(file + ".js")]
+    });
+    return compileModules(merge(['lib', template]), {
+        formatter: 'bundle',
+        output: file + '/moment.js'
+    });
+}
+
+var bundled = merge([
+    bundle('amd'),
+    bundle('amd-named'),
+    bundle('globals')
+]);
+
+var minified = uglify(bundled, {
+    mangle: true,
+    compress: {
+        dead_code: false // jshint ignore:line
+    },
+    output: {
+        ascii_only: true // jshint ignore:line
+    }
+});
+
+var commonjsSource = compile6to5(libAndTests, {
+    modules: 'commonInterop'
+});
+
+var commonjs = new Funnel(commonjsSource, {
+    destDir: "commonjs"
+});
+
+var all = merge([minified, tests, commonjs]);
+
+var allWithoutMaps = new Funnel(all, {
+    exclude: [/\.map$/]
+});
+
+module.exports = allWithoutMaps;
index 5520d157936bb2e0d0e31260cb1f307657ef2f14..5007d8eaa521361a109785260731628a348dd96f 100644 (file)
     ],
     "devDependencies": {
         "uglify-js": "latest",
+        "broccoli": "^0.13.3",
+        "broccoli-6to5-transpiler": "^0.1.1",
+        "broccoli-cli": "0.0.1",
+        "broccoli-es6-module-transpiler": "^0.5.0",
+        "broccoli-funnel": "^0.1.6",
+        "broccoli-merge-trees": "^0.2.1",
+        "broccoli-uglify-js": "^0.1.3",
         "grunt": "latest",
         "nodeunit": "latest",
         "benchmark": "latest",
         "karma-firefox-launcher": "latest",
         "karma-nodeunit": "latest",
         "karma-sauce-launcher": "latest",
+        "qunit": "^0.7.5",
+        "qunit-cli": "^0.1.4",
         "spacejam": "latest"
     },
     "scripts": {
-        "test": "grunt test:node"
+        "test": "rm -rf temp; broccoli build temp; qunit-cli temp/test/*.js; qunit-cli temp/commonjs/test/**/*.js;"
     },
     "ender": "./ender.js",
     "dojoBuild": "package.js",
diff --git a/test/helpers/each.js b/test/helpers/each.js
new file mode 100644 (file)
index 0000000..56c9968
--- /dev/null
@@ -0,0 +1,6 @@
+export default function (array, callback) {
+    var i;
+    for (i = 0; i < array.length; i++) {
+        callback(array[i], i, array);
+    }
+}
diff --git a/test/qunit.js b/test/qunit.js
new file mode 100644 (file)
index 0000000..59d50d7
--- /dev/null
@@ -0,0 +1,24 @@
+/*global QUnit:false*/
+
+import moment from "../moment";
+
+export var test = QUnit.test;
+
+export function module (name, lifecycle) {
+    QUnit.module(name, {
+        setup : function () {
+            moment.locale('en');
+            moment.createFromInputFallback = function () {
+                throw new Error('input not handled by moment');
+            };
+            if (lifecycle && lifecycle.setup) {
+                lifecycle.setup();
+            }
+        },
+        teardown : function () {
+            if (lifecycle && lifecycle.teardown) {
+                lifecycle.teardown();
+            }
+        }
+    });
+}