diff --git a/lib/bin.js b/lib/bin.js index 1e917cc..3c97125 100644 --- a/lib/bin.js +++ b/lib/bin.js @@ -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)); } diff --git a/package.json b/package.json index c132e1d..9bcf6c9 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/test/ps.js b/test/ps.js index 6cd06e0..85c1b4f 100644 --- a/test/ps.js +++ b/test/ps.js @@ -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'); +});