gleen version from source if it's not provided

This commit is contained in:
Alex Sanders 2021-03-05 12:23:24 +00:00
parent 5c355be170
commit 6a8b79956a
No known key found for this signature in database
GPG key ID: 0EEA728031DBA293
5 changed files with 43492 additions and 210 deletions

View file

@ -1,9 +1,41 @@
# 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>
## About this fork
This is a fork of the official GitHub [actions/setup-node](https://github.com/marketplace/actions/setup-node-js-environment) that checks common Node config files when picking the version of Node to use.
### Example
```yaml
- name: Setup node
uses: guardian/actions-setup-node@main
```
It checks the following places:
1. `.nvmrc`
2. `engines.node` in `package.json`
3. `.node-version`
4. `.n-node-version`
5. `.naverc`
6. `.nodeenvrc`
and finally the following environment variables:
7. `NODE_VERSION`
8. `NODIST_NODE_VERSION`
> Behind the scenes, it uses [@ehmicky](https://github.com/ehmicky)'s [`preferred-node-version`](https://www.npmjs.com/package/) 😍.
If it _still_ can't find anything, it falls back to the the original action's default behaviour (using the PATH version).
_Below is the rest of the original readme…_
---
This action sets by node environment for use in actions by: This action sets by node environment for use in actions by:
- optionally downloading and caching a version of node - npm by version spec and add to PATH - optionally downloading and caching a version of node - npm by version spec and add to PATH

42644
dist/index.js vendored

File diff suppressed because one or more lines are too long

1019
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -29,6 +29,7 @@
"@actions/http-client": "^1.0.6", "@actions/http-client": "^1.0.6",
"@actions/io": "^1.0.2", "@actions/io": "^1.0.2",
"@actions/tool-cache": "^1.5.4", "@actions/tool-cache": "^1.5.4",
"preferred-node-version": "^1.1.0",
"semver": "^6.1.1" "semver": "^6.1.1"
}, },
"devDependencies": { "devDependencies": {

View file

@ -4,6 +4,7 @@ import * as auth from './authutil';
import * as path from 'path'; import * as path from 'path';
import {URL} from 'url'; import {URL} from 'url';
import os = require('os'); import os = require('os');
import preferredNodeVersion from 'preferred-node-version';
export async function run() { export async function run() {
try { try {
@ -12,6 +13,9 @@ export async function run() {
// If not supplied then task is still used to setup proxy, auth, etc... // If not supplied then task is still used to setup proxy, auth, etc...
// //
let version = core.getInput('node-version'); let version = core.getInput('node-version');
if (!version) {
version = (await preferredNodeVersion()).version;
}
if (!version) { if (!version) {
version = core.getInput('version'); version = core.getInput('version');
} }