Skip to content

Commit 969fc5c

Browse files
committed
detect windowsOS - if win32 use npx.cm otherwise use npx for xslt-js task
1 parent b18b158 commit 969fc5c

File tree

3 files changed

+6
-1
lines changed

3 files changed

+6
-1
lines changed

src/documentChangeHandler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export interface TagRenameEdit {
1313
export class DocumentChangeHandler {
1414
public static lastActiveXMLEditor: vscode.TextEditor|null = null;
1515
public static lastXMLDocumentGlobalData: GlobalInstructionData[] = [];
16+
public static isWindowsOS: boolean | undefined;
1617

1718
private onDidChangeRegistration: vscode.Disposable | null = null;
1819
private xmlDocumentRegistered = false;

src/extension.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { DCPSymbolProvider } from './dcpSymbolProvider';
2525
import { XsltTokenDiagnostics } from './xsltTokenDiagnostics';
2626
import { window } from 'vscode';
2727
import { XSLTHoverProvider } from './xsltHoverProvider';
28+
import * as os from 'os';
2829

2930

3031

@@ -43,6 +44,7 @@ const legend = (function () {
4344
})();
4445

4546
export function activate(context: vscode.ExtensionContext) {
47+
DocumentChangeHandler.isWindowsOS = os.platform() === 'win32';
4648
const xsltDiagnosticsCollection = vscode.languages.createDiagnosticCollection('xslt');
4749
const xsltSymbolProvider = new XsltSymbolProvider(XSLTConfiguration.configuration, xsltDiagnosticsCollection);
4850

src/saxonJsTaskProvider.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as vscode from 'vscode';
88
import * as path from 'path';
99
import * as fs from 'fs';
1010
import { SaxonTaskProvider } from './saxonTaskProvider';
11+
import { DocumentChangeHandler } from './documentChangeHandler';
1112

1213
function exists(file: string): Promise<boolean> {
1314
return new Promise<boolean>((resolve, _reject) => {
@@ -139,6 +140,7 @@ export class SaxonJsTaskProvider implements vscode.TaskProvider {
139140
this.templateTaskFound = true;
140141
}
141142

143+
let npxCommand = DocumentChangeHandler.isWindowsOS? 'npx.cmd' : 'npx';
142144
let commandLineArgs: string[] = ['xslt3'];
143145

144146
let xsltParameters: XSLTParameter[] = xsltTask.parameters? xsltTask.parameters: [];
@@ -184,7 +186,7 @@ export class SaxonJsTaskProvider implements vscode.TaskProvider {
184186
// this is overriden if problemMatcher is set in the tasks.json file
185187
let problemMatcher = "$saxon-xslt-js";
186188

187-
const processExecution = new vscode.ProcessExecution('npx', commandLineArgs.concat(xsltParametersCommand));
189+
const processExecution = new vscode.ProcessExecution(npxCommand, commandLineArgs.concat(xsltParametersCommand));
188190
let newTask = new vscode.Task(xsltTask, xsltTask.label, source, processExecution, problemMatcher);
189191

190192
//let newTask = new vscode.Task(xsltTask, xsltTask.label, source, new vscode.ShellExecution(commandline), problemMatcher);

0 commit comments

Comments
 (0)