scratch-vm/test/fixtures/readProjectFile.js
adroitwhiz 3c9f7557f5 Replace new Buffer() with Buffer.from()
This removes the deprecation warnings logged when tests are run.
2021-03-07 16:21:06 -05:00

16 lines
510 B
JavaScript

const AdmZip = require('adm-zip');
const fs = require('fs');
module.exports = {
readFileToBuffer: function (path) {
return Buffer.from(fs.readFileSync(path));
},
extractProjectJson: function (path) {
const zip = new AdmZip(path);
const projectEntry = zip.getEntries().filter(item => item.entryName.match(/project\.json/))[0];
if (projectEntry) {
return JSON.parse(zip.readAsText(projectEntry.entryName, 'utf8'));
}
return null;
}
};