Skip to content

Commit 4731556

Browse files
chore: change fallback message with mirrors
1 parent 8f2ef77 commit 4731556

File tree

3 files changed

+41
-2
lines changed

3 files changed

+41
-2
lines changed

__tests__/official-installer.test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,43 @@ describe('setup-node', () => {
282282
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
283283
});
284284

285+
it('falls back to a version from node dist from mirror', async () => {
286+
os.platform = 'linux';
287+
os.arch = 'x64';
288+
289+
// a version which is not in the manifest but is in node dist
290+
const versionSpec = '11.15.0';
291+
const mirror = 'https://my_mirror_url';
292+
inputs['node-version'] = versionSpec;
293+
inputs['always-auth'] = false;
294+
inputs['token'] = 'faketoken';
295+
inputs['mirror'] = mirror;
296+
inputs['mirror-token'] = 'faketoken';
297+
298+
// ... but not in the local cache
299+
findSpy.mockImplementation(() => '');
300+
301+
dlSpy.mockImplementation(async () => '/some/temp/path');
302+
const toolPath = path.normalize('/cache/node/11.15.0/x64');
303+
exSpy.mockImplementation(async () => '/some/other/temp/path');
304+
cacheSpy.mockImplementation(async () => toolPath);
305+
306+
await main.run();
307+
308+
const expPath = path.join(toolPath, 'bin');
309+
310+
expect(getManifestSpy).toHaveBeenCalled();
311+
expect(logSpy).toHaveBeenCalledWith(
312+
`Attempting to download ${versionSpec}...`
313+
);
314+
expect(logSpy).toHaveBeenCalledWith(
315+
`Not found in manifest. Falling back to download directly from ${mirror}`
316+
);
317+
expect(dlSpy).toHaveBeenCalled();
318+
expect(exSpy).toHaveBeenCalled();
319+
expect(cnSpy).toHaveBeenCalledWith(`::add-path::${expPath}${osm.EOL}`);
320+
});
321+
285322
it('falls back to a version from node dist', async () => {
286323
os.platform = 'linux';
287324
os.arch = 'x64';

dist/setup/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97564,7 +97564,7 @@ class OfficialBuilds extends base_distribution_1.default {
9756497564
}
9756597565
}
9756697566
else {
97567-
core.info('Not found in manifest. Falling back to download directly from Node');
97567+
core.info(`Not found in manifest. Falling back to download directly from ${this.nodeInfo.mirror || 'Node'}`);
9756897568
}
9756997569
}
9757097570
catch (err) {

src/distributions/official_builds/official_builds.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ export default class OfficialBuilds extends BaseDistribution {
9696
}
9797
} else {
9898
core.info(
99-
'Not found in manifest. Falling back to download directly from Node'
99+
`Not found in manifest. Falling back to download directly from ${
100+
this.nodeInfo.mirror || 'Node'
101+
}`
100102
);
101103
}
102104
} catch (err) {

0 commit comments

Comments
 (0)