MCPcopy Index your code
hub / github.com/npmx-dev/npmx.dev / getCreateShortName

Function getCreateShortName

shared/utils/package-analysis.ts:210–229  ·  view source on GitHub ↗
(createPackageName: string)

Source from the content-addressed store, hash-verified

208 * e.g., "create-vite" -> "vite", "@scope/create-foo" -> "@scope/foo", "@scope/create" -> "@scope"
209 */
210export function getCreateShortName(createPackageName: string): string {
211 if (createPackageName.startsWith('@')) {
212 // @scope/create -> @scope, @scope/create-foo -> @scope/foo
213 const slashIndex = createPackageName.indexOf('/')
214 const scope = createPackageName.slice(0, slashIndex)
215 const name = createPackageName.slice(slashIndex + 1)
216 if (name === 'create') {
217 return scope
218 }
219 if (name.startsWith('create-')) {
220 return `${scope}/${name.slice('create-'.length)}`
221 }
222 return createPackageName
223 }
224 // create-vite -> vite
225 if (createPackageName.startsWith('create-')) {
226 return createPackageName.slice('create-'.length)
227 }
228 return createPackageName
229}
230
231/**
232 * Map of JS extensions to their corresponding declaration file extensions.

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected