mirror of
https://github.com/scratchfoundation/scratch-parser.git
synced 2025-08-28 22:18:45 -04:00
refactor: Merge changes from upstream and resolve issues with interface and test coverage
Merges in changes from upstream and resolves issues with both the removal of the analysis library as well as issues with lint rules and integration tests.
This commit is contained in:
commit
0fe264a05b
16 changed files with 638 additions and 59 deletions
34
index.js
34
index.js
|
@ -5,17 +5,27 @@ var parse = require('./lib/parse');
|
|||
var validate = require('./lib/validate');
|
||||
|
||||
/**
|
||||
* Unpacks, parses, validates, and analyzes Scratch projects. If successful,
|
||||
* will return a valid Scratch project object with appended metadata.
|
||||
* @param {Buffer | string} input Buffer or string representing project
|
||||
* @param {Function} callback Returns error or project data
|
||||
*/
|
||||
* Unpacks, parses, validates, and analyzes Scratch projects. If successful,
|
||||
* will return a valid Scratch project object with appended metadata.
|
||||
* @param {Buffer | string} input Buffer or string representing project
|
||||
* @param {Function} callback Returns error or project data
|
||||
*/
|
||||
module.exports = function (input, callback) {
|
||||
async.waterfall([
|
||||
function (cb) {
|
||||
unpack(input, cb);
|
||||
},
|
||||
parse,
|
||||
validate
|
||||
], callback);
|
||||
// First unpack the input (need this outside of the async waterfall so that
|
||||
// unpackedProject can be refered to again)
|
||||
unpack(input, function (err, unpackedProject) {
|
||||
if (err) return callback(err);
|
||||
|
||||
async.waterfall([
|
||||
function (cb) {
|
||||
parse(unpackedProject[0], cb);
|
||||
},
|
||||
validate
|
||||
], function (error, validatedInput) {
|
||||
// One more callback wrapper so that we can re-package everything
|
||||
// with the possible zip returned from unpack
|
||||
if (error) return callback(error);
|
||||
callback(null, [validatedInput, unpackedProject[1]]);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue