@cspell/cspell-tools
Version:
Tools to assist with the development of cSpell
14 lines • 576 B
JavaScript
import { promises as fs } from 'node:fs';
import { compress } from '../gzip/index.js';
const isGzFile = /\.gz$/;
export async function writeTextToFile(filename, data) {
const useGz = isGzFile.test(filename);
const buf = Buffer.from(data, 'utf8');
const buffer = useGz ? await compress(buf) : buf;
await fs.writeFile(filename, buffer);
}
export function writeTextLinesToFile(filename, lines) {
const data = Array.isArray(lines) ? lines.join('') : [...lines].join('');
return writeTextToFile(filename, data);
}
//# sourceMappingURL=writeTextToFile.js.map