mirror of
				https://github.com/zulip/zulip-desktop.git
				synced 2025-11-04 05:53:21 +00:00 
			
		
		
		
	Remove fs-extra dependency.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
		@@ -1,9 +1,9 @@
 | 
			
		||||
import {ipcRenderer, remote, OpenDialogOptions} from 'electron';
 | 
			
		||||
import fs from 'fs';
 | 
			
		||||
import path from 'path';
 | 
			
		||||
 | 
			
		||||
import Tagify from '@yaireo/tagify';
 | 
			
		||||
import {htmlEscape} from 'escape-goat';
 | 
			
		||||
import fs from 'fs-extra';
 | 
			
		||||
import ISO6391 from 'iso-639-1';
 | 
			
		||||
 | 
			
		||||
import supportedLocales from '../../../../translations/supported-locales.json';
 | 
			
		||||
@@ -494,7 +494,7 @@ export default class GeneralSection extends BaseSection {
 | 
			
		||||
			detail: clearAppDataMessage
 | 
			
		||||
		});
 | 
			
		||||
		if (response === 0) {
 | 
			
		||||
			await fs.remove(getAppPath);
 | 
			
		||||
			await fs.promises.rmdir(getAppPath, {recursive: true});
 | 
			
		||||
			setTimeout(() => ipcRenderer.send('clear-app-settings'), 1000);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -70,9 +70,9 @@ export default class Logger {
 | 
			
		||||
 | 
			
		||||
		// Trim log according to type of process
 | 
			
		||||
		if (process.type === 'renderer') {
 | 
			
		||||
			requestIdleCallback(() => this.trimLog(file));
 | 
			
		||||
			requestIdleCallback(async () => this.trimLog(file));
 | 
			
		||||
		} else {
 | 
			
		||||
			process.nextTick(() => this.trimLog(file));
 | 
			
		||||
			process.nextTick(async () => this.trimLog(file));
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		const fileStream = fs.createWriteStream(file, {flags: 'a'});
 | 
			
		||||
@@ -133,11 +133,8 @@ export default class Logger {
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	trimLog(file: string): void {
 | 
			
		||||
		fs.readFile(file, 'utf8', (err, data) => {
 | 
			
		||||
			if (err) {
 | 
			
		||||
				throw err;
 | 
			
		||||
			}
 | 
			
		||||
	async trimLog(file: string): Promise<void> {
 | 
			
		||||
		const data = await fs.promises.readFile(file, 'utf8');
 | 
			
		||||
 | 
			
		||||
		const MAX_LOG_FILE_LINES = 500;
 | 
			
		||||
		const logs = data.split(os.EOL);
 | 
			
		||||
@@ -147,8 +144,7 @@ export default class Logger {
 | 
			
		||||
		if (logLength > MAX_LOG_FILE_LINES) {
 | 
			
		||||
			const trimmedLogs = logs.slice(logLength - MAX_LOG_FILE_LINES);
 | 
			
		||||
			const toWrite = trimmedLogs.join(os.EOL);
 | 
			
		||||
				fs.writeFileSync(file, toWrite);
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
			await fs.promises.writeFile(file, toWrite);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,7 @@
 | 
			
		||||
    "url": "https://github.com/zulip/zulip-desktop/issues"
 | 
			
		||||
  },
 | 
			
		||||
  "engines": {
 | 
			
		||||
    "node": ">=10.0.0"
 | 
			
		||||
    "node": ">=12.10.0"
 | 
			
		||||
  },
 | 
			
		||||
  "scripts": {
 | 
			
		||||
    "start": "tsc && electron .",
 | 
			
		||||
@@ -156,7 +156,6 @@
 | 
			
		||||
    "electron-updater": "^4.3.5",
 | 
			
		||||
    "electron-window-state": "^5.0.3",
 | 
			
		||||
    "escape-goat": "^3.0.0",
 | 
			
		||||
    "fs-extra": "^9.0.1",
 | 
			
		||||
    "get-stream": "^6.0.0",
 | 
			
		||||
    "i18n": "^0.13.2",
 | 
			
		||||
    "iso-639-1": "^2.1.4",
 | 
			
		||||
@@ -167,7 +166,6 @@
 | 
			
		||||
    "@types/adm-zip": "^0.4.33",
 | 
			
		||||
    "@types/auto-launch": "^5.0.1",
 | 
			
		||||
    "@types/backoff": "^2.5.1",
 | 
			
		||||
    "@types/fs-extra": "^9.0.4",
 | 
			
		||||
    "@types/i18n": "^0.8.8",
 | 
			
		||||
    "@types/node": "^14.14.10",
 | 
			
		||||
    "@types/requestidlecallback": "^0.3.1",
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user