Skip to content

Commit

Permalink
Fixes bug were the tests would never be run
Browse files Browse the repository at this point in the history
  • Loading branch information
jauco committed Feb 26, 2014
1 parent f76a3d9 commit 139019b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 35 deletions.
2 changes: 1 addition & 1 deletion src/lib/createTestFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module.exports = function createTestFile(filenames, karmaPath, cb) {
jQuery: "jquery"
})
]
}, require("./handleWebpackResult"));
}, require("./handleWebpackResult")(cb));
} catch (e) {
console.log(e, e.stack);
}
Expand Down
71 changes: 38 additions & 33 deletions src/lib/handleWebpackResult.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,42 @@
module.exports = function handleWebpackResult(err, stats) {
if (stats) {
stats = stats.toJson();
}
var nonFatalErrors = (stats && stats.errors) || [];
var warnings = (stats && stats.warnings) || [];
if (err || nonFatalErrors.length > 0 || warnings.length > 0) {
console.error("Something went wrong while generating the test file");
if (err) {
console.log("Fatal error:");
console.log(" ", err);
module.exports = function createHandleWebpackResult(cb) {
return function handleWebpackResult(err, stats) {
if (stats) {
stats = stats.toJson();
}
if (nonFatalErrors.length > 0) {
console.log("Non-fatal error" + (nonFatalErrors.length > 1 ? "s" : "") + ":");
nonFatalErrors.forEach(function (err) {
err.split("\n").forEach(function (err) {
console.log(" ", err);
})
});
}
if (warnings.length > 0) {
console.log("Warning" + (nonFatalErrors.length > 1 ? "s" : "") + ":");
warnings.forEach(function (err) {
err.split("\n").forEach(function (err) {
console.log(" ", err);
})
});
}
if (err) {
console.error("Building failed!");
var nonFatalErrors = (stats && stats.errors) || [];
var warnings = (stats && stats.warnings) || [];
if (err || nonFatalErrors.length > 0 || warnings.length > 0) {
console.error("Something went wrong while generating the test file");
if (err) {
console.log("Fatal error:");
console.log(" ", err);
}
if (nonFatalErrors.length > 0) {
console.log("Non-fatal error" + (nonFatalErrors.length > 1 ? "s" : "") + ":");
nonFatalErrors.forEach(function (err) {
err.split("\n").forEach(function (err) {
console.log(" ", err);
})
});
}
if (warnings.length > 0) {
console.log("Warning" + (nonFatalErrors.length > 1 ? "s" : "") + ":");
warnings.forEach(function (err) {
err.split("\n").forEach(function (err) {
console.log(" ", err);
})
});
}
if (err) {
console.error("Building failed!");
cb(false);
} else {
console.error("Building finished, but the result might not work!");
cb(true);
}
} else {
console.error("Building finished, but the result might not work!");
console.log("Building succeeded!");
cb(true);
}
} else {
console.log("Building succeeded!");
}
};
};
2 changes: 1 addition & 1 deletion src/lib/rebuildProject.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module.exports = function rebuildProject(entryGlob, artifactPath) {
jQuery: "jquery"
})
]
}, require("./handleWebpackResult"));
}, require("./handleWebpackResult")(function () {}));
});
});
};

0 comments on commit 139019b

Please sign in to comment.