MCPcopy Create free account
hub / github.com/Crain99/cc-reverse / is3xRoot

Function is3xRoot

src/core/reverseEngine.js:206–230  ·  view source on GitHub ↗
(root)

Source from the content-addressed store, hash-verified

204 * @returns {Object}
205 */
206function detectProjectVersion(sourcePath, versionHint) {
207 const normalizedSourcePath = path.resolve(sourcePath);
208 const sourceBasename = path.basename(normalizedSourcePath);
209 const candidateRoots = [normalizedSourcePath];
210
211 // 兼容用户直接传入 assets/res 目录的场景
212 if (sourceBasename === 'assets' || sourceBasename === 'res') {
213 candidateRoots.push(path.dirname(normalizedSourcePath));
214 }
215
216 const uniqueCandidateRoots = [...new Set(candidateRoots)];
217
218 /**
219 * Find first existing path, or first match of a basename regex under a dir.
220 * Used for MD5 Cache builds: main.<hash>.js / settings.<hash>.js / project.<hash>.js
221 */
222 function findExistingPath(pathArray) {
223 for (const filePath of pathArray) {
224 if (fs.existsSync(filePath)) {
225 return filePath;
226 }
227 }
228 return null;
229 }
230
231 function findHashedFile(dir, pattern) {
232 if (!fs.existsSync(dir)) return null;
233 let entries;

Callers 1

detectProjectVersionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected