MCPcopy Create free account
hub / github.com/angular/dev-infra / getConfig

Function getConfig

ng-dev/utils/config.ts:120–154  ·  view source on GitHub ↗
(baseDirOrAssertions?: unknown, returnNullOnConfigNotFound = false)

Source from the content-addressed store, hash-verified

118 returnNullOnConfigNotFound: true,
119): Promise<NgDevConfig<Assertions<A>> | null>;
120export async function getConfig(baseDirOrAssertions?: unknown, returnNullOnConfigNotFound = false) {
121 let cachedConfig = getCachedConfig();
122
123 if (cachedConfig === null) {
124 let baseDir: string;
125 if (typeof baseDirOrAssertions === 'string') {
126 baseDir = baseDirOrAssertions;
127 } else {
128 baseDir = determineRepoBaseDirFromCwd();
129 }
130
131 // If the global config is not defined, load it from the file system.
132 // The full path to the configuration file.
133 const configPath = join(baseDir, CONFIG_FILE_PATH_MATCHER);
134 // Read the configuration and validate it before caching it for the future.
135 cachedConfig = await readConfigFile(configPath, returnNullOnConfigNotFound);
136
137 if (returnNullOnConfigNotFound && !cachedConfig) {
138 return null;
139 }
140
141 // Store the newly-read configuration in the cache.
142 setCachedConfig(cachedConfig);
143 }
144
145 if (Array.isArray(baseDirOrAssertions)) {
146 for (const assertion of baseDirOrAssertions) {
147 assertion(cachedConfig);
148 }
149 }
150
151 // Return a clone of the cached global config to ensure that a new instance of the config
152 // is returned each time, preventing unexpected effects of modifications to the config object.
153 return {...cachedConfig, __isNgDevConfigObject: true};
154}
155
156/**
157 * Get the local user configuration from the file system, returning the already loaded copy if it is

Callers 15

resetMergeModeFunction · 0.90
checkValidityFunction · 0.90
validateCommitMessageFunction · 0.85
getMethod · 0.85
getMethod · 0.85
runMethod · 0.85
forRangeMethod · 0.85
handlerFunction · 0.85
handlerFunction · 0.85
handlerFunction · 0.85
handlerFunction · 0.85

Calls 4

getCachedConfigFunction · 0.85
readConfigFileFunction · 0.85
setCachedConfigFunction · 0.85

Tested by

no test coverage detected