Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const clientOptions: LanguageClientOptions = {
documentSelector: [
{ scheme: 'file', language: 'papyrus' },
{ scheme: 'file', language: 'papyrus-project' },
],
synchronize: {
fileEvents: this._fsWatcher,
configurationSection: 'papyrus',
},
};
// In order to find the new process id, we need to exclude any current running instances of the language server.
let existingProcessIds: number[];
if (process.platform === 'win32' && process.env['PAPYRUS_EXTENSION_DEBUG']) {
const processes = await psList();
existingProcessIds = processes.filter((p) => p.name.startsWith('DarkId.Papyrus.Host')).map((p) => p.pid);
}
// Create the language client and start the client.
this._client = new LanguageClient('papyrus', 'Papyrus Language Service', this._serverOptions, clientOptions);
this._client.trace = Trace.Verbose;
this._clientDisposable = this._client.start();
await this._client.onReady();
if (!this._clientDisposable) {
return;
}
if (process.platform === 'win32' && process.env['PAPYRUS_EXTENSION_DEBUG']) {
let existingProcessIds: number[];
if (process.platform === 'win32' && process.env['PAPYRUS_EXTENSION_DEBUG']) {
const processes = await psList();
existingProcessIds = processes.filter((p) => p.name === 'DarkId.Papyrus.Host.exe').map((p) => p.pid);
}
// Create the language client and start the client.
this._client = new LanguageClient('papyrus', 'Papyrus Language Service', this._serverOptions, clientOptions);
this._client.trace = Trace.Verbose;
this._client.start();
await this._client.onReady();
if (process.platform === 'win32' && process.env['PAPYRUS_EXTENSION_DEBUG']) {
const processes = await psList();
const serverProcessId = processes.find(
(p) => p.name === 'DarkId.Papyrus.Host.exe' && existingProcessIds.indexOf(p.pid) === -1
)!.pid;
if (serverProcessId) {
exec(`vsjitdebugger.exe -p ${serverProcessId}`);
}
}
}
export async function findProcess(arg: ChildProcess | number) {
const pid = typeof arg === 'number' ? arg : arg.pid
const runningProcesses = await psList()
return runningProcesses.find(runningProcess => pid === runningProcess.pid)
}
return new Promise(resolve => {
psList()
.then(list => {
if (
findLodash(list, { name: 'Android File Transfer' }) &&
findLodash(list, { name: 'Android File Transfer Agent' })
) {
return resolve(true);
}
return resolve(false);
})
.catch(e => {
log.error(e, 'isGoogleAndroidFileTransferActive');
});
}).catch(e => {
log.error(e, 'isGoogleAndroidFileTransferActive -> Promise');
public async getprocesses(): Promise {
const processes = await psList();
const res = processes.find(proc => proc.name === this.pname);
if (res) {
return res.pid;
} else {
return -1;
}
}
}
export function isSteamRunning(searchTarget = 'steam') {
return Rx.Observable.fromPromise(psList())
.map(data => _.some(data, x => _.includes(x.name.toLowerCase(), searchTarget)));
}
export async function getGameIsRunning(game: PapyrusGame) {
const processList = await procList();
return processList.some((p) => p.name.toLowerCase() === getExecutableNameForGame(game).toLowerCase());
}