MCPcopy Create free account
hub / github.com/TanStack/cli / sanitizePackageName

Function sanitizePackageName

packages/cli/src/utils.ts:6–15  ·  view source on GitHub ↗
(name: string)

Source from the content-addressed store, hash-verified

4const FALLBACK_PACKAGE_NAME = 'tanstack-app'
5
6export function sanitizePackageName(name: string): string {
7 return name
8 .toLowerCase()
9 .replace(/\s+/g, '-') // Replace spaces with hyphens
10 .replace(/_/g, '-') // Replace underscores with hyphens
11 .replace(/[^a-z0-9-]/g, '') // Remove invalid characters
12 .replace(/^[^a-z]+/, '') // Ensure it starts with a letter
13 .replace(/-+/g, '-') // Collapse multiple hyphens
14 .replace(/-$/, '') // Remove trailing hyphen
15}
16
17export function getCurrentDirectoryName(): string {
18 return basename(process.cwd())

Callers 3

options.test.tsFile · 0.90
getDirectoryPackageNameFunction · 0.85

Calls 1

replaceMethod · 0.65

Tested by

no test coverage detected