commit
0b93441169
1 changed files with 12 additions and 2 deletions
|
@ -18,7 +18,13 @@ module.exports = function(grunt) {
|
||||||
|
|
||||||
grunt.registerMultiTask('wkhtmltopdf', 'Your task description goes here.', function() {
|
grunt.registerMultiTask('wkhtmltopdf', 'Your task description goes here.', function() {
|
||||||
|
|
||||||
this.files.forEach(function(file) {
|
// using grunt async support so we can be sure task doesn't
|
||||||
|
// end before PDF processing does: http://gruntjs.com/api/inside-tasks
|
||||||
|
var done = this.async(),
|
||||||
|
files = this.files;
|
||||||
|
|
||||||
|
// iterate through each file grouping
|
||||||
|
files.forEach(function(file, filesIndex) {
|
||||||
|
|
||||||
var pathlib = require('path');
|
var pathlib = require('path');
|
||||||
// calculate the destination directory and ensure it exists, since
|
// calculate the destination directory and ensure it exists, since
|
||||||
|
@ -30,7 +36,7 @@ module.exports = function(grunt) {
|
||||||
}
|
}
|
||||||
grunt.file.mkdir(destPath);
|
grunt.file.mkdir(destPath);
|
||||||
|
|
||||||
file.src.forEach(function(src) {
|
file.src.forEach(function(src, srcIndex) {
|
||||||
|
|
||||||
var dest = file.dest;
|
var dest = file.dest;
|
||||||
// wkhtmltopdf seems to require that the destination be a file
|
// wkhtmltopdf seems to require that the destination be a file
|
||||||
|
@ -73,6 +79,10 @@ module.exports = function(grunt) {
|
||||||
if (err) {
|
if (err) {
|
||||||
grunt.log('>>>', err);
|
grunt.log('>>>', err);
|
||||||
}
|
}
|
||||||
|
// if this is the last src of the last file, we are done.
|
||||||
|
if((filesIndex+1 >= files.length) && (srcIndex+1 >= file.src.length)) {
|
||||||
|
done();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue