Skip to content

Commit 4804262

Browse files
author
Gordey Doronin
committed
Stricter check and cleaner messaging
1 parent 8624ddb commit 4804262

3 files changed

Lines changed: 6 additions & 6 deletions

File tree

__tests__/installer.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ describe('setup-node', () => {
696696
);
697697
});
698698

699-
it('fail with unexpected LTS alias (lts/)', async () => {
699+
it('fail with unable to parse LTS alias (lts/)', async () => {
700700
// arrange
701701
inputs['node-version'] = 'lts/';
702702

@@ -713,7 +713,7 @@ describe('setup-node', () => {
713713
'Getting manifest from actions/node-versions@main'
714714
);
715715
expect(cnSpy).toHaveBeenCalledWith(
716-
`::error::Unexpected LTS alias '' for Node version 'lts/'${osm.EOL}`
716+
`::error::Unable to parse LTS alias for Node version 'lts/'${osm.EOL}`
717717
);
718718
});
719719

dist/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13225,7 +13225,7 @@ function getNode(versionSpec, stable, checkLatest, auth, arch = os.arch()) {
1322513225
}
1322613226
exports.getNode = getNode;
1322713227
function isLtsAlias(versionSpec) {
13228-
return versionSpec.startsWith('lts');
13228+
return versionSpec.startsWith('lts/');
1322913229
}
1323013230
function getManifest(auth) {
1323113231
core.debug('Getting manifest from actions/node-versions@main');
@@ -13235,7 +13235,7 @@ function resolveLtsAliasFromManifest(versionSpec, stable, manifest) {
1323513235
var _a;
1323613236
const alias = (_a = versionSpec.split('lts/')[1]) === null || _a === void 0 ? void 0 : _a.toLowerCase();
1323713237
if (!alias) {
13238-
throw new Error(`Unexpected LTS alias '${alias}' for Node version '${versionSpec}'`);
13238+
throw new Error(`Unable to parse LTS alias for Node version '${versionSpec}'`);
1323913239
}
1324013240
core.debug(`LTS alias '${alias}' for Node version '${versionSpec}'`);
1324113241
// Supported formats are `lts/<alias>` and `lts/*`. Where asterisk means highest possible LTS.

src/installer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ export async function getNode(
193193
}
194194

195195
function isLtsAlias(versionSpec: string): boolean {
196-
return versionSpec.startsWith('lts');
196+
return versionSpec.startsWith('lts/');
197197
}
198198

199199
function getManifest(auth: string | undefined): Promise<tc.IToolRelease[]> {
@@ -210,7 +210,7 @@ function resolveLtsAliasFromManifest(
210210

211211
if (!alias) {
212212
throw new Error(
213-
`Unexpected LTS alias '${alias}' for Node version '${versionSpec}'`
213+
`Unable to parse LTS alias for Node version '${versionSpec}'`
214214
);
215215
}
216216

0 commit comments

Comments
 (0)