MCPcopy Index your code
hub / github.com/chavyleung/scripts / loaddata

Method loaddata

Env.js:178–201  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

176 }
177
178 loaddata() {
179 if (this.isNode()) {
180 this.fs = this.fs ? this.fs : require('fs')
181 this.path = this.path ? this.path : require('path')
182 const curDirDataFilePath = this.path.resolve(this.dataFile)
183 const rootDirDataFilePath = this.path.resolve(
184 process.cwd(),
185 this.dataFile
186 )
187 const isCurDirDataFile = this.fs.existsSync(curDirDataFilePath)
188 const isRootDirDataFile =
189 !isCurDirDataFile && this.fs.existsSync(rootDirDataFilePath)
190 if (isCurDirDataFile || isRootDirDataFile) {
191 const datPath = isCurDirDataFile
192 ? curDirDataFilePath
193 : rootDirDataFilePath
194 try {
195 return JSON.parse(this.fs.readFileSync(datPath))
196 } catch (e) {
197 return {}
198 }
199 } else return {}
200 } else return {}
201 }
202
203 writedata() {
204 if (this.isNode()) {

Callers 2

getvalMethod · 0.45
setvalMethod · 0.45

Calls 1

isNodeMethod · 0.45

Tested by

no test coverage detected