forked from sombochea/verdaccio-ui
fix: when scope is provided use proper separator (#457)
This commit is contained in:
parent
b59840d352
commit
7e56c8e7e2
@ -1,6 +1,6 @@
|
||||
import { SyntheticEvent } from 'react';
|
||||
|
||||
import { copyToClipBoardUtility } from './cli-utils';
|
||||
import { copyToClipBoardUtility, getCLISetConfigRegistry } from './cli-utils';
|
||||
|
||||
describe('copyToClipBoardUtility', () => {
|
||||
let originalGetSelection;
|
||||
@ -47,3 +47,18 @@ describe('copyToClipBoardUtility', () => {
|
||||
expect(spys.removeChild).toHaveBeenCalledWith(expectedDiv);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getCLISetRegistry', () => {
|
||||
const command = 'npm set';
|
||||
const scope = '@testscope';
|
||||
const blankScope = '';
|
||||
const url = 'https://test.local';
|
||||
|
||||
test('should return ":" separated string when scope is set', () => {
|
||||
expect(getCLISetConfigRegistry(command, scope, url)).toEqual(`${command} ${scope}:registry ${url}`);
|
||||
});
|
||||
|
||||
test('should not output scope when scope is not set', () => {
|
||||
expect(getCLISetConfigRegistry(command, blankScope, url)).toEqual(`${command} registry ${url}`);
|
||||
});
|
||||
});
|
||||
|
@ -21,7 +21,8 @@ export const copyToClipBoardUtility = (str: string): ((e: SyntheticEvent<HTMLEle
|
||||
};
|
||||
|
||||
export function getCLISetConfigRegistry(command: string, scope: string, registryUrl: string): string {
|
||||
return `${command} ${scope}registry ${registryUrl}`;
|
||||
// if there is a scope defined there needs to be a ":" separator between the scope and the registry
|
||||
return `${command} ${scope}${scope !== '' ? ':' : ''}registry ${registryUrl}`;
|
||||
}
|
||||
|
||||
export function getCLISetRegistry(command: string, registryUrl: string): string {
|
||||
|
Loading…
Reference in New Issue
Block a user