mirror of
https://github.com/scratchfoundation/scratch-parser.git
synced 2025-08-28 22:18:45 -04:00
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:
parent
a74a97a906
commit
7f8672dfbc
3 changed files with 48 additions and 20 deletions
25
index.js
25
index.js
|
@ -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]]);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue