MCPcopy Create free account
hub / github.com/Semporia/Scripts / loaddata

Method loaddata

jd_try.js:645–662  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

643 }
644
645 loaddata() {
646 if (this.isNode()) {
647 this.fs = this.fs ? this.fs : require('fs')
648 this.path = this.path ? this.path : require('path')
649 const curDirDataFilePath = this.path.resolve(this.dataFile)
650 const rootDirDataFilePath = this.path.resolve(process.cwd(), this.dataFile)
651 const isCurDirDataFile = this.fs.existsSync(curDirDataFilePath)
652 const isRootDirDataFile = !isCurDirDataFile && this.fs.existsSync(rootDirDataFilePath)
653 if (isCurDirDataFile || isRootDirDataFile) {
654 const datPath = isCurDirDataFile ? curDirDataFilePath : rootDirDataFilePath
655 try {
656 return JSON.parse(this.fs.readFileSync(datPath))
657 } catch (e) {
658 return {}
659 }
660 } else return {}
661 } else return {}
662 }
663
664 writedata() {
665 if (this.isNode()) {

Callers 2

getvalMethod · 0.45
setvalMethod · 0.45

Calls 1

isNodeMethod · 0.45

Tested by

no test coverage detected