Skip to content

Commit

Permalink
add Utils.writeFileSync
Browse files Browse the repository at this point in the history
  • Loading branch information
Aylur committed Feb 6, 2024
1 parent 109faf5 commit 45be37a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 1.7.6

## Features

- Utils.writeFileSync

# 1.7.5

## Features
Expand Down
2 changes: 2 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const {
readFile,
readFileAsync,
writeFile,
writeFileSync,
monitorFile,
} = File;

Expand Down Expand Up @@ -65,6 +66,7 @@ export default {
readFile,
readFileAsync,
writeFile,
writeFileSync,
monitorFile,

timeout,
Expand Down
10 changes: 10 additions & 0 deletions src/utils/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ export function writeFile(string: string, path: string): Promise<Gio.File> {
});
}

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<Gio.FileMonitor, boolean> = new Map;
export function monitorFile(
path: string,
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.7.5
1.7.6

0 comments on commit 45be37a

Please sign in to comment.