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

Method get

ng-dev/utils/git/authenticated-git-client.ts:166–188  ·  view source on GitHub ↗

* Static method to get the singleton instance of the `AuthenticatedGitClient`, * creating it if it has not yet been created.

()

Source from the content-addressed store, hash-verified

164 * creating it if it has not yet been created.
165 */
166 static override async get(): Promise<AuthenticatedGitClient> {
167 if (AuthenticatedGitClient._token === null) {
168 throw new Error('No instance of `AuthenticatedGitClient` has been configured.');
169 }
170
171 // If there is no cached authenticated instance, create one and cache the promise
172 // immediately. This avoids constructing a client twice accidentally when e.g. waiting
173 // for the configuration to be loaded.
174 if (AuthenticatedGitClient._authenticatedInstance === null) {
175 AuthenticatedGitClient._authenticatedInstance = (async (
176 token: string,
177 userType: UserType,
178 ) => {
179 return new AuthenticatedGitClient(
180 token,
181 userType,
182 await getConfig([assertValidGithubConfig]),
183 );
184 })(AuthenticatedGitClient._token, AuthenticatedGitClient._userType);
185 }
186
187 return AuthenticatedGitClient._authenticatedInstance;
188 }
189
190 /** Configures an authenticated git client. */
191 static configure(token: string, userType: UserType = 'user'): void {

Callers 1

Calls 1

getConfigFunction · 0.85

Tested by

no test coverage detected