Skip to content

Commit

Permalink
Set cwd to the root workspace for supporting checkpatch config file
Browse files Browse the repository at this point in the history
  • Loading branch information
idanpa committed May 1, 2020
1 parent 7d76af0 commit bea9f69
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/checkpatchProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ export default class CheckpatchProvider implements vscode.CodeActionProvider {
// testing given configuration:
var re = /total: \d* errors, \d* warnings,( \d* checks,)? \d* lines checked/g;
let args = this.linterConfig.args.slice();
args.push('--no-tree - ');
let childProcess = cp.spawnSync(this.linterConfig.path, args, { shell: true, input: ' ' });
let cwd = vscode.workspace.workspaceFolders ? vscode.workspace.workspaceFolders[0].name : undefined;
args.push('--no-tree - ');
let childProcess = cp.spawnSync(this.linterConfig.path, args, {shell: true, input: ' ', cwd: cwd });
if (childProcess.pid && re.test(childProcess.stdout.toString())) {
// all good
} else {
Expand Down Expand Up @@ -135,10 +136,11 @@ export default class CheckpatchProvider implements vscode.CodeActionProvider {

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

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

0 comments on commit bea9f69

Please sign in to comment.