Replace mkdirp with native fs.mkdir
Prior to this change, Signal-Desktop was using a rather ancient version of `mkdirp`, which was meant for Node.js versions without native support for this kind of functionality. Starting with Node v10, `fs.mkdir()` can perform recursive directory creation. Since Signal-Desktop doesn't utilize any advantages of using such an old version of `mkdirp` [1] (let alone any version of `mkdirp`), we can replace it with the native methods of `fs` (or `fs/promises`). This transition slightly reduces the amount of packages needed to be downloaded and included in the final app since it now relies on the built-in API of Node.js.
This commit is contained in:
parent
16c9c17cc2
commit
7cd566726f
6 changed files with 16 additions and 53 deletions
|
@ -4,7 +4,7 @@
|
|||
/* eslint-disable no-console */
|
||||
import { createWriteStream } from 'fs';
|
||||
import { pathExists } from 'fs-extra';
|
||||
import { readdir, stat, writeFile } from 'fs/promises';
|
||||
import { readdir, stat, writeFile, mkdir } from 'fs/promises';
|
||||
import { promisify } from 'util';
|
||||
import { execFile } from 'child_process';
|
||||
import { join, normalize, extname } from 'path';
|
||||
|
@ -19,7 +19,6 @@ import config from 'config';
|
|||
import got from 'got';
|
||||
import { v4 as getGuid } from 'uuid';
|
||||
import pify from 'pify';
|
||||
import mkdirp from 'mkdirp';
|
||||
import rimraf from 'rimraf';
|
||||
import type { BrowserWindow } from 'electron';
|
||||
import { app, ipcMain } from 'electron';
|
||||
|
@ -51,7 +50,6 @@ import {
|
|||
isValidPreparedData as isValidDifferentialData,
|
||||
} from './differential';
|
||||
|
||||
const mkdirpPromise = pify(mkdirp);
|
||||
const rimrafPromise = pify(rimraf);
|
||||
|
||||
const INTERVAL = 30 * durations.MINUTE;
|
||||
|
@ -860,7 +858,7 @@ function getBaseTempDir() {
|
|||
export async function createTempDir(): Promise<string> {
|
||||
const targetDir = await getTempDir();
|
||||
|
||||
await mkdirpPromise(targetDir);
|
||||
await mkdir(targetDir, { recursive: true });
|
||||
|
||||
return targetDir;
|
||||
}
|
||||
|
@ -871,7 +869,7 @@ export async function getTempDir(): Promise<string> {
|
|||
|
||||
// Create parent folder if not already present
|
||||
if (!(await pathExists(baseTempDir))) {
|
||||
await mkdirpPromise(baseTempDir);
|
||||
await mkdir(baseTempDir, { recursive: true });
|
||||
}
|
||||
|
||||
return join(baseTempDir, uniqueName);
|
||||
|
@ -884,7 +882,7 @@ function getUpdateCacheDir() {
|
|||
|
||||
export async function createUpdateCacheDirIfNeeded(): Promise<string> {
|
||||
const targetDir = getUpdateCacheDir();
|
||||
await mkdirpPromise(targetDir);
|
||||
await mkdir(targetDir, { recursive: true });
|
||||
|
||||
return targetDir;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue