INNER CODE UNIT · TypeScript
toValidAppName
hypermodeinc/modus · cli/src/commands/new/index.ts:386
function toValidAppName(input: string): string {
// Remove any characters that aren't alphanumeric, spaces, or a few other valid characters.
// Replace spaces with hyphens.
return input
.trim() // Remove leading/trailing spaces
.toLowerCase() // Convert to lowercase for consistency
.replace(/[^a-z0-9\s-]/g, "") // Remove invalid characters
.replace(/\s+/g, "-") // Replace spaces (or multiple spaces) with a single hyphen
.replace(/-+/g, "-") // Replace multiple consecutive hyphens with a single hyphen
.replace(/^-|-$/g, ""); // Remove leading or trailing hyphens
}
async function isGitInPath() {
try {
await exec("git --version");
return true;
} catch {
return false;