MCPcopy
hub / github.com/chavyleung/scripts / writedata

Method writedata

Env.js:203–224  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

201 }
202
203 writedata() {
204 if (this.isNode()) {
205 this.fs = this.fs ? this.fs : require('fs')
206 this.path = this.path ? this.path : require('path')
207 const curDirDataFilePath = this.path.resolve(this.dataFile)
208 const rootDirDataFilePath = this.path.resolve(
209 process.cwd(),
210 this.dataFile
211 )
212 const isCurDirDataFile = this.fs.existsSync(curDirDataFilePath)
213 const isRootDirDataFile =
214 !isCurDirDataFile && this.fs.existsSync(rootDirDataFilePath)
215 const jsondata = JSON.stringify(this.data)
216 if (isCurDirDataFile) {
217 this.fs.writeFileSync(curDirDataFilePath, jsondata)
218 } else if (isRootDirDataFile) {
219 this.fs.writeFileSync(rootDirDataFilePath, jsondata)
220 } else {
221 this.fs.writeFileSync(curDirDataFilePath, jsondata)
222 }
223 }
224 }
225
226 lodash_get(source, path, defaultValue = undefined) {
227 const paths = path.replace(/\[(\d+)\]/g, '.$1').split('.')

Callers 1

setvalMethod · 0.45

Calls 1

isNodeMethod · 0.45

Tested by

no test coverage detected