remove pify

This commit is contained in:
Labhansh Agrawal 2023-02-21 13:29:00 +05:30
parent 591c692349
commit 605b29f4fa
6 changed files with 10 additions and 22 deletions

View file

@ -1,5 +1,4 @@
import pify from 'pify';
import fs from 'fs';
import {existsSync, readlink, symlink} from 'fs';
import path from 'path';
import notify from '../notify';
import {cliScriptPath, cliLinkPath} from '../config/paths';
@ -8,13 +7,14 @@ import type {ValueType} from 'native-reg';
import sudoPrompt from 'sudo-prompt';
import {clipboard, dialog} from 'electron';
import {mkdirpSync} from 'fs-extra';
import {promisify} from 'util';
const readlink = pify(fs.readlink);
const symlink = pify(fs.symlink);
const sudoExec = pify(sudoPrompt.exec, {multiArgs: true});
const readLink = promisify(readlink);
const symLink = promisify(symlink);
const sudoExec = promisify(sudoPrompt.exec);
const checkInstall = () => {
return readlink(cliLinkPath)
return readLink(cliLinkPath)
.then((link) => link === cliScriptPath)
.catch((err) => {
if (err.code === 'ENOENT') {
@ -32,14 +32,14 @@ const addSymlink = async (silent: boolean) => {
return;
}
console.log('Linking HyperCLI');
if (!fs.existsSync(path.dirname(cliLinkPath))) {
if (!existsSync(path.dirname(cliLinkPath))) {
try {
mkdirpSync(path.dirname(cliLinkPath));
} catch (err) {
throw `Failed to create directory ${path.dirname(cliLinkPath)} - ${err}`;
}
}
await symlink(cliScriptPath, cliLinkPath);
await symLink(cliScriptPath, cliLinkPath);
} catch (_err) {
const err = _err as {code: string};
// 'EINVAL' is returned by readlink,