mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-17 05:58:41 -09:00
Fix type errors due to unknow type in try catch
This commit is contained in:
parent
b5cc6e7662
commit
c6dfab9e67
6 changed files with 17 additions and 9 deletions
|
|
@ -16,7 +16,8 @@ const _extract = (script?: vm.Script): Record<string, any> => {
|
||||||
const _syntaxValidation = (cfg: string) => {
|
const _syntaxValidation = (cfg: string) => {
|
||||||
try {
|
try {
|
||||||
return new vm.Script(cfg, {filename: '.hyper.js', displayErrors: true});
|
return new vm.Script(cfg, {filename: '.hyper.js', displayErrors: true});
|
||||||
} catch (err) {
|
} catch (_err) {
|
||||||
|
const err = _err as {name: string};
|
||||||
notify(`Error loading config: ${err.name}`, `${err}`, {error: err});
|
notify(`Error loading config: ${err.name}`, `${err}`, {error: err});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -296,7 +296,8 @@ function requirePlugins(): any[] {
|
||||||
console.log(`Plugin ${mod._name} (${mod._version}) loaded.`);
|
console.log(`Plugin ${mod._name} (${mod._version}) loaded.`);
|
||||||
|
|
||||||
return mod;
|
return mod;
|
||||||
} catch (err) {
|
} catch (_err) {
|
||||||
|
const err = _err as {code: string; message: string};
|
||||||
if (err.code === 'MODULE_NOT_FOUND') {
|
if (err.code === 'MODULE_NOT_FOUND') {
|
||||||
console.warn(`Plugin error while loading "${basename(path_)}" (${path_}): ${err.message}`);
|
console.warn(`Plugin error while loading "${basename(path_)}" (${path_}): ${err.message}`);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,8 @@ export default class Session extends EventEmitter {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.pty = spawn(shell, shellArgs, options);
|
this.pty = spawn(shell, shellArgs, options);
|
||||||
} catch (err) {
|
} catch (_err) {
|
||||||
|
const err = _err as {message: string};
|
||||||
if (/is not a function/.test(err.message)) {
|
if (/is not a function/.test(err.message)) {
|
||||||
throw createNodePtyError();
|
throw createNodePtyError();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -215,7 +216,8 @@ fallback to default shell config: ${JSON.stringify(defaultShellConfig, undefined
|
||||||
if (this.pty) {
|
if (this.pty) {
|
||||||
try {
|
try {
|
||||||
this.pty.resize(cols, rows);
|
this.pty.resize(cols, rows);
|
||||||
} catch (err) {
|
} catch (_err) {
|
||||||
|
const err = _err as {stack: any};
|
||||||
console.error(err.stack);
|
console.error(err.stack);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -227,7 +229,8 @@ fallback to default shell config: ${JSON.stringify(defaultShellConfig, undefined
|
||||||
if (this.pty) {
|
if (this.pty) {
|
||||||
try {
|
try {
|
||||||
this.pty.kill();
|
this.pty.kill();
|
||||||
} catch (err) {
|
} catch (_err) {
|
||||||
|
const err = _err as {stack: any};
|
||||||
console.error('exit error', err.stack);
|
console.error('exit error', err.stack);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,8 @@ const addSymlink = async (silent: boolean) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await symlink(cliScriptPath, cliLinkPath);
|
await symlink(cliScriptPath, cliLinkPath);
|
||||||
} catch (err) {
|
} catch (_err) {
|
||||||
|
const err = _err as {code: string};
|
||||||
// 'EINVAL' is returned by readlink,
|
// 'EINVAL' is returned by readlink,
|
||||||
// 'EEXIST' is returned by symlink
|
// 'EEXIST' is returned by symlink
|
||||||
let error =
|
let error =
|
||||||
|
|
@ -61,7 +62,7 @@ sudo ln -sf "${cliScriptPath}" "${cliLinkPath}"`,
|
||||||
await sudoExec(`ln -sf "${cliScriptPath}" "${cliLinkPath}"`, {name: 'Hyper'});
|
await sudoExec(`ln -sf "${cliScriptPath}" "${cliLinkPath}"`, {name: 'Hyper'});
|
||||||
return;
|
return;
|
||||||
} catch (_error) {
|
} catch (_error) {
|
||||||
error = _error[0];
|
error = (_error as any[])[0];
|
||||||
}
|
}
|
||||||
} else if (result.response === 1) {
|
} else if (result.response === 1) {
|
||||||
clipboard.writeText(`sudo ln -sf "${cliScriptPath}" "${cliLinkPath}"`);
|
clipboard.writeText(`sudo ln -sf "${cliScriptPath}" "${cliLinkPath}"`);
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,8 @@ function memoize<T extends (...args: any[]) => any>(fn: T): T {
|
||||||
const getFileContents = memoize(() => {
|
const getFileContents = memoize(() => {
|
||||||
try {
|
try {
|
||||||
return fs.readFileSync(fileName, 'utf8');
|
return fs.readFileSync(fileName, 'utf8');
|
||||||
} catch (err) {
|
} catch (_err) {
|
||||||
|
const err = _err as {code: string};
|
||||||
if (err.code !== 'ENOENT') {
|
if (err.code !== 'ENOENT') {
|
||||||
// ENOENT === !exists()
|
// ENOENT === !exists()
|
||||||
throw err;
|
throw err;
|
||||||
|
|
|
||||||
|
|
@ -352,7 +352,8 @@ export default class Term extends React.PureComponent<TermProps> {
|
||||||
.forEach((option) => {
|
.forEach((option) => {
|
||||||
try {
|
try {
|
||||||
this.term.setOption(option, nextTermOptions[option]);
|
this.term.setOption(option, nextTermOptions[option]);
|
||||||
} catch (e) {
|
} catch (_e) {
|
||||||
|
const e = _e as {message: string};
|
||||||
if (/The webgl renderer only works with the webgl char atlas/i.test(e.message)) {
|
if (/The webgl renderer only works with the webgl char atlas/i.test(e.message)) {
|
||||||
// Ignore this because the char atlas will also be changed
|
// Ignore this because the char atlas will also be changed
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue