From 22a14e442824ee40772d8d727936344ddda84a31 Mon Sep 17 00:00:00 2001 From: Robert McGuinness Date: Sat, 8 Jul 2023 20:23:49 -0400 Subject: [PATCH 1/2] feat: add support for pnpm --- src/DebugConfigurationProvider.ts | 4 +- tests/DebugConfigurationProvider.test.ts | 53 +++++++++++++----------- 2 files changed, 31 insertions(+), 26 deletions(-) diff --git a/src/DebugConfigurationProvider.ts b/src/DebugConfigurationProvider.ts index c50ea9b2c..c3c401c23 100755 --- a/src/DebugConfigurationProvider.ts +++ b/src/DebugConfigurationProvider.ts @@ -181,9 +181,9 @@ export class DebugConfigurationProvider implements vscode.DebugConfigurationProv program: undefined, }; - if (cmd === 'npm') { + if (cmd === 'npm' || cmd === 'pnpm') { const extraArgs = args.includes('--') ? [] : ['--']; - return { runtimeExecutable: 'npm', args: extraArgs, ...commonConfig }; + return { runtimeExecutable: cmd, args: extraArgs, ...commonConfig }; } if (cmd === 'yarn') { return { runtimeExecutable: 'yarn', args: [], ...commonConfig }; diff --git a/tests/DebugConfigurationProvider.test.ts b/tests/DebugConfigurationProvider.test.ts index 7984fa18d..d0cb289c5 100755 --- a/tests/DebugConfigurationProvider.test.ts +++ b/tests/DebugConfigurationProvider.test.ts @@ -290,33 +290,38 @@ describe('DebugConfigurationProvider', () => { ${'yarn'} | ${['test', '--config', 'test-jest.json']} | ${false} ${'npm'} | ${['run', 'test']} | ${true} ${'npm'} | ${['test', '--', '--config', 'test-jest.json']} | ${false} - `('can merge yarn or npm command line: $cmd $cArgs', ({ cmd, cArgs, appendExtraArg }) => { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const { args, program, windows, ...restConfig } = config; - const sut = new DebugConfigurationProvider(); - const spy = jest.spyOn(sut, 'provideDebugConfigurations'); - spy.mockImplementation(() => [config]); + ${'pnpm'} | ${['run', 'test']} | ${true} + ${'pnpm'} | ${['test', '--', '--config', 'test-jest.json']} | ${false} + `( + 'can merge yarn or npm or pnpmcommand line: $cmd $cArgs', + ({ cmd, cArgs, appendExtraArg }) => { + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const { args, program, windows, ...restConfig } = config; + const sut = new DebugConfigurationProvider(); + const spy = jest.spyOn(sut, 'provideDebugConfigurations'); + spy.mockImplementation(() => [config]); - const cmdLine = [cmd, ...cArgs].join(' '); - const { - args: newArgs, - program: newProgram, - runtimeExecutable, - ...restNewConfig - } = sut.withCommandLine(workspace, cmdLine); - expect(newArgs).toContain('--runInBand'); - expect(runtimeExecutable).toEqual(cmd); - expect(newProgram).toBeUndefined(); + const cmdLine = [cmd, ...cArgs].join(' '); + const { + args: newArgs, + program: newProgram, + runtimeExecutable, + ...restNewConfig + } = sut.withCommandLine(workspace, cmdLine); + expect(newArgs).toContain('--runInBand'); + expect(runtimeExecutable).toEqual(cmd); + expect(newProgram).toBeUndefined(); - const expectArgs = [...cArgs]; - if (appendExtraArg) { - expectArgs.push('--'); - } - expectArgs.push(...args); + const expectArgs = [...cArgs]; + if (appendExtraArg) { + expectArgs.push('--'); + } + expectArgs.push(...args); - expect(newArgs).toEqual(expectArgs); - expect(restNewConfig).toEqual(restConfig); - }); + expect(newArgs).toEqual(expectArgs); + expect(restNewConfig).toEqual(restConfig); + } + ); it('platform specific sections are removed.', () => { const sut = new DebugConfigurationProvider(); From 713d315ded8bf441d2ece3f4799be9ca83d5440c Mon Sep 17 00:00:00 2001 From: Robert McGuinness Date: Sat, 8 Jul 2023 20:54:38 -0400 Subject: [PATCH 2/2] style: typo --- tests/DebugConfigurationProvider.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/DebugConfigurationProvider.test.ts b/tests/DebugConfigurationProvider.test.ts index d0cb289c5..68bdc382e 100755 --- a/tests/DebugConfigurationProvider.test.ts +++ b/tests/DebugConfigurationProvider.test.ts @@ -293,7 +293,7 @@ describe('DebugConfigurationProvider', () => { ${'pnpm'} | ${['run', 'test']} | ${true} ${'pnpm'} | ${['test', '--', '--config', 'test-jest.json']} | ${false} `( - 'can merge yarn or npm or pnpmcommand line: $cmd $cArgs', + 'can merge yarn or npm or pnpm command line: $cmd $cArgs', ({ cmd, cArgs, appendExtraArg }) => { // eslint-disable-next-line @typescript-eslint/no-unused-vars const { args, program, windows, ...restConfig } = config;