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
<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>
</p>
@ -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)

View file

@ -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}`
);
});
});

View file

@ -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:

2
dist/setup/index.js vendored
View file

@ -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}`);

View file

@ -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:

View file

@ -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')