diff --git a/modules/package.js b/modules/package.js new file mode 100644 index 0000000..87b917e --- /dev/null +++ b/modules/package.js @@ -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; + } +} \ No newline at end of file