Simplify resolvePackageName

Signed-off-by: Min Kim <minkimcello@gmail.com>
This commit is contained in:
Min Kim
2025-01-07 16:00:06 -05:00
parent c2b688b168
commit 540995076a
+6 -10
View File
@@ -31,20 +31,16 @@ export const resolvePackageName = (options: {
scope?: string;
plugin: boolean;
}) => {
const { baseName, scope: _scope, plugin } = options;
if (_scope) {
const scope = _scope.replace(/@/g, '');
const { baseName, scope, plugin } = options;
if (scope) {
const scopeSanitized = scope.replace(/[@/]/g, '');
if (plugin) {
const pluginName = scope.startsWith('backstage')
const pluginPrefix = scopeSanitized.startsWith('backstage')
? 'plugin'
: 'backstage-plugin';
return scope.includes('/')
? `@${scope}${pluginName}-${baseName}`
: `@${scope}/${pluginName}-${baseName}`;
return `@${scopeSanitized}/${pluginPrefix}-${baseName}`;
}
return scope.includes('/')
? `@${scope}${baseName}`
: `@${scope}/${baseName}`;
return `@${scopeSanitized}/${baseName}`;
}
return plugin ? `backstage-plugin-${baseName}` : baseName;