2018-03-25 19:08:52 -04:00
|
|
|
const AdmZip = require('adm-zip');
|
|
|
|
const fs = require('fs');
|
|
|
|
|
|
|
|
module.exports = {
|
2018-04-05 13:46:07 -04:00
|
|
|
readFileToBuffer: function (path) {
|
2018-03-25 19:08:52 -04:00
|
|
|
return new Buffer(fs.readFileSync(path));
|
|
|
|
},
|
2018-04-05 13:46:07 -04:00
|
|
|
extractProjectJson: function (path) {
|
2018-03-25 19:08:52 -04:00
|
|
|
const zip = new AdmZip(path);
|
2019-02-12 05:24:26 -05:00
|
|
|
const projectEntry = zip.getEntries().filter(item => item.entryName.match(/project\.json/))[0];
|
|
|
|
if (projectEntry) {
|
|
|
|
return JSON.parse(zip.readAsText(projectEntry.entryName, 'utf8'));
|
|
|
|
}
|
|
|
|
return null;
|
2018-03-25 19:08:52 -04:00
|
|
|
}
|
|
|
|
};
|