Skip to content

Commit

Permalink
Parse plugin-name from .pnpm/.pnpm-store
Browse files Browse the repository at this point in the history
  • Loading branch information
da-levkovets committed Nov 20, 2023
1 parent 70fb975 commit c6aeec6
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
30 changes: 30 additions & 0 deletions src/parse-plugin-name.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,34 @@ describe('parsePluginName', () => {
'@some-org/some-plugin-name'
);
});

test('should return a plugin name from a stack if it is in .pnpm', () => {
const stack = `
at Hermione.herm.<computed> (/Users/da-levkovets/arcadia/search-interfaces/oceania/projects/web4/node_modules/.pnpm/[email protected]/node_modules/hermione-plugins-profiler/build/wrap-hermione-handler.js:13:19)
at module.exports (/Users/da-levkovets/arcadia/search-interfaces/oceania/projects/web4/node_modules/.pnpm/[email protected]/node_modules/hermione-passive-browsers/lib/index.js:54:14)
at /Users/da-levkovets/arcadia/search-interfaces/oceania/projects/web4/node_modules/.pnpm/[email protected]/node_modules/plugins-loader/lib/loader.js:19:80
at Module.load (node:internal/modules/cjs/loader:1037:32)
`;

const err = new Error();

err.stack = stack;

expect(parsePluginName(err)).toEqual('hermione-passive-browsers');
});

test('should return a plugin name from a stack if it is in .pnpm-store', () => {
const stack = `
at Hermione.herm.<computed> [as on] (/Users/da-levkovets/.pnpm-store/oceania-virtual-store/[email protected]/node_modules/hermione-plugins-profiler/build/wrap-hermione-handler.js:14:29)
at module.exports (/Users/da-levkovets/.pnpm-store/oceania-virtual-store/@[email protected]_56d91d656e193c0ca144cec591e28121/node_modules/@yandex-int/html-reporter-dumps-plugin/src/hermione/index.ts:22:14)
at /Users/da-levkovets/.pnpm-store/oceania-virtual-store/[email protected]/node_modules/plugins-loader/lib/loader.js:19:80
at /Users/da-levkovets/.pnpm-store/oceania-virtual-store/[email protected]/node_modules/plugins-loader/lib/index.js:9:26
`;

const err = new Error();

err.stack = stack;

expect(parsePluginName(err)).toEqual('@yandex-int/html-reporter-dumps-plugin');
});
});
3 changes: 2 additions & 1 deletion src/parse-plugin-name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ export function parsePluginName(error: Error): string {
return UNKNOWN_PLUGIN_NAME;
}

const [, pluginRootPath] = pluginIndexPath.split('node_modules');
const pluginRootPaths = pluginIndexPath.split('node_modules');
const pluginRootPath = pluginRootPaths[pluginRootPaths.length - 1];

if (!pluginRootPath) {
logWarn();
Expand Down

0 comments on commit c6aeec6

Please sign in to comment.