From f867798c54d4f5f8b6e2fbff17089083d7cd326b Mon Sep 17 00:00:00 2001 From: ConnectDotz Date: Sat, 13 Jan 2024 17:57:26 -0500 Subject: [PATCH] more fault tolerant for shell setting (#1100) * more fault tolerant for shell setting * fix ci check --- src/JestExt/run-shell.ts | 2 +- tests/JestExt/run-shell.test.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/JestExt/run-shell.ts b/src/JestExt/run-shell.ts index 90fb2325f..f0c1de37e 100644 --- a/src/JestExt/run-shell.ts +++ b/src/JestExt/run-shell.ts @@ -41,7 +41,7 @@ export class RunShell { this.nonLoginShell = setting; this.loginShell = this.getLoginShell(setting); } else { - if (setting.args.length > 0) { + if (setting.args?.length > 0) { this._useLoginShell = true; this.nonLoginShell = undefined; this.loginShell = setting; diff --git a/tests/JestExt/run-shell.test.ts b/tests/JestExt/run-shell.test.ts index a452ba8d6..d5a95c410 100644 --- a/tests/JestExt/run-shell.test.ts +++ b/tests/JestExt/run-shell.test.ts @@ -30,6 +30,7 @@ describe('RunnerShell', () => { ${6} | ${'darwin'} | ${{ path: 'bash', args: ['--login'] }} | ${{ path: 'bash', args: ['--login'] }} | ${true} | ${undefined} ${7} | ${'linux'} | ${undefined} | ${LoginShells.sh} | ${false} | ${undefined} ${8} | ${'linux'} | ${'whatever'} | ${undefined} | ${'never'} | ${undefined} + ${9} | ${'darwin'} | ${{ path: '/bin/zsh' }} | ${LoginShells.zsh} | ${false} | ${'/bin/zsh'} `('case $case', ({ platform, setting, loginShell, settingOverride, useLoginShell }) => { jest.clearAllMocks(); mockPlatform.mockReturnValue(platform);