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