mirror of
https://github.com/scratchfoundation/scratch-parser.git
synced 2025-08-28 22:18:45 -04:00
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.
21 lines
702 B
JavaScript
21 lines
702 B
JavaScript
var JSZip = require('jszip');
|
|
|
|
/**
|
|
* Unpacks a zip file.
|
|
* @param {string} input Zip file provided as a string
|
|
* @param {array} callback Array including both the project and zip archive
|
|
* @return {void}
|
|
*/
|
|
module.exports = function (input, callback) {
|
|
return JSZip.loadAsync(input)
|
|
.then(function (zip) {
|
|
return zip.file('project.json').async('string')
|
|
.then(function (project) {
|
|
return callback(null, [project, zip]);
|
|
});
|
|
})
|
|
.catch(function (err) {
|
|
var msg = 'Failed to unzip and extract project.json, with error: ';
|
|
return callback(msg + JSON.stringify(err));
|
|
});
|
|
};
|