scratch-vm/test/fixtures/readProjectFile.js
2019-02-11 10:24:34 +01:00

16 lines
512 B
JavaScript

const AdmZip = require('adm-zip');
const fs = require('fs');
module.exports = {
readFileToBuffer: function (path) {
return new Buffer(fs.readFileSync(path));
},
extractProjectJson: function (path) {
const zip = new AdmZip(path);
return JSON.parse(zip.readAsText('project.json', 'utf8'));
},
extractNestedProjectJson: function (path, folder) {
const zip = new AdmZip(path);
return JSON.parse(zip.readAsText(`${folder}/project.json`, 'utf8'));
}
};