Skip to content

Commit

Permalink
fix(initialize): use correct url to fetch additional test runner conf…
Browse files Browse the repository at this point in the history
…ig (#4699)

Fixes #4698
  • Loading branch information
nicojs authored Jan 29, 2024
1 parent df51d24 commit 59e53d0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 28 deletions.
48 changes: 21 additions & 27 deletions packages/core/src/initializer/npm-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,35 +48,29 @@ export class NpmClient {
return this.search(`/-/v1/search?text=keywords:${encodeURIComponent('@stryker-mutator/reporter-plugin')}`).then(mapSearchResultToPromptOption);
}

public getAdditionalConfig(pkgInfo: PackageSummary): Promise<PackageInfo> {
const path = `/${encodeURIComponent(pkgInfo.name)}@${pkgInfo.version}`;
return this.innerNpmClient
.get<PackageInfo>(path)
.then(handleResult(path))
.catch((err) => {
this.log.warn(
`Could not fetch additional initialization config for dependency ${pkgInfo.name}. You might need to configure it manually`,
err,
);
return pkgInfo;
});
public async getAdditionalConfig(pkgInfo: PackageSummary): Promise<PackageInfo> {
const path = `/${encodeURIComponent(pkgInfo.name)}/${pkgInfo.version}`;
try {
const response = await this.innerNpmClient.get<PackageInfo>(path);
return handleResult(path)(response);
} catch (err) {
this.log.warn(`Could not fetch additional initialization config for dependency ${pkgInfo.name}. You might need to configure it manually`, err);
return pkgInfo;
}
}

private search(path: string): Promise<NpmSearchResult> {
private async search(path: string): Promise<NpmSearchResult> {
this.log.debug(`Searching: ${path}`);
return this.innerNpmClient
.get<NpmSearchResult>(path)
.then(handleResult(path))
.catch((err) => {
this.log.error(
`Unable to reach 'https://registry.npmjs.com' (for query ${path}). Please check your internet connection.`,
errorToString(err),
);
const result: NpmSearchResult = {
objects: [],
total: 0,
};
return result;
});
try {
const response = await this.innerNpmClient.get<NpmSearchResult>(path);
return handleResult(path)(response);
} catch (err) {
this.log.error(`Unable to reach 'https://registry.npmjs.com' (for query ${path}). Please check your internet connection.`, errorToString(err));
const result: NpmSearchResult = {
objects: [],
total: 0,
};
return result;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ describe(StrykerInitializer.name, () => {
keywords: [],
version: '1.1.1',
};
npmRestClient.get.withArgs(`/${encodeURIComponent(name)}@1.1.1`).resolves({
npmRestClient.get.withArgs(`/${encodeURIComponent(name)}/1.1.1`).resolves({
result,
statusCode: 200,
headers: {},
Expand Down

0 comments on commit 59e53d0

Please sign in to comment.