Skip to content

Commit

Permalink
Cleanup from previous pull; handle no tasks found
Browse files Browse the repository at this point in the history
  • Loading branch information
ehynds committed Dec 24, 2014
1 parent 7d582b1 commit e47f10d
Showing 1 changed file with 31 additions and 25 deletions.
56 changes: 31 additions & 25 deletions tasks/grunt-image-embed.js
Expand Up @@ -15,33 +15,39 @@ module.exports = function(grunt) {
var done = this.async();
var filesCount = this.files.length;
var doneCount = 0;

if (filesCount > 0) {

if (filesCount === 0) {
grunt.log.warn('No files defined');
return done();
}

// Process each src file
this.files.forEach(function(file) {
var dest = file.dest;
var tasks;

tasks = file.src.map(function(srcFile) {
return function(callback) {
encode.stylesheet(srcFile, opts, callback);
};
});

// Once all files have been processed write them out.
grunt.util.async.parallel(tasks, function(err, output) {
grunt.file.write(dest, output);
grunt.log.writeln('File "' + dest + '" created.');

// call done() exactly once, after all files are processed
if(++doneCount >= filesCount) {
done();
}
});
this.files.forEach(function(file) {
var dest = file.dest;
var tasks;

tasks = file.src.map(function(srcFile) {
return function(callback) {
encode.stylesheet(srcFile, opts, callback);
};
});

if(!tasks.length) {
grunt.log.writeln('No files found');
return done();
}

// Once all files have been processed write them out.
grunt.util.async.parallel(tasks, function(err, output) {
grunt.file.write(dest, output);
grunt.log.writeln('File "' + dest + '" created.');

// call done() exactly once, after all files are processed
if(++doneCount >= filesCount) {
done();
}
});
} else {
done();
};
});
});

};

0 comments on commit e47f10d

Please sign in to comment.