Skip to content

Commit

Permalink
fix: api binary host config (#383)
Browse files Browse the repository at this point in the history
  • Loading branch information
elrrrrrrr authored Jan 29, 2023
1 parent 4884e9f commit 8a2415f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/common/adapter/binary/ApiBinary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class ApiBinary extends AbstractBinary {
private readonly config: EggAppConfig;

async fetch(dir: string, binaryName?: string): Promise<FetchResult | undefined> {
const apiUrl = this.config.syncBinaryFromAPISource || `${this.config.sourceRegistry}/-/binary`;
const apiUrl = this.config.cnpmcore.syncBinaryFromAPISource || `${this.config.cnpmcore.sourceRegistry}/-/binary`;
const url = `${apiUrl}/${binaryName}${dir}`;
const data = await this.requestJSON(url);
if (!Array.isArray(data)) {
Expand Down
6 changes: 3 additions & 3 deletions test/common/adapter/binary/ApiBinary.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('test/common/adapter/binary/ApiBinary.test.ts', () => {
});
describe('fetch()', () => {
it('should fetch root: / work', async () => {
mock(app.config, 'syncBinaryFromAPISource', 'https://cnpmjs.org/mirrors/apis');
mock(app.config.cnpmcore, 'syncBinaryFromAPISource', 'https://cnpmjs.org/mirrors/apis');
app.mockHttpclient('https://cnpmjs.org/mirrors/apis/node/', 'GET', {
data: await TestUtil.readFixturesFile('cnpmjs.org/mirrors/apis/node.json'),
persist: false,
Expand Down Expand Up @@ -44,8 +44,8 @@ describe('test/common/adapter/binary/ApiBinary.test.ts', () => {
});

it('should fetch subdir: /v16.13.1/ work', async () => {
mock(app.config, 'syncBinaryFromAPISource', null);
mock(app.config, 'sourceRegistry', 'https://r.cnpmjs.org');
mock(app.config.cnpmcore, 'syncBinaryFromAPISource', null);
mock(app.config.cnpmcore, 'sourceRegistry', 'https://r.cnpmjs.org');
app.mockHttpclient('https://r.cnpmjs.org/-/binary/node/v16.13.1/', 'GET', {
data: await TestUtil.readFixturesFile('r.cnpmjs.org/-/binary/node/v16.13.1.json'),
persist: false,
Expand Down

0 comments on commit 8a2415f

Please sign in to comment.