Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for WSL in vscode #17

Merged
merged 4 commits into from
May 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ function run(cmd, args, options, done) {
if (executed) return;
executed = true;

if (stderr) {
// Bogus screen size is a WSL-specific vscode error:
// https://github.com/microsoft/vscode/issues/98590
if (stderr && !stderr.includes('screen size is bogus')) {
return done(new Error(stderr));
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pidtree",
"version": "0.5.0",
"version": "0.5.1",
"description": "Cross platform children list of a PID",
"license": "MIT",
"homepage": "http://github.com/simonepri/pidtree#readme",
Expand Down
60 changes: 60 additions & 0 deletions test/ps.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,63 @@ test('should parse ps output on *nix', async t => {
mockery.deregisterMock('child_process');
mockery.deregisterMock('os');
});

test('should throw if stderr contains an error', async t => {
const stdout =
'PPID PID\n' +
' 1 430\n' +
' 430 432\n' +
' 1 727\n' +
' 1 7166\n';

mockery.registerMock('child_process', {
spawn: () => mocks.spawn(stdout, 'Some error', null, 0, null),
});
mockery.registerMock('os', {
EOL: '\n',
platform: () => 'linux',
type: () => 'type',
release: () => 'release',
});

const ps = require('../lib/ps');

await t.throws(pify(ps)());

mockery.deregisterMock('child_process');
mockery.deregisterMock('os');
});

test('should not throw if stderr contains the "bogus" error message from vscode', async t => {
const stdout =
'PPID PID\n' +
' 1 430\n' +
' 430 432\n' +
' 1 727\n' +
' 1 7166\n';

mockery.registerMock('child_process', {
spawn: () =>
mocks.spawn(
stdout,
'Error: your 131072x1 screen size is bogus. expect trouble',
null,
0,
null
),
});
mockery.registerMock('os', {
EOL: '\n',
platform: () => 'linux',
type: () => 'type',
release: () => 'release',
});

const ps = require('../lib/ps');

const result = await pify(ps)();
t.deepEqual(result, [[1, 430], [430, 432], [1, 727], [1, 7166]]);

mockery.deregisterMock('child_process');
mockery.deregisterMock('os');
});