import util from 'node:util';
import {exec as _exec} from 'child_process';

export const exec = util.promisify(_exec);

export function toKebabCase(anyCaseName: string) {
  const spacesRemoved = anyCaseName.replace(/\s/g, '-');
  const lettersOnly = spacesRemoved.replace(/[^a-zA-Z\-]/g, '');
  const lowerCased = lettersOnly.toLowerCase();
  return lowerCased;
}

export function toCamelCase(kebabCaseName: string) {
  const words = kebabCaseName.split('-');
  for (let i = 1; i < words.length; ++i) {
    words[i] = words[i][0].toUpperCase() + words[i].slice(1);
  }
  return words.join('');
}

export default {
  comment: 'This is only exported beacuse otherwise node does not recognize this file as a module'
};
