mirror of
				https://github.com/actions/setup-node.git
				synced 2025-11-04 01:03:33 +00:00 
			
		
		
		
	work on resolving comments
This commit is contained in:
		
							parent
							
								
									65270bbd55
								
							
						
					
					
						commit
						882cfbaf78
					
				
							
								
								
									
										2
									
								
								.github/workflows/versions.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.github/workflows/versions.yml
									
									
									
									
										vendored
									
									
								
							@ -57,7 +57,7 @@ jobs:
 | 
			
		||||
      fail-fast: false
 | 
			
		||||
      matrix:
 | 
			
		||||
        os: [ubuntu-latest, windows-latest, macos-latest]
 | 
			
		||||
        node-version: [17-nightly, 18-nightly, 19-nightly]
 | 
			
		||||
        node-version: [16.0.0-nightly20210420a0261d231c, 17-nightly, 18.0.0-nightly]
 | 
			
		||||
    steps:
 | 
			
		||||
      - uses: actions/checkout@v3
 | 
			
		||||
      - name: Setup Node
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										10
									
								
								__tests__/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								__tests__/README.md
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,10 @@
 | 
			
		||||
Files located in data directory are used only for testing purposes. 
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
## Here the list of files in the data directory
 | 
			
		||||
 - `.nvmrc`, `.tools-versions` and `package.json` are used to test node-version-file logic
 | 
			
		||||
 - `package-lock.json`, `pnpm-lock.yaml` and `yarn.lock` are used to test cache logic 
 | 
			
		||||
 - `versions-manifest.json` is used for unit testing to check downloading Node.js versions from the node-versions repository.
 | 
			
		||||
 - `node-dist-index.json` is used for unit testing to check downloading Node.js versions from the official site.
 | 
			
		||||
 - `node-rc-index.json` is used for unit testing to check downloading Node.js rc versions from the official site.
 | 
			
		||||
 - `node-nightly-index.json` is used for unit testing to check downloading Node.js nightly builds from the official site.
 | 
			
		||||
							
								
								
									
										9
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										9
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							@ -73438,7 +73438,7 @@ function evaluateNightlyVersions(versions, versionSpec) {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if (range) {
 | 
			
		||||
        versions.sort((a, b) => +semver.lt(a, b) - 0.5);
 | 
			
		||||
        versions.sort(semver.rcompare);
 | 
			
		||||
        for (const currentVersion of versions) {
 | 
			
		||||
            const satisfied = semver.satisfies(currentVersion.replace('-nightly', '-nightly.'), range, { includePrerelease: true }) && currentVersion.includes('nightly');
 | 
			
		||||
            if (satisfied) {
 | 
			
		||||
@ -73462,12 +73462,7 @@ function evaluateVersions(versions, versionSpec) {
 | 
			
		||||
    if (versionSpec.includes('nightly')) {
 | 
			
		||||
        return evaluateNightlyVersions(versions, versionSpec);
 | 
			
		||||
    }
 | 
			
		||||
    versions = versions.sort((a, b) => {
 | 
			
		||||
        if (semver.gt(a, b)) {
 | 
			
		||||
            return 1;
 | 
			
		||||
        }
 | 
			
		||||
        return -1;
 | 
			
		||||
    });
 | 
			
		||||
    versions = versions.sort(semver.rcompare);
 | 
			
		||||
    for (let i = versions.length - 1; i >= 0; i--) {
 | 
			
		||||
        const potential = versions[i];
 | 
			
		||||
        const satisfied = semver.satisfies(potential, versionSpec);
 | 
			
		||||
 | 
			
		||||
@ -108,6 +108,8 @@ jobs:
 | 
			
		||||
 | 
			
		||||
You can specify a nightly version to download it from https://nodejs.org/download/nightly. 
 | 
			
		||||
 | 
			
		||||
### Install nightly build for specific node version
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
jobs:
 | 
			
		||||
  build:
 | 
			
		||||
@ -117,7 +119,39 @@ jobs:
 | 
			
		||||
      - uses: actions/checkout@v3
 | 
			
		||||
      - uses: actions/setup-node@v3
 | 
			
		||||
        with:
 | 
			
		||||
          node-version: '16.0.0-nightly' # or 16-nightly
 | 
			
		||||
          node-version: '16.0.0-nightly' # it will install the latest nigthly release for node 16.0.0
 | 
			
		||||
      - run: npm ci
 | 
			
		||||
      - run: npm test
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### Install nightly build for major node version
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
jobs:
 | 
			
		||||
  build:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    name: Node sample
 | 
			
		||||
    steps:
 | 
			
		||||
      - uses: actions/checkout@v3
 | 
			
		||||
      - uses: actions/setup-node@v3
 | 
			
		||||
        with:
 | 
			
		||||
          node-version: '16-nightly' # it will install the latest nigthly release for node 16
 | 
			
		||||
      - run: npm ci
 | 
			
		||||
      - run: npm test
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
### Install the exact nightly version
 | 
			
		||||
 | 
			
		||||
```yaml
 | 
			
		||||
jobs:
 | 
			
		||||
  build:
 | 
			
		||||
    runs-on: ubuntu-latest
 | 
			
		||||
    name: Node sample
 | 
			
		||||
    steps:
 | 
			
		||||
      - uses: actions/checkout@v3
 | 
			
		||||
      - uses: actions/setup-node@v3
 | 
			
		||||
        with:
 | 
			
		||||
          node-version: '16.0.0-nightly20210420a0261d231c'
 | 
			
		||||
      - run: npm ci
 | 
			
		||||
      - run: npm test
 | 
			
		||||
```
 | 
			
		||||
@ -140,6 +174,8 @@ jobs:
 | 
			
		||||
      - run: npm test
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
**Note:** You should specify the exact version for rc: `16.0.0-rc.1`.
 | 
			
		||||
 | 
			
		||||
## Caching packages data
 | 
			
		||||
The action follows [actions/cache](https://github.com/actions/cache/blob/main/examples.md#node---npm) guidelines, and caches global cache on the machine instead of `node_modules`, so cache can be reused between different Node.js versions.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -370,7 +370,7 @@ function evaluateNightlyVersions(
 | 
			
		||||
  versionSpec: string
 | 
			
		||||
): string {
 | 
			
		||||
  let version = '';
 | 
			
		||||
  let range: string | null | undefined;
 | 
			
		||||
  let range: string | undefined;
 | 
			
		||||
  const [raw, prerelease] = versionSpec.split('-');
 | 
			
		||||
  const isValidVersion = semver.valid(raw);
 | 
			
		||||
  const rawVersion = isValidVersion ? raw : semver.coerce(raw);
 | 
			
		||||
@ -383,7 +383,7 @@ function evaluateNightlyVersions(
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (range) {
 | 
			
		||||
    versions.sort((a, b) => +semver.lt(a, b) - 0.5);
 | 
			
		||||
    versions.sort(semver.rcompare);
 | 
			
		||||
    for (const currentVersion of versions) {
 | 
			
		||||
      const satisfied: boolean =
 | 
			
		||||
        semver.satisfies(
 | 
			
		||||
@ -416,12 +416,7 @@ function evaluateVersions(versions: string[], versionSpec: string): string {
 | 
			
		||||
    return evaluateNightlyVersions(versions, versionSpec);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  versions = versions.sort((a, b) => {
 | 
			
		||||
    if (semver.gt(a, b)) {
 | 
			
		||||
      return 1;
 | 
			
		||||
    }
 | 
			
		||||
    return -1;
 | 
			
		||||
  });
 | 
			
		||||
  versions = versions.sort(semver.rcompare);
 | 
			
		||||
  for (let i = versions.length - 1; i >= 0; i--) {
 | 
			
		||||
    const potential: string = versions[i];
 | 
			
		||||
    const satisfied: boolean = semver.satisfies(potential, versionSpec);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user