Remove text qualifier

The type already enforces that. And it reads better and the call sites this way.
This commit is contained in:
Manav Rathi 2024-04-15 12:20:16 +05:30
parent 73ef03a5d9
commit 3ea4879cf0
No known key found for this signature in database
5 changed files with 14 additions and 14 deletions

View file

@ -20,7 +20,7 @@ export const fsRm = (path: string) => fs.rm(path);
export const fsReadTextFile = async (filePath: string) =>
fs.readFile(filePath, "utf-8");
export const fsWriteTextFile = (path: string, contents: string) =>
export const fsWriteFile = (path: string, contents: string) =>
fs.writeFile(path, contents);
/**

View file

@ -24,7 +24,7 @@ import {
fsRename,
fsRm,
fsRmdir,
fsWriteTextFile,
fsWriteFile,
isFolder,
saveStreamToDisk,
} from "./fs";
@ -129,8 +129,8 @@ export const attachIPCHandlers = () => {
ipcMain.handle("fsReadTextFile", (_, path: string) => fsReadTextFile(path));
ipcMain.handle("fsWriteTextFile", (_, path: string, contents: string) =>
fsWriteTextFile(path, contents),
ipcMain.handle("fsWriteFile", (_, path: string, contents: string) =>
fsWriteFile(path, contents),
);
// - Conversion

View file

@ -115,8 +115,8 @@ const fsRm = (path: string): Promise<void> => ipcRenderer.invoke("fsRm", path);
const fsReadTextFile = (path: string): Promise<string> =>
ipcRenderer.invoke("fsReadTextFile", path);
const fsWriteTextFile = (path: string, contents: string): Promise<void> =>
ipcRenderer.invoke("fsWriteTextFile", path, contents);
const fsWriteFile = (path: string, contents: string): Promise<void> =>
ipcRenderer.invoke("fsWriteFile", path, contents);
// - AUDIT below this
@ -326,7 +326,7 @@ contextBridge.exposeInMainWorld("electron", {
rmdir: fsRmdir,
rm: fsRm,
readTextFile: fsReadTextFile,
writeTextFile: fsWriteTextFile,
writeFile: fsWriteFile,
},
// - Conversion

View file

@ -884,7 +884,7 @@ class ExportService {
try {
const exportRecord = await this.getExportRecord(folder);
const newRecord: ExportRecord = { ...exportRecord, ...newData };
await ensureElectron().fs.writeTextFile(
await ensureElectron().fs.writeFile(
`${folder}/${exportRecordFileName}`,
JSON.stringify(newRecord, null, 2),
);
@ -1076,7 +1076,7 @@ class ExportService {
fileExportName: string,
file: EnteFile,
) {
await ensureElectron().fs.writeTextFile(
await ensureElectron().fs.writeFile(
getFileMetadataExportPath(collectionExportPath, fileExportName),
getGoogleLikeMetadataFile(fileExportName, file),
);
@ -1105,7 +1105,7 @@ class ExportService {
private createEmptyExportRecord = async (exportRecordJSONPath: string) => {
const exportRecord: ExportRecord = NULL_EXPORT_RECORD;
await ensureElectron().fs.writeTextFile(
await ensureElectron().fs.writeFile(
exportRecordJSONPath,
JSON.stringify(exportRecord, null, 2),
);

View file

@ -189,16 +189,16 @@ export interface Electron {
*/
rm: (path: string) => Promise<void>;
/** Read the string contents of a file at {@link path}. */
readTextFile: (path: string) => Promise<string>;
/**
* Write a string to a file, replacing the file if it already exists.
*
* @param path The path of the file.
* @param contents The string contents to write.
*/
writeTextFile: (path: string, contents: string) => Promise<void>;
/** Read the string contents of a file at {@link path}. */
readTextFile: (path: string) => Promise<string>;
writeFile: (path: string, contents: string) => Promise<void>;
};
/*