@dbml/cli
Version:
See our website [@dbml/cli](https://dbml.dbdiagram.io/cli/) for more information
24 lines (19 loc) • 506 B
JavaScript
import fs from 'fs';
class OutputFilePlugin {
constructor (filePath, header) {
this.filePath = filePath;
this.header = header;
this.isWrite = false;
}
start () {
fs.writeFileSync(this.filePath, '');
this.stream = fs.createWriteStream(this.filePath, { flags: 'a' });
if (this.header) this.stream.write(this.header);
this.isWrite = true;
}
write (content) {
if (!this.isWrite) this.start();
this.stream.write(content);
}
}
export default OutputFilePlugin;