Skip to content

Commit 1fc33df

Browse files
committed
set working dir of spawn function
1 parent 4c85449 commit 1fc33df

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

src/features/linter-provider.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import * as path from 'path';
44
import * as cp from 'child_process';
55
import ChildProcess = cp.ChildProcess;
6-
import { getIncludeParams, LANGUAGE_ID } from '../lib/helper';
6+
import { getIncludeParams, LANGUAGE_ID, extract_path } from '../lib/helper';
77

88
import * as vscode from 'vscode';
99

@@ -28,8 +28,9 @@ export default class FortranLintingProvider {
2828
let diagnostics: vscode.Diagnostic[] = [];
2929
let command = this.getGfortranPath();
3030
let argList = this.constructArgumentList(textDocument);
31-
32-
let childProcess = cp.spawn(command, argList);
31+
32+
let filePath = extract_path(textDocument.fileName);
33+
let childProcess = cp.spawn(command, argList, {cwd: filePath});
3334

3435
if (childProcess.pid) {
3536
childProcess.stdout.on('data', (data: Buffer) => {

src/lib/helper.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11

22
import * as fs from 'fs';
33
import * as vscode from 'vscode';
4-
4+
let path = require('path');
5+
const fileSep = path.sep;
56

67
export const LANGUAGE_ID = 'fortran90';
78

@@ -106,4 +107,10 @@ let saveKeywordToJson = (keyword) => {
106107
if (err) throw err;
107108
console.log('Saved!');
108109
});
109-
};
110+
};
111+
112+
export const extract_path = (file: string) => {
113+
114+
let pos = file.lastIndexOf(fileSep);
115+
return file.substring(0, pos);
116+
};

src/lib/linter.ts

Whitespace-only changes.

0 commit comments

Comments
 (0)