MCPcopy Create free account
hub / github.com/11ty/dev-server / #getFileContents

Method #getFileContents

server.js:360–380  ·  view source on GitHub ↗
(localpath, rootDir)

Source from the content-addressed store, hash-verified

358 }
359
360 #getFileContents(localpath, rootDir) {
361 let filepath;
362 let searchLocations = [];
363
364 if(rootDir) {
365 searchLocations.push(TemplatePath.absolutePath(rootDir, localpath));
366 }
367
368 // fallbacks for file:../ installations
369 searchLocations.push(TemplatePath.absolutePath(__dirname, localpath));
370 searchLocations.push(TemplatePath.absolutePath(__dirname, "../../../", localpath));
371
372 for(let loc of searchLocations) {
373 if(fs.existsSync(loc)) {
374 filepath = loc;
375 break;
376 }
377 }
378
379 return this.#readFile(filepath);
380 }
381
382 augmentContentWithNotifier(content, inlineContents = false, options = {}) {
383 let { integrityHash, scriptContents } = options;

Callers 3

onRequestHandlerMethod · 0.95

Calls 1

#readFileMethod · 0.95

Tested by

no test coverage detected