Skip to content

Commit bea9f69

Browse files
committed
Set cwd to the root workspace for supporting checkpatch config file
1 parent 7d76af0 commit bea9f69

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/checkpatchProvider.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ export default class CheckpatchProvider implements vscode.CodeActionProvider {
6868
// testing given configuration:
6969
var re = /total: \d* errors, \d* warnings,( \d* checks,)? \d* lines checked/g;
7070
let args = this.linterConfig.args.slice();
71-
args.push('--no-tree - ');
72-
let childProcess = cp.spawnSync(this.linterConfig.path, args, { shell: true, input: ' ' });
71+
let cwd = vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders[0].name : undefined;
72+
args.push('--no-tree - ');
73+
let childProcess = cp.spawnSync(this.linterConfig.path, args, {shell: true, input: ' ', cwd: cwd });
7374
if (childProcess.pid && re.test(childProcess.stdout.toString())) {
7475
// all good
7576
} else {
@@ -135,10 +136,11 @@ export default class CheckpatchProvider implements vscode.CodeActionProvider {
135136

136137
let log = '';
137138
let args = this.linterConfig.args.slice();
139+
let cwd = vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders[0].name : undefined;
138140
args.push('--show-types -f');
139141
args.push(textDocument.fileName.replace(/\\/g, '/'));
140142

141-
let childProcess = cp.spawn(this.linterConfig.path, args, { shell: true });
143+
let childProcess = cp.spawn(this.linterConfig.path, args, { shell: true, cwd: cwd });
142144
if (childProcess.pid) {
143145
// clean old diagostics. Prevents files with only one warning from being updated
144146
this.diagnosticCollection.delete(textDocument.uri);

0 commit comments

Comments
 (0)