Skip to content

Commit

Permalink
Fix moment-with-locales and customization and add locale parent checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ichernev committed Nov 6, 2016
1 parent a1e6947 commit 036a64c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions tasks/transpile.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ module.exports = function (grunt) {
function generateLocales(target, localeFiles, opts) {
var files = localeFiles,
code = [
'import moment from "./moment";'
'import moment from "./moment";',
'export default moment;'
].concat(files.map(function (file) {
var identifier = path.basename(file, '.js').replace('-', '_');
return 'import ' + identifier + ' from "./' + file + '";';
Expand All @@ -169,8 +170,8 @@ module.exports = function (grunt) {
code: code,
target: target,
skipMoment: opts.skipMoment,
headerFile: 'templates/locale-header.js',
skipLines: 7
headerFile: opts.skipMoment === true ? 'templates/locale-header.js' : 'templates/default.js',
skipLines: opts.skipMoment === true ? 7 : 5
});
}

Expand Down Expand Up @@ -278,6 +279,13 @@ module.exports = function (grunt) {
{skipMoment: false});
}).then(function () {
grunt.log.ok('build/umd/min/moment-with-locales.custom.js');
}).then(function () {
var moment = require('../build/umd/min/moment-with-locales.custom.js');
if (moment.locales().length != localeFiles.length) {
throw new Error(
'You probably specified locales requiring ' +
'parent locale, but didn\'t specify parent')
}
}).then(done, function (e) {
grunt.log.error('error transpiling-custom', e);
done(e);
Expand Down

0 comments on commit 036a64c

Please sign in to comment.