adds path to error output

* fix grammar in README & Advance usage docs
* update example in action.yml
This commit is contained in:
La'Kaleigh Harris 2021-11-16 23:43:08 +00:00 committed by GitHub
parent cc6b809bd0
commit 4e4d3278fa
6 changed files with 12 additions and 11 deletions

View file

@ -1,4 +1,5 @@
# setup-node # setup-node
<p align="left"> <p align="left">
<a href="https://github.com/actions/setup-node/actions?query=workflow%3Abuild-test"><img alt="build-test status" src="https://github.com/actions/setup-node/workflows/build-test/badge.svg"></a> <a href="https://github.com/actions/setup-node/actions?query=workflow%3Aversions"><img alt="versions status" src="https://github.com/actions/setup-node/workflows/versions/badge.svg"></a> <a href="https://github.com/actions/setup-node/actions?query=workflow%3Aproxy"><img alt="proxy status" src="https://github.com/actions/setup-node/workflows/proxy/badge.svg"></a> <a href="https://github.com/actions/setup-node/actions?query=workflow%3Abuild-test"><img alt="build-test status" src="https://github.com/actions/setup-node/workflows/build-test/badge.svg"></a> <a href="https://github.com/actions/setup-node/actions?query=workflow%3Aversions"><img alt="versions status" src="https://github.com/actions/setup-node/workflows/versions/badge.svg"></a> <a href="https://github.com/actions/setup-node/actions?query=workflow%3Aproxy"><img alt="proxy status" src="https://github.com/actions/setup-node/workflows/proxy/badge.svg"></a>
</p> </p>
@ -71,7 +72,6 @@ steps:
- run: npm test - run: npm test
``` ```
## Matrix Testing: ## Matrix Testing:
```yaml ```yaml
jobs: jobs:
@ -93,7 +93,7 @@ jobs:
## Advanced usage ## Advanced usage
1. [Check latest version](docs/advanced-usage.md#check-latest-version) 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) 3. [Using different architectures](docs/advanced-usage.md#architecture)
4. [Caching packages dependencies](docs/advanced-usage.md#caching-packages-dependencies) 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) 5. [Using multiple operating systems and architectures](docs/advanced-usage.md#multiple-operating-systems-and-architectures)

View file

@ -624,8 +624,7 @@ describe('setup-node', () => {
it('should throw an error if node-version-file is not found', async () => { it('should throw an error if node-version-file is not found', async () => {
const versionFile = '.nvmrc'; const versionFile = '.nvmrc';
const expectedVersionSpec = '14'; const versionFilePath = path.join(__dirname, '..', versionFile);
process.env['GITHUB_WORKSPACE'] = path.join(__dirname);
inputs['node-version-file'] = versionFile; inputs['node-version-file'] = versionFile;
inSpy.mockImplementation(name => inputs[name]); inSpy.mockImplementation(name => inputs[name]);
@ -641,7 +640,7 @@ describe('setup-node', () => {
expect(existsSpy).toHaveReturnedWith(false); expect(existsSpy).toHaveReturnedWith(false);
expect(parseNodeVersionSpy).not.toHaveBeenCalled(); expect(parseNodeVersionSpy).not.toHaveBeenCalled();
expect(cnSpy).toHaveBeenCalledWith( 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}`
); );
}); });
}); });

View file

@ -8,7 +8,7 @@ inputs:
node-version: node-version:
description: 'Version Spec of the version to use. Examples: 12.x, 10.15.1, >=10.15.0' description: 'Version Spec of the version to use. Examples: 12.x, 10.15.1, >=10.15.0'
node-version-file: 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: architecture:
description: 'Target architecture for Node to use. Examples: x86, x64. Will use system architecture by default.' description: 'Target architecture for Node to use. Examples: x86, x64. Will use system architecture by default.'
check-latest: check-latest:

2
dist/setup/index.js vendored
View file

@ -7014,7 +7014,7 @@ function resolveVersionInput() {
if (versionFileInput) { if (versionFileInput) {
const versionFilePath = path.join(process.env.GITHUB_WORKSPACE, versionFileInput); const versionFilePath = path.join(process.env.GITHUB_WORKSPACE, versionFileInput);
if (!fs_1.default.existsSync(versionFilePath)) { 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')); version = installer.parseNodeVersionFile(fs_1.default.readFileSync(versionFilePath, 'utf8'));
core.info(`Resolved ${versionFileInput} as ${version}`); core.info(`Resolved ${versionFileInput} as ${version}`);

View file

@ -21,9 +21,9 @@ steps:
## Node version file ## 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. 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.
You can check [supported version syntax](https://github.com/actions/setup-node#supported-version-syntax) See [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 action will search for the node version file relative to the repository root.
```yaml ```yaml
steps: steps:

View file

@ -93,7 +93,9 @@ function resolveVersionInput(): string {
versionFileInput versionFileInput
); );
if (!fs.existsSync(versionFilePath)) { 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( version = installer.parseNodeVersionFile(
fs.readFileSync(versionFilePath, 'utf8') fs.readFileSync(versionFilePath, 'utf8')