MCPcopy Index your code
hub / github.com/TypeScriptToLua/TypeScriptToLua / locateConfigFile

Function locateConfigFile

src/cli/tsconfig.ts:8–37  ·  view source on GitHub ↗
(commandLine: ParsedCommandLine)

Source from the content-addressed store, hash-verified

6import { ParsedCommandLine, updateParsedConfigFile } from "./parse";
7
8export function locateConfigFile(commandLine: ParsedCommandLine): ts.Diagnostic | string | undefined {
9 const { project } = commandLine.options;
10 if (!project) {
11 if (commandLine.fileNames.length > 0) {
12 return undefined;
13 }
14
15 const searchPath = normalizeSlashes(process.cwd());
16 return ts.findConfigFile(searchPath, ts.sys.fileExists);
17 }
18
19 if (commandLine.fileNames.length !== 0) {
20 return cliDiagnostics.optionProjectCannotBeMixedWithSourceFilesOnACommandLine();
21 }
22
23 // TODO: Unlike tsc, this resolves `.` to absolute path
24 const fileOrDirectory = normalizeSlashes(path.resolve(process.cwd(), project));
25 if (ts.sys.directoryExists(fileOrDirectory)) {
26 const configFileName = path.posix.join(fileOrDirectory, "tsconfig.json");
27 if (ts.sys.fileExists(configFileName)) {
28 return configFileName;
29 } else {
30 return cliDiagnostics.cannotFindATsconfigJsonAtTheSpecifiedDirectory(project);
31 }
32 } else if (ts.sys.fileExists(fileOrDirectory)) {
33 return fileOrDirectory;
34 } else {
35 return cliDiagnostics.theSpecifiedPathDoesNotExist(project);
36 }
37}
38
39export function parseConfigFileWithSystem(
40 configFileName: string,

Callers 2

locateFunction · 0.90
executeCommandLineFunction · 0.90

Calls 4

normalizeSlashesFunction · 0.90
resolveMethod · 0.80
directoryExistsMethod · 0.80
fileExistsMethod · 0.80

Tested by 1

locateFunction · 0.72