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

Method writedata

jd_try.js:664–681  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

662 }
663
664 writedata() {
665 if (this.isNode()) {
666 this.fs = this.fs ? this.fs : require('fs')
667 this.path = this.path ? this.path : require('path')
668 const curDirDataFilePath = this.path.resolve(this.dataFile)
669 const rootDirDataFilePath = this.path.resolve(process.cwd(), this.dataFile)
670 const isCurDirDataFile = this.fs.existsSync(curDirDataFilePath)
671 const isRootDirDataFile = !isCurDirDataFile && this.fs.existsSync(rootDirDataFilePath)
672 const jsondata = JSON.stringify(this.data)
673 if (isCurDirDataFile) {
674 this.fs.writeFileSync(curDirDataFilePath, jsondata)
675 } else if (isRootDirDataFile) {
676 this.fs.writeFileSync(rootDirDataFilePath, jsondata)
677 } else {
678 this.fs.writeFileSync(curDirDataFilePath, jsondata)
679 }
680 }
681 }
682
683 lodash_get(source, path, defaultValue = undefined) {
684 const paths = path.replace(/\[(\d+)\]/g, '.$1').split('.')

Callers 1

setvalMethod · 0.45

Calls 1

isNodeMethod · 0.45

Tested by

no test coverage detected