Path.writeTextSync() method
pathlib-ts > Path > writeTextSync
Path.writeTextSync() method
Section titled “Path.writeTextSync() method”Write the given text to the file using the provided encoding.
An existing file of the same name is overwritten.
Signature:
writeTextSync(data: string, encoding?: BufferEncoding): void;Parameters
Section titled “Parameters”|
Parameter |
Type |
Description |
|---|---|---|
|
data |
string |
Text to persist. |
|
encoding |
BufferEncoding |
(Optional) Encoding to use (defaults to |
Returns:
void
Remarks
Section titled “Remarks”Mirrors Path.writeText() but executes synchronously.
Example
Section titled “Example”Writing CLI output synchronously
import { Path } from "pathlib-ts";
const report = new Path("./report.txt");report.writeTextSync("Report generated\n");