Skip to content

Commit

Permalink
squash!
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaRHristov committed Dec 18, 2023
1 parent 94c7b23 commit ed26328
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 99 deletions.
24 changes: 12 additions & 12 deletions Source/azService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { spawn, ChildProcess, SpawnOptions } from "child_process";
import { ChildProcess, SpawnOptions, spawn } from "child_process";
import { join } from "path";
import * as semver from "semver";

import { exec, realpath, exists, readdir } from "./utils";
import { exec, exists, readdir, realpath } from "./utils";

const isWindows = process.platform === "win32";

Expand Down Expand Up @@ -67,7 +67,7 @@ export class AzService {
private listeners: {
[sequence: number]: (
err: undefined | any,
response: Message<any> | undefined
response: Message<any> | undefined,
) => void;
} = {};
private nextSequenceNumber = 1;
Expand All @@ -81,7 +81,7 @@ export class AzService {

async getCompletions(
query: CompletionQuery,
onCancel: (handle: () => void) => void
onCancel: (handle: () => void) => void,
): Promise<Completion[]> {
try {
return this.send<CompletionQuery, Completion[]>(query, onCancel);
Expand All @@ -97,20 +97,20 @@ export class AzService {

async getHover(
command: Command,
onCancel: (handle: () => void) => void
onCancel: (handle: () => void) => void,
): Promise<HoverText> {
return this.send<HoverQuery, HoverText>(
{
request: "hover",
command,
},
onCancel
onCancel,
);
}

private async send<T, R>(
data: T,
onCancel?: (handle: () => void) => void
onCancel?: (handle: () => void) => void,
): Promise<R> {
const process = await this.getProcess();
return new Promise<R>((resolve, reject) => {
Expand Down Expand Up @@ -161,7 +161,7 @@ export class AzService {
throw "wrongVersion";
}
const pythonLocation = (/^Python location '([^']*)'/m.exec(
stdout
stdout,
) || [])[1];
const processOptions = await this.getSpawnProcessOptions();
return this.spawn(pythonLocation, processOptions);
Expand All @@ -180,7 +180,7 @@ export class AzService {
if (binPath.startsWith(cellarBasePath)) {
const installPath = binPath.substr(
0,
binPath.indexOf("/", cellarBasePath.length)
binPath.indexOf("/", cellarBasePath.length),
);
const libPath = `${installPath}/libexec/lib`;
const entries = await readdir(libPath);
Expand All @@ -202,10 +202,10 @@ export class AzService {
const process = spawn(
join(
__dirname,
`../../service/az-service${isWindows ? ".bat" : ""}`
`../../service/az-service${isWindows ? ".bat" : ""}`,
),
[pythonLocation],
processOptions
processOptions,
);
process.stdout.setEncoding("utf8");
process.stdout.on("data", (data) => {
Expand Down Expand Up @@ -237,7 +237,7 @@ export class AzService {
delete this.listeners[sequence];
listener(
`Python process terminated with exit code ${code}, signal ${signal}.`,
undefined
undefined,
);
}
});
Expand Down
Loading

0 comments on commit ed26328

Please sign in to comment.