All files / utils generate-files.config.ts

100% Statements 7/7
50% Branches 1/2
100% Functions 3/3
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25          4x 4x 4x   4x   4x   4x     4x                
/**
 * Creates generate files configuration object.
 * @param name library name
 * @param prefix library name prefix that should be removed from names
 */
export const generateFilesConfig = (name: string, prefix: string) => {
  const kebabCaseName = name.replace(prefix, '');
  const pascalCaseName = kebabCaseName
    .split('-')
    .map(item => `${item[0].toUpperCase()}${item.slice(1)}`)
    .join('');
  const camelCaseName = kebabCaseName
    .split('-')
    .map((item, index) => (index === 0 ? item : `${item[0].toUpperCase()}${item.slice(1)}`))
    .join('');
 
  return {
    tmpl: '',
    name,
    kebabCaseName,
    pascalCaseName,
    camelCaseName,
  };
};