Skip to content

Commit

Permalink
Move es6 files to src, add transpile and qtest grunt tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
ichernev committed Mar 25, 2015
1 parent 5fb4720 commit 92c28cb
Show file tree
Hide file tree
Showing 129 changed files with 77 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ sauce_connect.log
.sauce-labs.creds
npm-debug.log
.build*
temp
build
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"broccoli-funnel": "^0.1.6",
"broccoli-merge-trees": "^0.2.1",
"broccoli-uglify-js": "^0.1.3",
"es6-promise": "latest",
"grunt": "latest",
"nodeunit": "latest",
"benchmark": "latest",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions lib/moment.js → src/moment.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! license : MIT
//! momentjs.com

import { hooks as moment, setHookCallback } from "./utils/hooks";
import { hooks as moment, setHookCallback } from "./lib/utils/hooks";

moment.version = '2.8.3';

Expand All @@ -18,7 +18,7 @@ import {
createLocal as local,
createInvalid as invalid,
createInZone as parseZone
} from "./moment/moment";
} from "./lib/moment/moment";

import {
defineLocale,
Expand All @@ -29,17 +29,17 @@ import {
listWeekdays as weekdays,
listWeekdaysMin as weekdaysMin,
listWeekdaysShort as weekdaysShort
} from "./locale/locale";
} from "./lib/locale/locale";

import {
isDuration,
createDuration as duration,
getSetRelativeTimeThreshold as relativeTimeThreshold
} from "./duration/duration";
} from "./lib/duration/duration";

import { normalizeUnits } from "./units/units";
import { normalizeUnits } from "./lib/units/units";

import isDate from "./utils/is-date";
import isDate from "./lib/utils/is-date";

setHookCallback(local);

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
29 changes: 29 additions & 0 deletions tasks/qtest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module.exports = function (grunt) {
grunt.task.registerTask("qtest", "run tests locally", function () {

var done = this.async();

var testrunner = require("qunit");

testrunner.options.log.assertions = false;
testrunner.options.log.tests = false;
testrunner.options.log.summary = false;
testrunner.options.log.testing = false;

testrunner.run({
code: "build/umd/moment.js",
tests: grunt.file.expand("build/umd/test/moment/*.js"),
}, function(err, report) {
if (err) {
done(err);
return;
}
var err = null;
if (report.failed !== 0) {
err = new Error(report.failed + " tests failed");
}
done(err);
});

});
};
36 changes: 36 additions & 0 deletions tasks/transpile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
module.exports = function (grunt) {
var esperanto = require('esperanto');
var Promise = require('es6-promise').Promise;

grunt.task.registerTask('transpile', 'convert es6 to umd', function () {
var done = this.async();

grunt.file.delete("build");

esperanto.bundle({
base: 'src', // optional, defaults to current dir
entry: 'moment.js' // the '.js' is optional
}).then(function(bundle) {
var umd = bundle.toUmd({name: 'moment'});
grunt.file.write('build/umd/moment.js', umd.code);
}).then(function() {
var files = grunt.file.expand({cwd: 'src'}, "test/moment/*.js");
var header = grunt.file.read('templates/test-header.js');

return Promise.all(files.map(function (file) {
return esperanto.bundle({
base: 'src',
entry: file,
skip: ['moment']
}).then(function (bundle) {
var umd = bundle.toUmd({name: 'not_used'});
var fixed = header + umd.code.split('\n').slice(5).join('\n');
grunt.file.write('build/umd/' + file, fixed);
});
}));

}).catch(function() {
}).then(done);

});
};
4 changes: 4 additions & 0 deletions templates/test-header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(require('../../moment')) :
typeof define === 'function' && define.amd && define(['../../moment'], factory);
}(this, function (moment) { 'use strict';

0 comments on commit 92c28cb

Please sign in to comment.