Skip to content

Commit

Permalink
Better logging in grunt transpile
Browse files Browse the repository at this point in the history
  • Loading branch information
ichernev committed Mar 25, 2015
1 parent 165d3b8 commit bdc22f2
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions tasks/transpile.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ module.exports = function (grunt) {
}

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) : '',
Expand All @@ -58,9 +57,7 @@ module.exports = function (grunt) {
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,
Expand All @@ -84,7 +81,6 @@ module.exports = function (grunt) {
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;
}
Expand Down Expand Up @@ -112,7 +108,6 @@ module.exports = function (grunt) {
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({
Expand All @@ -121,6 +116,8 @@ module.exports = function (grunt) {
umdName: 'moment',
target: 'build/umd/moment.js',
moveComments: true
}).then(function () {
grunt.log.ok('build/umd/moment.js');
}).then(function () {
return transpileMany({
base: 'src',
Expand All @@ -131,6 +128,8 @@ module.exports = function (grunt) {
targetDir: 'build/umd',
skip: ['moment']
});
}).then(function () {
grunt.log.ok('build/umd/locale/*.js');
}).then(function () {
return transpileMany({
base: 'src',
Expand All @@ -141,6 +140,8 @@ module.exports = function (grunt) {
targetDir: 'build/umd',
skip: ['moment']
});
}).then(function () {
grunt.log.ok('build/umd/test/moment/*.js');
}).then(function () {
return transpileMany({
base: 'src',
Expand All @@ -151,6 +152,8 @@ module.exports = function (grunt) {
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) {
Expand All @@ -165,6 +168,8 @@ module.exports = function (grunt) {
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) {
Expand All @@ -187,6 +192,8 @@ module.exports = function (grunt) {
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);
Expand Down

0 comments on commit bdc22f2

Please sign in to comment.