From 4e4d3278fa142a90b9492fbb176512244fe98222 Mon Sep 17 00:00:00 2001 From: La'Kaleigh Harris <35268101+Xlient@users.noreply.github.com> Date: Tue, 16 Nov 2021 23:43:08 +0000 Subject: [PATCH] adds path to error output * fix grammar in README & Advance usage docs * update example in action.yml --- README.md | 4 ++-- __tests__/installer.test.ts | 5 ++--- action.yml | 2 +- dist/setup/index.js | 2 +- docs/advanced-usage.md | 6 +++--- src/main.ts | 4 +++- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 28636268..3e01b7fe 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # setup-node +
@@ -71,7 +72,6 @@ steps: - run: npm test ``` - ## Matrix Testing: ```yaml jobs: @@ -93,7 +93,7 @@ jobs: ## Advanced usage 1. [Check latest version](docs/advanced-usage.md#check-latest-version) -2. [Using a node version file](docs/advanced-usage.md#Node-version-file) +2. [Using a node version file](docs/advanced-usage.md#node-version-file) 3. [Using different architectures](docs/advanced-usage.md#architecture) 4. [Caching packages dependencies](docs/advanced-usage.md#caching-packages-dependencies) 5. [Using multiple operating systems and architectures](docs/advanced-usage.md#multiple-operating-systems-and-architectures) diff --git a/__tests__/installer.test.ts b/__tests__/installer.test.ts index 716dd4bb..4565dd4c 100644 --- a/__tests__/installer.test.ts +++ b/__tests__/installer.test.ts @@ -624,8 +624,7 @@ describe('setup-node', () => { it('should throw an error if node-version-file is not found', async () => { const versionFile = '.nvmrc'; - const expectedVersionSpec = '14'; - process.env['GITHUB_WORKSPACE'] = path.join(__dirname); + const versionFilePath = path.join(__dirname, '..', versionFile); inputs['node-version-file'] = versionFile; inSpy.mockImplementation(name => inputs[name]); @@ -641,7 +640,7 @@ describe('setup-node', () => { expect(existsSpy).toHaveReturnedWith(false); expect(parseNodeVersionSpy).not.toHaveBeenCalled(); expect(cnSpy).toHaveBeenCalledWith( - `::error::The specified node version file does not exist${osm.EOL}` + `::error::The specified node version file at: ${versionFilePath} does not exist${osm.EOL}` ); }); }); diff --git a/action.yml b/action.yml index 66b170ca..900588b2 100644 --- a/action.yml +++ b/action.yml @@ -8,7 +8,7 @@ inputs: node-version: description: 'Version Spec of the version to use. Examples: 12.x, 10.15.1, >=10.15.0' node-version-file: - description: 'File containing the version Spec of the version to use. Examples: .nvmrc' + description: 'File containing the version Spec of the version to use. Examples: .nvmrc, .node-version, .n-node-version' architecture: description: 'Target architecture for Node to use. Examples: x86, x64. Will use system architecture by default.' check-latest: diff --git a/dist/setup/index.js b/dist/setup/index.js index 912b976e..fc9ea9fa 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -7014,7 +7014,7 @@ function resolveVersionInput() { if (versionFileInput) { const versionFilePath = path.join(process.env.GITHUB_WORKSPACE, versionFileInput); if (!fs_1.default.existsSync(versionFilePath)) { - throw new Error('The specified node version file does not exist'); + throw new Error(`The specified node version file at: ${versionFilePath} does not exist`); } version = installer.parseNodeVersionFile(fs_1.default.readFileSync(versionFilePath, 'utf8')); core.info(`Resolved ${versionFileInput} as ${version}`); diff --git a/docs/advanced-usage.md b/docs/advanced-usage.md index ddb40463..960772f5 100644 --- a/docs/advanced-usage.md +++ b/docs/advanced-usage.md @@ -21,9 +21,9 @@ steps: ## Node version file -The `node-version-file` input accepts path to file containing the version of Node.js used by project, for example `.nvmrc`. If both the `node-version` and the `node-version-file` inputs are provided the `node-version` input is used. -You can check [supported version syntax](https://github.com/actions/setup-node#supported-version-syntax) -> The action will search for the node version file relative to repository root. +The `node-version-file` input accepts a path to a file containing the version of Node.js to be used by a project, for example `.nvmrc` or `.node-version`. If both the `node-version` and the `node-version-file` inputs are provided then the `node-version` input is used. +See [supported version syntax](https://github.com/actions/setup-node#supported-version-syntax) +> The action will search for the node version file relative to the repository root. ```yaml steps: diff --git a/src/main.ts b/src/main.ts index e14819e5..49a1080b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -93,7 +93,9 @@ function resolveVersionInput(): string { versionFileInput ); if (!fs.existsSync(versionFilePath)) { - throw new Error('The specified node version file does not exist'); + throw new Error( + `The specified node version file at: ${versionFilePath} does not exist` + ); } version = installer.parseNodeVersionFile( fs.readFileSync(versionFilePath, 'utf8')