From 45be37a5cc67698652a166fc4ca34658dac80eb1 Mon Sep 17 00:00:00 2001 From: Aylur Date: Tue, 6 Feb 2024 13:55:03 +0100 Subject: [PATCH] add Utils.writeFileSync --- CHANGELOG.md | 6 ++++++ src/utils.ts | 2 ++ src/utils/file.ts | 10 ++++++++++ version | 2 +- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dfcd32d3..f4fb8729 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 1.7.6 + +## Features + +- Utils.writeFileSync + # 1.7.5 ## Features diff --git a/src/utils.ts b/src/utils.ts index 3453513a..9263bf57 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -22,6 +22,7 @@ export const { readFile, readFileAsync, writeFile, + writeFileSync, monitorFile, } = File; @@ -65,6 +66,7 @@ export default { readFile, readFileAsync, writeFile, + writeFileSync, monitorFile, timeout, diff --git a/src/utils/file.ts b/src/utils/file.ts index 37aae415..8c82fb8f 100644 --- a/src/utils/file.ts +++ b/src/utils/file.ts @@ -59,6 +59,16 @@ export function writeFile(string: string, path: string): Promise { }); } +export function writeFileSync(string: string, path: string) { + const file = Gio.File.new_for_path(path); + return file.replace_contents( + new TextEncoder().encode(string), + null, + false, + Gio.FileCreateFlags.REPLACE_DESTINATION, + null); +} + const fileMonitors: Map = new Map; export function monitorFile( path: string, diff --git a/version b/version index 6a126f40..de28578a 100644 --- a/version +++ b/version @@ -1 +1 @@ -1.7.5 +1.7.6