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) => export const fsReadTextFile = async (filePath: string) =>
fs.readFile(filePath, "utf-8"); fs.readFile(filePath, "utf-8");
export const fsWriteTextFile = (path: string, contents: string) => export const fsWriteFile = (path: string, contents: string) =>
fs.writeFile(path, contents); fs.writeFile(path, contents);
/** /**

View file

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

View file

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

View file

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

View file

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