Skip to content

Commit

Permalink
Add option to run yb under WSL
Browse files Browse the repository at this point in the history
Fixes #1 [ch1741]
  • Loading branch information
zombiezen committed Jul 31, 2020
1 parent 68c7b5c commit 87f213b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

[Unreleased]: https://github.com/yourbase/yourbase-vscode/compare/v0.2.2...HEAD

### Added

- Added option to run `yb` under WSL ([#1][])

[#1]: https://github.com/yourbase/yourbase-vscode/issues/1

### Fixed

- Update elliptic to address [CVE-2020-13822][].
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
"default": false,
"description": "Run builds on the YourBase service. Must log in using `yb login` first.",
"scope": "resource"
},
"yourbase.useWSL": {
"type": "boolean",
"default": false,
"description": "Use WSL to start a build. Only used on Windows.",
"scope": "machine"
}
}
},
Expand Down
18 changes: 17 additions & 1 deletion src/ybTaskProvider.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as fs from 'fs';
import * as path from 'path';
import * as process from 'process';
import * as vscode from 'vscode';
import * as yaml from 'yaml';

Expand Down Expand Up @@ -146,10 +147,25 @@ function workspaceUsesRemoteBuilds(folder: vscode.WorkspaceFolder): boolean {
return vscode.workspace.getConfiguration(configSection, folder).get('remoteBuild', false);
}

function useWsl(): boolean {
return process.platform === 'win32' &&
vscode.workspace.getConfiguration(configSection).get('useWSL', false);
}

/** Return the invocation for a task. */
function taskExecution(definition: YbTaskDefinition, remote: boolean): vscode.ProcessExecution {
let process: string;
let args: string[];
if (!useWsl()) {
process = 'yb';
args = [];
} else {
process = 'wsl';
args = ['yb'];
}
const subcmd = remote ? 'remotebuild' : 'build';
return new vscode.ProcessExecution('yb', [subcmd, '--', definition.target]);
args.push(subcmd, '--', definition.target);
return new vscode.ProcessExecution(process, args);
}

/** YAML definition of a build target. */
Expand Down

0 comments on commit 87f213b

Please sign in to comment.