mirror of
https://gh.wpcy.net/https://github.com/djav1985/v-wordpress-plugin-updater.git
synced 2026-04-26 06:07:35 +08:00
15 lines
489 B
JavaScript
15 lines
489 B
JavaScript
import { dirname, normalize } from 'node:path';
|
|
import { mkdir } from 'node:fs/promises';
|
|
import { stripVTControlCharacters } from 'node:util';
|
|
import writeFileAtomic from 'write-file-atomic';
|
|
|
|
/**
|
|
* @param {string} content
|
|
* @param {string} filePath
|
|
* @returns {Promise<void>}
|
|
*/
|
|
export default async function writeOutputFile(content, filePath) {
|
|
await mkdir(dirname(filePath), { recursive: true });
|
|
|
|
await writeFileAtomic(normalize(filePath), stripVTControlCharacters(content));
|
|
}
|