From ca2d4e0cdd8c63d9ebfedc3d16d450a870caf31c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vytis=20Valentinavi=C4=8Dius?= Date: Tue, 18 Jul 2023 14:01:34 +0300 Subject: [PATCH] feat: handling the case where "node" is used for tool-versions file. (#812) --- .github/workflows/versions.yml | 3 ++- __tests__/data/.tool-versions-node | 1 + dist/cache-save/index.js | 2 +- dist/setup/index.js | 2 +- src/util.ts | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 __tests__/data/.tool-versions-node diff --git a/.github/workflows/versions.yml b/.github/workflows/versions.yml index 082550ca..2d72d409 100644 --- a/.github/workflows/versions.yml +++ b/.github/workflows/versions.yml @@ -158,7 +158,8 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest, macos-latest] - node-version-file: [.nvmrc, .tool-versions, package.json] + node-version-file: + [.nvmrc, .tool-versions, .tool-versions-node, package.json] steps: - uses: actions/checkout@v3 - name: Remove volta from package.json diff --git a/__tests__/data/.tool-versions-node b/__tests__/data/.tool-versions-node new file mode 100644 index 00000000..8e8ac418 --- /dev/null +++ b/__tests__/data/.tool-versions-node @@ -0,0 +1 @@ +node 14.0.0 diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js index 1b205cd6..cfef4635 100644 --- a/dist/cache-save/index.js +++ b/dist/cache-save/index.js @@ -60754,7 +60754,7 @@ function parseNodeVersionFile(contents) { core.info('Node version file is not JSON file'); } if (!nodeVersion) { - const found = contents.match(/^(?:nodejs\s+)?v?(?[^\s]+)$/m); + const found = contents.match(/^(?:node(js)?\s+)?v?(?[^\s]+)$/m); nodeVersion = (_c = found === null || found === void 0 ? void 0 : found.groups) === null || _c === void 0 ? void 0 : _c.version; } // In the case of an unknown format, diff --git a/dist/setup/index.js b/dist/setup/index.js index 5d2b2358..00774971 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -72336,7 +72336,7 @@ function parseNodeVersionFile(contents) { core.info('Node version file is not JSON file'); } if (!nodeVersion) { - const found = contents.match(/^(?:nodejs\s+)?v?(?[^\s]+)$/m); + const found = contents.match(/^(?:node(js)?\s+)?v?(?[^\s]+)$/m); nodeVersion = (_c = found === null || found === void 0 ? void 0 : found.groups) === null || _c === void 0 ? void 0 : _c.version; } // In the case of an unknown format, diff --git a/src/util.ts b/src/util.ts index 39e48245..3ae94a2d 100644 --- a/src/util.ts +++ b/src/util.ts @@ -13,7 +13,7 @@ export function parseNodeVersionFile(contents: string): string { } if (!nodeVersion) { - const found = contents.match(/^(?:nodejs\s+)?v?(?[^\s]+)$/m); + const found = contents.match(/^(?:node(js)?\s+)?v?(?[^\s]+)$/m); nodeVersion = found?.groups?.version; }