Skip to content

Commit

Permalink
fix: eslint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jnoortheen committed Aug 2, 2024
1 parent 5fd26eb commit de74fc2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
"publish:ovsx": "yarn run env-cmd --expand-envs ovsx publish *.vsix --pat '$OVS_PAT'",
"publish:vsce": "vsce publish",
"publish": "yarn package && yarn publish:vsce && yarn publish:ovsx",
"lint": "ESLINT_USE_FLAT_CONFIG=false eslint --ext ts src"
"lint": "eslint src"
},
"dependencies": {
"command-exists": "^1.2.9",
Expand Down
15 changes: 9 additions & 6 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,20 @@ import {
ServerOptions,
} from "vscode-languageclient/node";
import { config, UriMessageItem } from "./configuration";

import commandExists = require("command-exists");
import { sync as commandExistsSync } from "command-exists";

let client: LanguageClient;

export async function activate(context: ExtensionContext): Promise<void> {
if (!commandExists.sync(config.serverPath)) {
if (!commandExistsSync(config.serverPath)) {
const selection = await window.showErrorMessage<UriMessageItem>(
`Command ${config.serverPath} not found in $PATH`,
{
title: "Install language server",
uri: Uri.parse(
"https://github.com/nix-community/vscode-nix-ide?tab=readme-ov-file#language-servers"
"https://github.com/nix-community/vscode-nix-ide?tab=readme-ov-file#language-servers",
),
}
},
);
if (selection?.uri !== undefined) {
await env.openExternal(selection?.uri);
Expand Down Expand Up @@ -85,7 +84,11 @@ export async function restart(context: ExtensionContext): Promise<void> {
"$(loading~spin) Restarting Nix language server",
);
try {
client ? await client.restart() : await activate(context);
if (client) {
await client.restart();
} else {
await activate(context);
}
} catch (error) {
client?.error("Failed to restart Nix language server", error, "force");
} finally {
Expand Down
6 changes: 3 additions & 3 deletions src/process-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export interface IProcessResult {
export const runInWorkspace = (
folder: WorkspaceFolder | undefined,
command: ReadonlyArray<string>,
stdin?: string
stdin?: string,
): Promise<IProcessResult> =>
new Promise((resolve, reject) => {
const cwd = folder ? folder.uri.fsPath : process.cwd();
Expand All @@ -82,12 +82,12 @@ export const runInWorkspace = (
// Throw system errors, but do not fail if the command
// fails with a non-zero exit code.
console.error("Command error", command, error);
reject(error);
reject(error); // eslint-disable-line @typescript-eslint/prefer-promise-reject-errors
} else {
const exitCode = error ? error.code : 0;
resolve({ stdout, stderr, exitCode });
}
}
},
);
if (stdin && child.stdin) {
child.stdin.end(stdin);
Expand Down

0 comments on commit de74fc2

Please sign in to comment.