refactor($lib): Add callback wrapper around JSZip promise-based interface. Refactor m

Refactor unpack and main exported function to return optional zip, if originally provided, in
addition to the validated project.

BREAKING CHANGE: Change to main api to return originally provided zip (or null if string was
provided) along with validated project, in a 2-element array.
This commit is contained in:
Karishma Chadha 2018-03-15 18:25:36 -04:00
parent a74a97a906
commit 7f8672dfbc
3 changed files with 48 additions and 20 deletions

View file

@ -14,12 +14,21 @@ var analyze = require('./lib/analyze');
* @return {Object}
*/
module.exports = function (input, callback) {
async.waterfall([
function (cb) {
unpack(input, cb);
},
parse,
validate,
analyze
], callback);
unpack(input, function(err, unpackedProject) {
if (err) {
return callback(err);
}
async.waterfall([
function (cb) {
parse(unpackedProject[0], cb);
},
validate,
analyze
], function(err2, validatedInput) {
if (err2) {
return callback(err2);
}
callback(null, [validatedInput, unpackedProject[1]]);
});
});
};