this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix error handling

+20 -3
+6 -2
source/is-terminal-running.js
··· 10 10 try { 11 11 await execute('pgrep', ['-x', 'Terminal']); 12 12 return true; 13 - } catch { 14 - return false; 13 + } catch (error) { 14 + // Error code 1: 'No processes were matched.' 15 + // See `man grep` 16 + if (error.code === 1) return false; 17 + 18 + throw error; 15 19 } 16 20 }
+14 -1
test/is-terminal-running.js
··· 25 25 it('returns false when Terminal is not running', async () => { 26 26 childProcess.execFile.mock.mockImplementation( 27 27 (_command, _args, callback) => { 28 - callback(new Error('no process found')); 28 + const error = new Error('no process found'); 29 + error.code = 1; 30 + callback(error); 29 31 }, 30 32 ); 31 33 32 34 assert.equal(await isTerminalRunning(), false); 35 + 36 + it('rethrows unexpected pgrep failures', async () => { 37 + const error = new Error('spawn pgrep ENOENT'); 38 + error.code = 'ENOENT'; 39 + childProcess.execFile.mock.mockImplementation( 40 + (_command, _args, callback) => { 41 + callback(error); 42 + }, 43 + ); 44 + 45 + await assert.rejects(isTerminalRunning(), error); 33 46 }); 34 47 35 48 it('calls pgrep with correct arguments', async () => {