mirror of
https://github.com/scratchfoundation/scratch-parser.git
synced 2025-08-28 22:18:45 -04:00
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.
20 lines
447 B
JavaScript
20 lines
447 B
JavaScript
var JSZip = require('jszip');
|
|
|
|
/**
|
|
* Unpacks a zip
|
|
*
|
|
* @param {String} Input
|
|
*
|
|
* @return {Object}
|
|
*/
|
|
module.exports = function (input, callback) {
|
|
JSZip.loadAsync(input).then(function (zip) {
|
|
zip.file('project.json').async('string')
|
|
.then(function (project) {
|
|
callback(null, [project, zip]);
|
|
})
|
|
.catch(function (err) {
|
|
callback(err);
|
|
});
|
|
});
|
|
};
|