mirror of
https://github.com/danbulant/bpm
synced 2026-06-20 06:51:06 +00:00
Working on package.json parser
This commit is contained in:
parent
8be20adb9d
commit
ab1c3c3464
1 changed files with 19 additions and 0 deletions
19
modules/package.js
Normal file
19
modules/package.js
Normal 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;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue