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

Added logic and test for case without terminal (eg. Jenkins) #13

Merged
merged 1 commit into from
Jun 23, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,13 @@ module.exports = function(grunt)
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-nodeunit');

grunt.registerTask('unset_clearline', 'Unset stdout.clearLine for testing', function(){
process.stdout.clearLine = undefined;
});

grunt.registerTask('test', ['clean', 'svg2png', 'nodeunit']);
grunt.registerTask('test_noterminal', ['unset_clearline', 'test']);
grunt.registerTask('default', ['jshint', 'test']);

};
15 changes: 10 additions & 5 deletions tasks/svg2png.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,14 @@ module.exports = function(grunt)
if (!total) {
return;
}

process.stdout.clearLine();
process.stdout.cursorTo(0);


var hasTerminal = !!process.stdout.clearLine;

if (hasTerminal) {
process.stdout.clearLine();
process.stdout.cursorTo(0);
}

var str = style('0%', 'yellow') + ' [ ',
arr = [],
count = total,
Expand All @@ -93,7 +97,8 @@ module.exports = function(grunt)
}
str += arr.reverse().join('');
str += ' ] ' + style(percent + "%", 'green') + ' (' + ((new Date() - start) / 1000).toFixed(1) + 's) ';
process.stdout.write(str);

process.stdout.write(str + (hasTerminal ? '' : "\n"));
};

var spawn = grunt.util.spawn({
Expand Down