UNPKG

@sunamo/sunodejs

Version:

Node.js utilities for file system operations, process management, and Electron apps. Includes TypeScript support with functions for file operations, directory management, and cross-platform compatibility.

18 lines (17 loc) 581 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.writeAllLines = writeAllLines; const promises_1 = require("fs/promises"); const path_1 = require("path"); async function writeAllLines(log, filePath, lines) { const { error } = log; try { const dir = (0, path_1.dirname)(filePath); await (0, promises_1.mkdir)(dir, { recursive: true }); await (0, promises_1.writeFile)(filePath, lines.join("\n"), "utf8"); } catch (err) { error(`Error writing to file: ${filePath}`, err); throw err; } }