| 1068 | } |
| 1069 | |
| 1070 | loaddata() { |
| 1071 | if (!this.isNode()) return {}; |
| 1072 | { |
| 1073 | this.fs = this.fs ? this.fs : require("fs"), this.path = this.path ? this.path : require("path"); |
| 1074 | const t = this.path.resolve(this.dataFile), e = this.path.resolve(process.cwd(), this.dataFile), |
| 1075 | s = this.fs.existsSync(t), i = !s && this.fs.existsSync(e); |
| 1076 | if (!s && !i) return {}; |
| 1077 | { |
| 1078 | const i = s ? t : e; |
| 1079 | try { |
| 1080 | return JSON.parse(this.fs.readFileSync(i)) |
| 1081 | } catch (t) { |
| 1082 | return {} |
| 1083 | } |
| 1084 | } |
| 1085 | } |
| 1086 | } |
| 1087 | |
| 1088 | writedata() { |
| 1089 | if (this.isNode()) { |