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..68bdc382e 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 pnpm 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]); - 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();