Skip to content

Commit

Permalink
Adds a check for valid path to Au3Check
Browse files Browse the repository at this point in the history
  • Loading branch information
loganch committed Apr 28, 2021
1 parent 0bf3a9a commit f4412d8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/extension.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const vscode = require('vscode');
const path = require('path');
const fs = require('fs');
const { spawn } = require('child_process');
const languageConfiguration = require('./languageConfiguration');
const hoverFeature = require('./ai_hover');
Expand All @@ -16,8 +17,6 @@ const {
updateDiagnostics,
} = require('./checkAutoItCode');

const { checkPath } = vscode.workspace.getConfiguration('autoit');

let diagnosticCollection;

const parseAu3CheckOutput = (document, output) => {
Expand Down Expand Up @@ -49,7 +48,7 @@ const parseAu3CheckOutput = (document, output) => {
};

function checkAutoItCode(document) {
const { enableDiagnostics } = vscode.workspace.getConfiguration('autoit');
const { checkPath, enableDiagnostics } = vscode.workspace.getConfiguration('autoit');

diagnosticCollection.clear();

Expand All @@ -61,6 +60,13 @@ function checkAutoItCode(document) {
return;
}

if (!fs.existsSync(checkPath)) {
vscode.window.showErrorMessage(
'Inavlid Check Path! Please review AutoIt settings (Check Path in UI, autoit.checkPath in JSON)',
);
return;
}

const checkProcess = spawn(checkPath, [document.fileName], {
cwd: path.dirname(document.fileName),
});
Expand Down

0 comments on commit f4412d8

Please sign in to comment.