mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
style: lint
This commit is contained in:
@@ -24,6 +24,7 @@ export function require_dlopen(modulename: string) {
|
|||||||
const module = { exports: {} };
|
const module = { exports: {} };
|
||||||
const import__dirname = dirname(fileURLToPath(import.meta.url));
|
const import__dirname = dirname(fileURLToPath(import.meta.url));
|
||||||
process.dlopen(module, path.join(import__dirname, modulename));
|
process.dlopen(module, path.join(import__dirname, modulename));
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
return module.exports as any;
|
return module.exports as any;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
1
src/pty/node-pty.d.ts
vendored
1
src/pty/node-pty.d.ts
vendored
@@ -225,6 +225,7 @@ declare module '@/pty' {
|
|||||||
* @returns an `IDisposable` to stop listening.
|
* @returns an `IDisposable` to stop listening.
|
||||||
*/
|
*/
|
||||||
export interface IEvent<T> {
|
export interface IEvent<T> {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
(listener: (e: T) => any): IDisposable;
|
(listener: (e: T) => any): IDisposable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
import { require_dlopen } from '.';
|
import { require_dlopen } from '.';
|
||||||
export function pty_loader() {
|
export function pty_loader() {
|
||||||
let pty: any;
|
let pty: any;
|
||||||
try {
|
try {
|
||||||
pty = require_dlopen('./pty/' + process.platform + '.' + process.arch + '/pty.node');
|
pty = require_dlopen('./pty/' + process.platform + '.' + process.arch + '/pty.node');
|
||||||
} catch (outerError) {
|
} catch {
|
||||||
pty = undefined;
|
pty = undefined;
|
||||||
}
|
}
|
||||||
return pty;
|
return pty;
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
/* eslint-disable prefer-rest-params */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
/* eslint-disable no-undef */
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2012-2015, Christopher Jeffrey (MIT License)
|
* Copyright (c) 2012-2015, Christopher Jeffrey (MIT License)
|
||||||
* Copyright (c) 2016, Daniel Imms (MIT License).
|
* Copyright (c) 2016, Daniel Imms (MIT License).
|
||||||
@@ -26,14 +27,14 @@ const DEFAULT_NAME = 'xterm';
|
|||||||
const DESTROY_SOCKET_TIMEOUT_MS = 200;
|
const DESTROY_SOCKET_TIMEOUT_MS = 200;
|
||||||
|
|
||||||
export class UnixTerminal extends Terminal {
|
export class UnixTerminal extends Terminal {
|
||||||
protected _fd: number;
|
protected override _fd: number;
|
||||||
protected _pty: string;
|
protected override _pty: string;
|
||||||
|
|
||||||
protected _file: string;
|
protected override _file: string;
|
||||||
protected _name: string;
|
protected override _name: string;
|
||||||
|
|
||||||
protected _readable: boolean;
|
protected override _readable: boolean;
|
||||||
protected _writable: boolean;
|
protected override _writable: boolean;
|
||||||
|
|
||||||
private _boundClose: boolean = false;
|
private _boundClose: boolean = false;
|
||||||
private _emittedClose: boolean = false;
|
private _emittedClose: boolean = false;
|
||||||
@@ -67,9 +68,9 @@ export class UnixTerminal extends Terminal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const cwd = opt.cwd || process.cwd();
|
const cwd = opt.cwd || process.cwd();
|
||||||
env.PWD = cwd;
|
env['PWD'] = cwd;
|
||||||
const name = opt.name || env.TERM || DEFAULT_NAME;
|
const name = opt.name || env['TERM'] || DEFAULT_NAME;
|
||||||
env.TERM = name;
|
env['TERM'] = name;
|
||||||
const parsedEnv = this._parseEnv(env);
|
const parsedEnv = this._parseEnv(env);
|
||||||
|
|
||||||
const encoding = (opt.encoding === undefined ? 'utf8' : opt.encoding);
|
const encoding = (opt.encoding === undefined ? 'utf8' : opt.encoding);
|
||||||
@@ -212,7 +213,7 @@ export class UnixTerminal extends Terminal {
|
|||||||
self._pty = term.pty;
|
self._pty = term.pty;
|
||||||
|
|
||||||
self._file = process.argv[0] || 'node';
|
self._file = process.argv[0] || 'node';
|
||||||
self._name = process.env.TERM || '';
|
self._name = process.env['TERM'] || '';
|
||||||
|
|
||||||
self._readable = true;
|
self._readable = true;
|
||||||
self._writable = true;
|
self._writable = true;
|
||||||
@@ -246,7 +247,7 @@ export class UnixTerminal extends Terminal {
|
|||||||
public kill(signal?: string): void {
|
public kill(signal?: string): void {
|
||||||
try {
|
try {
|
||||||
process.kill(this.pid, signal || 'SIGHUP');
|
process.kill(this.pid, signal || 'SIGHUP');
|
||||||
} catch (e) { /* swallow */ }
|
} catch { /* swallow */ }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
/* eslint-disable no-undef */
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2012-2015, Christopher Jeffrey, Peter Sunde (MIT License)
|
* Copyright (c) 2012-2015, Christopher Jeffrey, Peter Sunde (MIT License)
|
||||||
* Copyright (c) 2016, Daniel Imms (MIT License).
|
* Copyright (c) 2016, Daniel Imms (MIT License).
|
||||||
@@ -147,7 +149,7 @@ export class WindowsPtyAgent {
|
|||||||
consoleProcessList.forEach((pid: number) => {
|
consoleProcessList.forEach((pid: number) => {
|
||||||
try {
|
try {
|
||||||
process.kill(pid);
|
process.kill(pid);
|
||||||
} catch (e) {
|
} catch{
|
||||||
// Ignore if process cannot be found (kill ESRCH error)
|
// Ignore if process cannot be found (kill ESRCH error)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -165,7 +167,7 @@ export class WindowsPtyAgent {
|
|||||||
processList.forEach(pid => {
|
processList.forEach(pid => {
|
||||||
try {
|
try {
|
||||||
process.kill(pid);
|
process.kill(pid);
|
||||||
} catch (e) {
|
} catch {
|
||||||
// Ignore if process cannot be found (kill ESRCH error)
|
// Ignore if process cannot be found (kill ESRCH error)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -201,7 +203,7 @@ export class WindowsPtyAgent {
|
|||||||
const osVersion = (/(\d+)\.(\d+)\.(\d+)/g).exec(os.release());
|
const osVersion = (/(\d+)\.(\d+)\.(\d+)/g).exec(os.release());
|
||||||
let buildNumber: number = 0;
|
let buildNumber: number = 0;
|
||||||
if (osVersion && osVersion.length === 4) {
|
if (osVersion && osVersion.length === 4) {
|
||||||
buildNumber = parseInt(osVersion[3]);
|
buildNumber = parseInt(osVersion[3]!);
|
||||||
}
|
}
|
||||||
return buildNumber;
|
return buildNumber;
|
||||||
}
|
}
|
||||||
@@ -253,20 +255,20 @@ export function argsToCommandLine(file: string, args: ArgvOrCommandLine): string
|
|||||||
}
|
}
|
||||||
const arg = argv[argIndex];
|
const arg = argv[argIndex];
|
||||||
// if it is empty or it contains whitespace and is not already quoted
|
// if it is empty or it contains whitespace and is not already quoted
|
||||||
const hasLopsidedEnclosingQuote = xOr((arg[0] !== '"'), (arg[arg.length - 1] !== '"'));
|
const hasLopsidedEnclosingQuote = xOr((arg![0] !== '"'), (arg![arg!.length - 1] !== '"'));
|
||||||
const hasNoEnclosingQuotes = ((arg[0] !== '"') && (arg[arg.length - 1] !== '"'));
|
const hasNoEnclosingQuotes = ((arg![0] !== '"') && (arg![arg!.length - 1] !== '"'));
|
||||||
const quote =
|
const quote =
|
||||||
arg === '' ||
|
arg === '' ||
|
||||||
(arg.indexOf(' ') !== -1 ||
|
(arg!.indexOf(' ') !== -1 ||
|
||||||
arg.indexOf('\t') !== -1) &&
|
arg!.indexOf('\t') !== -1) &&
|
||||||
((arg.length > 1) &&
|
((arg!.length > 1) &&
|
||||||
(hasLopsidedEnclosingQuote || hasNoEnclosingQuotes));
|
(hasLopsidedEnclosingQuote || hasNoEnclosingQuotes));
|
||||||
if (quote) {
|
if (quote) {
|
||||||
result += '"';
|
result += '"';
|
||||||
}
|
}
|
||||||
let bsCount = 0;
|
let bsCount = 0;
|
||||||
for (let i = 0; i < arg.length; i++) {
|
for (let i = 0; i < arg!.length; i++) {
|
||||||
const p = arg[i];
|
const p = arg![i];
|
||||||
if (p === '\\') {
|
if (p === '\\') {
|
||||||
bsCount++;
|
bsCount++;
|
||||||
} else if (p === '"') {
|
} else if (p === '"') {
|
||||||
|
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
/**
|
/**
|
||||||
* Copyright (c) 2012-2015, Christopher Jeffrey, Peter Sunde (MIT License)
|
* Copyright (c) 2012-2015, Christopher Jeffrey, Peter Sunde (MIT License)
|
||||||
* Copyright (c) 2016, Daniel Imms (MIT License).
|
* Copyright (c) 2016, Daniel Imms (MIT License).
|
||||||
@@ -135,7 +136,8 @@ export class WindowsTerminal extends Terminal {
|
|||||||
* openpty
|
* openpty
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public static open(options?: IPtyOpenOptions): void {
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
public static open(_options?: IPtyOpenOptions): void {
|
||||||
throw new Error('open() not supported on windows, use Fork() instead.');
|
throw new Error('open() not supported on windows, use Fork() instead.');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -176,6 +178,8 @@ export class WindowsTerminal extends Terminal {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @ts-expect-error - This is a private method that is not part of the public API.
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
private _deferNoArgs<A>(deferredFn: () => void): void {
|
private _deferNoArgs<A>(deferredFn: () => void): void {
|
||||||
// If the terminal is ready, execute.
|
// If the terminal is ready, execute.
|
||||||
if (this._isReady) {
|
if (this._isReady) {
|
||||||
|
@@ -1,2 +1,2 @@
|
|||||||
import { NCoreInitShell } from "./base";
|
import { NCoreInitShell } from './base';
|
||||||
NCoreInitShell();
|
NCoreInitShell();
|
Reference in New Issue
Block a user