Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Commit

Permalink
updates to summary logs
Browse files Browse the repository at this point in the history
  • Loading branch information
vladikoff committed Aug 15, 2014
1 parent 5cc5433 commit 4216c9a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 22 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v0.11.1:
date: 2014-08-15
changes:
- Fixes summary logging.
v0.11.0:
date: 2014-08-06
changes:
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "grunt-contrib-coffee",
"description": "Compile CoffeeScript files to JavaScript.",
"version": "0.11.0",
"version": "0.11.1",
"homepage": "https://github.com/gruntjs/grunt-contrib-coffee",
"author": {
"name": "Grunt Team",
Expand Down
46 changes: 25 additions & 21 deletions tasks/coffee.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@ module.exports = function(grunt) {
var chalk = require('chalk');
var _ = require('lodash');

var actionCounts = {};
var resetCounts = function() {
actionCounts = {
fileCreated: 0,
mapCreated: 0
};
};
resetCounts();

grunt.registerMultiTask('coffee', 'Compile CoffeeScript files into JavaScript', function() {
var options = this.options({
bare: false,
Expand All @@ -30,6 +21,10 @@ module.exports = function(grunt) {
joinExt: '.src.coffee',
separator: grunt.util.linefeed
});
var actionCounts = {
createdFile: 0,
createdMap: 0
};

options.separator = grunt.util.normalizelf(options.separator);

Expand All @@ -40,20 +35,20 @@ module.exports = function(grunt) {
var paths = createOutputPaths(f.dest);
// add sourceMapDir to options object
var fileOptions = _.extend({ sourceMapDir: paths.destDir }, options);
writeFileAndMap(paths, compileWithMaps(validFiles, fileOptions, paths), fileOptions);
var writeResult = writeFileAndMap(paths, compileWithMaps(validFiles, fileOptions, paths), fileOptions);
actionCounts.createdFile += writeResult.createdFile;
actionCounts.createdMap += writeResult.createdMap;
} else if (options.join === true) {
writeCompiledFile(f.dest, concatInput(validFiles, options));
actionCounts.createdFile += writeCompiledFile(f.dest, concatInput(validFiles, options));
} else {
writeCompiledFile(f.dest, concatOutput(validFiles, options));
actionCounts.createdFile += writeCompiledFile(f.dest, concatOutput(validFiles, options));
}
});

grunt.log.ok(actionCounts.fileCreated + ' files created.');
if (actionCounts.mapCreated > 0) {
grunt.log.ok(actionCounts.mapCreated + ' source map files created.');
grunt.log.ok(actionCounts.createdFile + ' files created.');
if (actionCounts.createdMap > 0) {
grunt.log.ok(actionCounts.createdMap + ' source map files created.');
}
resetCounts();

});

var isLiterate = function(ext) {
Expand Down Expand Up @@ -224,9 +219,14 @@ module.exports = function(grunt) {
return;
}

writeCompiledFile(paths.dest, output.js);
var createdFile = writeCompiledFile(paths.dest, output.js);
options.sourceMapDir = appendTrailingSlash(options.sourceMapDir);
writeSourceMapFile(options.sourceMapDir + paths.mapFileName, output.v3SourceMap);
var createdMap = writeSourceMapFile(options.sourceMapDir + paths.mapFileName, output.v3SourceMap);

return {
createdFile: createdFile,
createdMap: createdMap
};
};

var warnOnEmptyFile = function(path) {
Expand All @@ -245,14 +245,18 @@ module.exports = function(grunt) {

var writeCompiledFile = function(path, output) {
if (writeFile(path, output)) {
actionCounts.fileCreated++;
grunt.verbose.writeln('File ' + chalk.cyan(path) + ' created.');
return 1;
} else {
return 0;
}
};
var writeSourceMapFile = function(path, output) {
if (writeFile(path, output)) {
actionCounts.mapCreated++;
grunt.verbose.writeln('File ' + chalk.cyan(path) + ' created (source map).');
return 1;
} else {
return 0;
}
};
};

0 comments on commit 4216c9a

Please sign in to comment.