}
function transpile(opts) {
- grunt.log.writeln('transpile', opts);
// base, entry, skip, headerFile, skipLines, target
var umdName = opts.headerFile ? 'not_used' : opts.umdName,
header = opts.headerFile ? getHeaderByFile(opts.headerFile) : '',
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);
return transpile({
base: opts.base,
entry: file,
function prepareTemp(base) {
var files = grunt.file.expand({cwd: base}, '**/*.js'),
tmpDir = TMP_DIR;
- grunt.log.writeln('preparint temp', base);
if (grunt.file.exists(tmpDir)) {
return;
}
grunt.task.registerTask('transpile-raw', 'convert es6 to umd', function () {
var done = this.async();
- grunt.log.writeln('cleaning up build');
grunt.file.delete('build');
transpile({
umdName: 'moment',
target: 'build/umd/moment.js',
moveComments: true
+ }).then(function () {
+ grunt.log.ok('build/umd/moment.js');
}).then(function () {
return transpileMany({
base: 'src',
targetDir: 'build/umd',
skip: ['moment']
});
+ }).then(function () {
+ grunt.log.ok('build/umd/locale/*.js');
}).then(function () {
return transpileMany({
base: 'src',
targetDir: 'build/umd',
skip: ['moment']
});
+ }).then(function () {
+ grunt.log.ok('build/umd/test/moment/*.js');
}).then(function () {
return transpileMany({
base: 'src',
targetDir: 'build/umd',
skip: ['moment']
});
+ }).then(function () {
+ grunt.log.ok('build/umd/test/locale/*.js');
}).then(function () {
var files = grunt.file.expand({cwd: 'src'}, 'locale/*.js'),
code = files.map(function (file) {
headerFile: 'templates/locale-header.js',
skipLines: 5
});
+ }).then(function () {
+ grunt.log.ok('build/umd/min/locales.js');
}).then(function () {
var files = grunt.file.expand({cwd: 'src'}, 'locale/*.js'),
importCode = files.map(function (file) {
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(function () {
+ grunt.log.ok('build/umd/min/moment-with-locales.js');
}).then(done, function (e) {
grunt.log.error('error transpiling', e);
done(e);