Skip to content

Commit 87f213b

Browse files
committed
Add option to run yb under WSL
Fixes #1 [ch1741]
1 parent 68c7b5c commit 87f213b

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

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

10+
### Added
11+
12+
- Added option to run `yb` under WSL ([#1][])
13+
14+
[#1]: https://github.com/yourbase/yourbase-vscode/issues/1
15+
1016
### Fixed
1117

1218
- Update elliptic to address [CVE-2020-13822][].

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@
3838
"default": false,
3939
"description": "Run builds on the YourBase service. Must log in using `yb login` first.",
4040
"scope": "resource"
41+
},
42+
"yourbase.useWSL": {
43+
"type": "boolean",
44+
"default": false,
45+
"description": "Use WSL to start a build. Only used on Windows.",
46+
"scope": "machine"
4147
}
4248
}
4349
},

src/ybTaskProvider.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as fs from 'fs';
22
import * as path from 'path';
3+
import * as process from 'process';
34
import * as vscode from 'vscode';
45
import * as yaml from 'yaml';
56

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

150+
function useWsl(): boolean {
151+
return process.platform === 'win32' &&
152+
vscode.workspace.getConfiguration(configSection).get('useWSL', false);
153+
}
154+
149155
/** Return the invocation for a task. */
150156
function taskExecution(definition: YbTaskDefinition, remote: boolean): vscode.ProcessExecution {
157+
let process: string;
158+
let args: string[];
159+
if (!useWsl()) {
160+
process = 'yb';
161+
args = [];
162+
} else {
163+
process = 'wsl';
164+
args = ['yb'];
165+
}
151166
const subcmd = remote ? 'remotebuild' : 'build';
152-
return new vscode.ProcessExecution('yb', [subcmd, '--', definition.target]);
167+
args.push(subcmd, '--', definition.target);
168+
return new vscode.ProcessExecution(process, args);
153169
}
154170

155171
/** YAML definition of a build target. */

0 commit comments

Comments
 (0)