MCPcopy Create free account
hub / github.com/SethGammon/Citadel / getBaseName

Function getBaseName

hooks_src/organize-enforce.js:136–148  ·  view source on GitHub ↗

* Strip companion suffixes from a filename to get the base source name. * e.g., "Button.test.tsx" -> "Button", "auth.spec.js" -> "auth"

(fileName)

Source from the content-addressed store, hash-verified

134 * e.g., "Button.test.tsx" -> "Button", "auth.spec.js" -> "auth"
135 */
136function getBaseName(fileName) {
137 // Remove extension first
138 const ext = path.extname(fileName);
139 let name = fileName.slice(0, -ext.length);
140
141 // Strip companion suffix if present
142 for (const suffix of COMPANION_SUFFIXES) {
143 if (name.endsWith(suffix)) {
144 return name.slice(0, -suffix.length);
145 }
146 }
147 return name;
148}
149
150/**
151 * Check if a source file exists in a given directory for a base name.

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected