Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Commit

Permalink
Respect ruby.pathToBundler for RuboCop executable
Browse files Browse the repository at this point in the history
  • Loading branch information
Ted committed Dec 3, 2018
1 parent 6799da0 commit 45de587
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/format/RuboCop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@ export class AutoCorrect {

// What's the exe name for rubocop?
get exe(): string[] {
const opts:any = this.opts;
const opts: any = this.opts;
if (opts.exe) {
return [opts.exe];
}

const ext: string = process.platform === 'win32' ? '.bat' : '';
if (vscode.workspace.getConfiguration('ruby').useBundler) {
return [`bundle${ext}`, 'exec', 'rubocop'];
let pathToBundler = vscode.workspace.getConfiguration('ruby').pathToBundler || 'bundle';
return [`${pathToBundler}${ext}`, 'exec', 'rubocop'];
}

return [`rubocop${ext}`];
Expand Down Expand Up @@ -88,16 +89,17 @@ export class AutoCorrect {

private spawn = (args: string[], options?: cp.SpawnOptions): cp.ChildProcess => {
const exe: string[] = this.exe;
const spawnOpt: cp.SpawnOptions = options ? options : {}
const spawnOpt: cp.SpawnOptions = options ? options : {};

if (!spawnOpt.cwd) { spawnOpt.cwd = vscode.workspace.rootPath }
if (!spawnOpt.cwd) {
spawnOpt.cwd = vscode.workspace.rootPath;
}

return cp.spawn(exe.shift(), exe.concat(args), spawnOpt);
};

public test(): Promise<any> {
return new Promise((resolve, reject) => {

const rubo = this.spawn(['-v']);

rubo.on('error', err => {
Expand Down

0 comments on commit 45de587

Please sign in to comment.