MCPcopy Create free account
hub / github.com/Snapchat/Valdi / getUserConfig

Function getUserConfig

npm_modules/cli/src/utils/fileUtils.ts:71–92  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

69}
70
71export function getUserConfig(): Constants.UserConfig {
72 let resolvedPath: string | undefined;
73
74 for (const filePath of Constants.VALDI_CONFIG_PATHS) {
75 const unrolledPath = resolveFilePath(filePath);
76 if (fs.existsSync(unrolledPath)) {
77 resolvedPath = unrolledPath;
78 break;
79 }
80 }
81
82 if (resolvedPath === undefined) {
83 throw new CliError(
84 `Please create a Valdi config file in ${Constants.VALDI_CONFIG_PATHS[0] ?? ''} (Running 'valdi bootstrap' takes care of that for you)`,
85 );
86 }
87
88 const configContents = fs.readFileSync(resolvedPath, 'utf8');
89 const parsedYaml = yaml.parse(configContents) as Constants.UserConfig;
90
91 return parsedYaml;
92}
93
94export function getAllFilePaths(directoryPath: string): string[] {
95 directoryPath = resolveFilePath(directoryPath);

Callers

nothing calls this directly

Calls 3

resolveFilePathFunction · 0.85
readFileSyncMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected