@maticnetwork/matic-cli
Version:
Testing toolkit to setup, manage and operate Polygon networks
30 lines (23 loc) • 527 B
JavaScript
// noinspection JSUnresolvedFunction
import fs from 'fs-extra'
class FileReplacer {
constructor(f, options = {}) {
this.file = f
this.options = options
// load content
this.data = fs.readFileSync(f, 'utf8')
}
replace(...args) {
this.data = this.data.replace(...args)
return this
}
save() {
fs.writeFileSync(this.file, this.data, {
mode: this.options.mode || 0o755
})
return this
}
}
export default function (f, options = {}) {
return new FileReplacer(f, options)
}