Working on package.json parser

This commit is contained in:
danbulant 2020-02-19 17:11:21 +01:00
parent 8be20adb9d
commit ab1c3c3464

19
modules/package.js Normal file
View file

@ -0,0 +1,19 @@
const fs = require("fs");
module.exports = class Package {
pkg = {};
load(path){
if(!fs.existsSync(path))throw Error("Path doesn't exists!");
try {
var json = JSON.parse(fs.readFileSync(path));
} catch(e){
throw Error("Invalid JSON file");
}
this.pkg = json;
return json;
}
}