Skip to content

Commit

Permalink
Replace dash to slash for asdf lts syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
doong-jo committed Mar 26, 2023
1 parent a4fcaaf commit 2dd7314
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 4 additions & 3 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import * as cache from '@actions/cache';
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import * as tc from '@actions/tool-cache';
import * as cache from '@actions/cache';

import fs from 'fs';
import path from 'path';
import osm from 'os';
import path from 'path';

import each from 'jest-each';

import OfficialBuilds from '../src/distributions/official_builds/official_builds';
import * as main from '../src/main';
import * as util from '../src/util';
import OfficialBuilds from '../src/distributions/official_builds/official_builds';

describe('main tests', () => {
let inputs = {} as any;
Expand Down Expand Up @@ -95,6 +95,7 @@ describe('main tests', () => {
${'lts/erbium'} | ${'lts/erbium'}
${'lts/*'} | ${'lts/*'}
${'nodejs 12.3.4'} | ${'12.3.4'}
${'nodejs lts-erbium'} | ${'lts/erbium'}
${'ruby 2.3.4\nnodejs 12.3.4\npython 3.4.5'} | ${'12.3.4'}
${''} | ${''}
${'unknown format'} | ${'unknown format'}
Expand Down
8 changes: 7 additions & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ export function parseNodeVersionFile(contents: string): string {

if (!nodeVersion) {
const found = contents.match(/^(?:nodejs\s+)?v?(?<version>[^\s]+)$/m);
nodeVersion = found?.groups?.version;


if (found?.groups?.version?.includes('lts-')) {
nodeVersion = found?.groups?.version.replace(/-/g, '/');
} else {
nodeVersion = found?.groups?.version;
}
}

// In the case of an unknown format,
Expand Down

0 comments on commit 2dd7314

Please sign in to comment.