Skip to content
This repository has been archived by the owner on Oct 9, 2024. It is now read-only.

Commit

Permalink
Fix stdio incompatibility with some third-party clients (#604)
Browse files Browse the repository at this point in the history
* Stdio patch
Do not log validation status on stdout, use connection logs instead.
See #540, #541

* Fix: use optional chaining for connection as it may not exist for purposes of testing.

---------

Co-authored-by: Priyam Sahoo <[email protected]>
  • Loading branch information
JosBritton and priyamsahoo authored Oct 23, 2023
1 parent 00fcca6 commit fad31c1
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/providers/validationProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export async function doValidate(

const settings = await context.documentSettings.get(textDocument.uri);
if (!settings.validation.enabled) {
console.log("Validation disabled");
connection?.console.log("Validation disabled");

// this is done to remove the cache as well
const blankDiagnostics = new Map<string, Diagnostic[]>();
Expand All @@ -54,10 +54,10 @@ export async function doValidate(
: settings.validation.lint.path;
const lintAvailability =
await commandRunner.getExecutablePath(lintExecutable);
console.debug("Path for lint: ", lintAvailability);
connection?.console.log(`Path for lint: ${lintAvailability}`);

if (lintAvailability) {
console.debug("Validating using ansible-lint");
connection?.console.log("Validating using ansible-lint");
diagnosticsByFile = await context.ansibleLint.doValidate(textDocument);
} else {
connection?.window.showErrorMessage(
Expand All @@ -68,14 +68,14 @@ export async function doValidate(

// validate using ansible-playbook --syntax-check
else {
console.debug("Validating using ansible syntax-check");
connection?.console.log("Validating using ansible syntax-check");

if (isPlaybook(textDocument)) {
console.debug("playbook file");
connection?.console.log("playbook file");
diagnosticsByFile =
await context.ansiblePlaybook.doValidate(textDocument);
} else {
console.debug("non-playbook file");
connection?.console.log("non-playbook file");
diagnosticsByFile = new Map<string, Diagnostic[]>();
}
}
Expand Down

0 comments on commit fad31c1

Please sign in to comment.