Skip to content

Commit

Permalink
cleaned-up task code
Browse files Browse the repository at this point in the history
  • Loading branch information
Bartvds committed Nov 6, 2013
1 parent b2c7fcb commit b3db9ed
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions tasks/cleaver.js
Expand Up @@ -14,18 +14,19 @@ var path = require('path');
module.exports = function (grunt) {

function compileCleaver(file, options, callback) {
var cleaver = new Cleaver(path.resolve(file.src));

//TODO inject file.dest and options into source (or pass to cleaver)
//TODO inject file.dest and options into source (or pass to cleaver once it supporst these)

//trick output directory
var cwd = process.cwd();
process.chdir(path.dirname(file.src));

var restore = function () {
process.chdir(cwd);
};

cleaver.run().then(function () {
var cleaver = new Cleaver(path.resolve(file.src));
process.chdir(path.dirname(file.src));

//running with cleavers
return cleaver.run().then(function () {
restore();
callback();
}, function (err) {
Expand All @@ -35,12 +36,13 @@ module.exports = function (grunt) {
}

grunt.registerMultiTask('cleaver', 'Run cleaver to build slideshows from markdown', function () {
var options = this.options({
});

var options = this.options({});
var done = this.async();
var files = [];

var fileCount = 0;
var success = 0;
var failed = 0;

//flatten list for sanity
grunt.util._.each(this.files, function (f) {
Expand All @@ -65,9 +67,6 @@ module.exports = function (grunt) {
return;
}

var success = 0;
var failed = 0;

grunt.util.async.forEach(files, function (file, callback) {
compileCleaver(file, options, function (err) {
if (err) {
Expand Down

0 comments on commit b3db9ed

Please sign in to comment.