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

Function normalizeSourceExtension

packages/create/src/template-file.ts:28–48  ·  view source on GitHub ↗
(target: string, typescript: boolean)

Source from the content-addressed store, hash-verified

26}
27
28function normalizeSourceExtension(target: string, typescript: boolean) {
29 if (!typescript) {
30 return target
31 }
32
33 const normalizedTarget = target.replace(/\\/g, '/')
34
35 if (!normalizedTarget.startsWith('src/')) {
36 return target
37 }
38
39 if (normalizedTarget.endsWith('.js')) {
40 return `${target.slice(0, -3)}.ts`
41 }
42
43 if (normalizedTarget.endsWith('.jsx')) {
44 return `${target.slice(0, -4)}.tsx`
45 }
46
47 return target
48}
49
50export function createTemplateFile(environment: Environment, options: Options) {
51 function getPackageManagerAddScript(

Callers 1

createTemplateFileFunction · 0.70

Calls 1

replaceMethod · 0.65

Tested by

no test coverage detected