Skip to content

Commit

Permalink
Update install check to use fs.existsSync
Browse files Browse the repository at this point in the history
The install check was using command-exists to check if an absolute
path was present--which does not seem to work on Windows. Instead,
just check if the file exists at all.

Fixes #14
Fixes #9

Signed-off-by: Torin Sandall <[email protected]>
  • Loading branch information
tsandall committed Mar 8, 2019
1 parent a3210ec commit 75b920b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/opa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as vscode from 'vscode';

import { promptForInstall } from './install-opa';
import { getImports, getPackage } from './util';
import { existsSync } from 'fs';

var regoVarPattern = new RegExp('^[a-zA-Z_][a-zA-Z0-9_]*$');

Expand Down Expand Up @@ -60,7 +61,7 @@ export function run(path: string, args: string[], stdin: string, cb: (error: str
export function runWithStatus(path: string, args: string[], stdin: string, cb: (code: number, stderr: string, stdout: string) => void) {
const opaPath = vscode.workspace.getConfiguration('opa').get<string>('path');
const existsOnPath = commandExistsSync(path);
const existsInUserSettings = opaPath !== null && commandExistsSync(opaPath);
const existsInUserSettings = opaPath !== undefined && opaPath !== null && existsSync(opaPath);

if (!(existsOnPath || existsInUserSettings)) {
promptForInstall();
Expand Down

0 comments on commit 75b920b

Please sign in to comment.