writeOutputFile.js 476 B

1234567891011121314151617
  1. 'use strict';
  2. const path = require('path');
  3. const { mkdir } = require('fs').promises;
  4. const stripAnsi = require('strip-ansi');
  5. const writeFileAtomic = require('write-file-atomic');
  6. /**
  7. * @param {string} content
  8. * @param {string} filePath
  9. * @returns {Promise<void>}
  10. */
  11. module.exports = async function writeOutputFile(content, filePath) {
  12. await mkdir(path.dirname(filePath), { recursive: true });
  13. await writeFileAtomic(path.normalize(filePath), stripAnsi(content));
  14. };