MCPcopy Create free account
hub / github.com/observablehq/framework / findDefaultRoot

Function findDefaultRoot

src/config.ts:388–406  ·  view source on GitHub ↗
(defaultRoot?: string)

Source from the content-addressed store, hash-verified

386}
387
388function findDefaultRoot(defaultRoot?: string): string {
389 if (defaultRoot !== undefined) return defaultRoot;
390 const root = existsSync("docs") ? "docs" : "src";
391 console.warn(
392 wrapAnsi(
393 `${yellow("Warning:")} the config file is missing the ${bold(
394 "root"
395 )} option, which specifies the path to the source root.${
396 root === "docs"
397 ? ` The recommended source root is ${bold('"src"')}; however, since ${bold(
398 "docs"
399 )} exists and was previously the default for this option, we will use ${bold('"docs"')}.`
400 : ""
401 } You can suppress this warning by specifying ${bold(`root: ${JSON.stringify(root)}`)} in the config file.\n`,
402 Math.min(80, process.stdout.columns ?? 80)
403 )
404 );
405 return root;
406}
407
408function normalizeArray<T>(spec: unknown, f: (spec: unknown) => T): T[] {
409 return spec == null ? [] : Array.from(spec as ArrayLike<unknown>, f);

Callers 1

normalizeConfigFunction · 0.85

Calls 2

existsSyncFunction · 0.85
warnMethod · 0.45

Tested by

no test coverage detected