Skip to content

Commit f559951

Browse files
committed
use code as node runtime on Linux/Mac
By setting the ELECTRON_RUN_AS_NODE environment variable, we can use `code` as a node runtime and execute shell.ts directly. However, this only works on non-Windows platforms because `code` has the GUI app flag set on Windows that makes stdin unusable. So, we will have to continue to use the nexe version on Windows until we can figure out a workaround. Removing 2 out of 3 native binaries significantly reduces the download size.
1 parent bfe8525 commit f559951

File tree

5 files changed

+7
-10
lines changed

5 files changed

+7
-10
lines changed

.gitattributes

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
native/linux/helper filter=lfs diff=lfs merge=lfs -text
2-
native/darwin/helper filter=lfs diff=lfs merge=lfs -text
31
native/win32/helper.exe filter=lfs diff=lfs merge=lfs -text
42

53
* text eol=lf

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
55

66
## Unreleased
77
### Changed
8+
- `ev3devBrowser` debugger type no longer uses native executable.
89
- SSH shell no longer uses native executable on Linux and Mac.
910
### Fixed
1011
- Fix debugger hanging when ev3dev Device Browser view is collapsed

native/darwin/helper

Lines changed: 0 additions & 3 deletions
This file was deleted.

native/linux/helper

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/extension.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ let config: WorkspaceConfig;
2424
let output: vscode.OutputChannel;
2525
let resourceDir: string;
2626
let helperExePath: string;
27+
let shellPath: string;
2728
let ev3devBrowserProvider: Ev3devBrowserProvider;
2829

2930
// this method is called when your extension is activated
@@ -36,6 +37,7 @@ export function activate(context: vscode.ExtensionContext): void {
3637
if (process.platform === 'win32') {
3738
helperExePath += '.exe';
3839
}
40+
shellPath = context.asAbsolutePath(path.join('out', 'native-helper', 'shell.js'));
3941

4042
ev3devBrowserProvider = new Ev3devBrowserProvider();
4143
context.subscriptions.push(
@@ -493,9 +495,11 @@ class DeviceTreeItem extends vscode.TreeItem {
493495
}
494496

495497
public openSshTerminal(): void {
498+
const isWin32 = os.platform() === 'win32';
499+
const port = this.device.shellPort.toString();
496500
const term = vscode.window.createTerminal(`SSH: ${this.label}`,
497-
helperExePath,
498-
['shell', this.device.shellPort.toString()]);
501+
isWin32 ? helperExePath : '/usr/bin/env',
502+
isWin32 ? ['shell', port] : ['ELECTRON_RUN_AS_NODE=1', process.execPath, shellPath, 'shell', port]);
499503
term.show();
500504
}
501505

0 commit comments

Comments
 (0)