mirror of
				https://kkgithub.com/actions/setup-node.git
				synced 2025-11-04 12:46:16 +08:00 
			
		
		
		
	Compare commits
	
		
			3 Commits
		
	
	
		
			tiwarishub
			...
			v3.4.0
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 5b949b50c3 | |||
| dbb64ac1d1 | |||
| 82496765f3 | 
							
								
								
									
										3
									
								
								.github/workflows/versions.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.github/workflows/versions.yml
									
									
									
									
										vendored
									
									
								
							@ -92,12 +92,13 @@ jobs:
 | 
				
			|||||||
      fail-fast: false
 | 
					      fail-fast: false
 | 
				
			||||||
      matrix:
 | 
					      matrix:
 | 
				
			||||||
        os: [ubuntu-latest, windows-latest, macos-latest]
 | 
					        os: [ubuntu-latest, windows-latest, macos-latest]
 | 
				
			||||||
 | 
					        node-version-file: [.nvmrc, .tool-versions]
 | 
				
			||||||
    steps:
 | 
					    steps:
 | 
				
			||||||
      - uses: actions/checkout@v3
 | 
					      - uses: actions/checkout@v3
 | 
				
			||||||
      - name: Setup node from node version file
 | 
					      - name: Setup node from node version file
 | 
				
			||||||
        uses: ./
 | 
					        uses: ./
 | 
				
			||||||
        with:
 | 
					        with:
 | 
				
			||||||
          node-version-file: '__tests__/data/.nvmrc'
 | 
					          node-version-file: '__tests__/data/${{ matrix.node-version-file }}'
 | 
				
			||||||
      - name: Verify node
 | 
					      - name: Verify node
 | 
				
			||||||
        run: __tests__/verify-node.sh 14
 | 
					        run: __tests__/verify-node.sh 14
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -295,7 +295,7 @@ describe('run', () => {
 | 
				
			|||||||
      expect(setFailedSpy).not.toHaveBeenCalled();
 | 
					      expect(setFailedSpy).not.toHaveBeenCalled();
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    it('save with -1 cacheId, should not fail workflow', async () => {
 | 
					    it('save with -1 cacheId , should not fail workflow', async () => {
 | 
				
			||||||
      inputs['cache'] = 'npm';
 | 
					      inputs['cache'] = 'npm';
 | 
				
			||||||
      getStateSpy.mockImplementation((name: string) => {
 | 
					      getStateSpy.mockImplementation((name: string) => {
 | 
				
			||||||
        if (name === State.CacheMatchedKey) {
 | 
					        if (name === State.CacheMatchedKey) {
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										1
									
								
								__tests__/data/.tool-versions
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								__tests__/data/.tool-versions
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					nodejs 14.0.0
 | 
				
			||||||
@ -8,6 +8,7 @@ import fs from 'fs';
 | 
				
			|||||||
import cp from 'child_process';
 | 
					import cp from 'child_process';
 | 
				
			||||||
import osm = require('os');
 | 
					import osm = require('os');
 | 
				
			||||||
import path from 'path';
 | 
					import path from 'path';
 | 
				
			||||||
 | 
					import each from 'jest-each';
 | 
				
			||||||
import * as main from '../src/main';
 | 
					import * as main from '../src/main';
 | 
				
			||||||
import * as auth from '../src/authutil';
 | 
					import * as auth from '../src/authutil';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -904,3 +905,23 @@ describe('setup-node', () => {
 | 
				
			|||||||
    );
 | 
					    );
 | 
				
			||||||
  });
 | 
					  });
 | 
				
			||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					describe('helper methods', () => {
 | 
				
			||||||
 | 
					  describe('parseNodeVersionFile', () => {
 | 
				
			||||||
 | 
					    each`
 | 
				
			||||||
 | 
					      contents                                     | expected
 | 
				
			||||||
 | 
					      ${'12'}                                      | ${'12'}
 | 
				
			||||||
 | 
					      ${'12.3'}                                    | ${'12.3'}
 | 
				
			||||||
 | 
					      ${'12.3.4'}                                  | ${'12.3.4'}
 | 
				
			||||||
 | 
					      ${'v12.3.4'}                                 | ${'12.3.4'}
 | 
				
			||||||
 | 
					      ${'lts/erbium'}                              | ${'lts/erbium'}
 | 
				
			||||||
 | 
					      ${'lts/*'}                                   | ${'lts/*'}
 | 
				
			||||||
 | 
					      ${'nodejs 12.3.4'}                           | ${'12.3.4'}
 | 
				
			||||||
 | 
					      ${'ruby 2.3.4\nnodejs 12.3.4\npython 3.4.5'} | ${'12.3.4'}
 | 
				
			||||||
 | 
					      ${''}                                        | ${''}
 | 
				
			||||||
 | 
					      ${'unknown format'}                          | ${'unknown format'}
 | 
				
			||||||
 | 
					    `.it('parses "$contents"', ({contents, expected}) => {
 | 
				
			||||||
 | 
					      expect(im.parseNodeVersionFile(contents)).toBe(expected);
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					  });
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
				
			|||||||
@ -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, .node-version.'
 | 
					    description: 'File containing the version Spec of the version to use.  Examples: .nvmrc, .node-version, .tool-versions.'
 | 
				
			||||||
  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:
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										1356
									
								
								dist/cache-save/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1356
									
								
								dist/cache-save/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										1904
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1904
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@ -56,7 +56,7 @@ steps:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
## Node version file
 | 
					## Node version file
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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.
 | 
					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`, `.node-version` or `.tool-versions`. 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)
 | 
					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.
 | 
					> The action will search for the node version file relative to the repository root.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										54
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										54
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							@ -14,7 +14,7 @@
 | 
				
			|||||||
        "@actions/exec": "^1.1.0",
 | 
					        "@actions/exec": "^1.1.0",
 | 
				
			||||||
        "@actions/github": "^1.1.0",
 | 
					        "@actions/github": "^1.1.0",
 | 
				
			||||||
        "@actions/glob": "^0.2.0",
 | 
					        "@actions/glob": "^0.2.0",
 | 
				
			||||||
        "@actions/http-client": "^2.0.1",
 | 
					        "@actions/http-client": "^1.0.11",
 | 
				
			||||||
        "@actions/io": "^1.0.2",
 | 
					        "@actions/io": "^1.0.2",
 | 
				
			||||||
        "@actions/tool-cache": "^1.5.4",
 | 
					        "@actions/tool-cache": "^1.5.4",
 | 
				
			||||||
        "semver": "^6.1.1"
 | 
					        "semver": "^6.1.1"
 | 
				
			||||||
@ -81,14 +81,6 @@
 | 
				
			|||||||
        "@actions/http-client": "^1.0.11"
 | 
					        "@actions/http-client": "^1.0.11"
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "node_modules/@actions/core/node_modules/@actions/http-client": {
 | 
					 | 
				
			||||||
      "version": "1.0.11",
 | 
					 | 
				
			||||||
      "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz",
 | 
					 | 
				
			||||||
      "integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==",
 | 
					 | 
				
			||||||
      "dependencies": {
 | 
					 | 
				
			||||||
        "tunnel": "0.0.6"
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    },
 | 
					 | 
				
			||||||
    "node_modules/@actions/exec": {
 | 
					    "node_modules/@actions/exec": {
 | 
				
			||||||
      "version": "1.1.0",
 | 
					      "version": "1.1.0",
 | 
				
			||||||
      "resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.0.tgz",
 | 
					      "resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.0.tgz",
 | 
				
			||||||
@ -116,11 +108,11 @@
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "node_modules/@actions/http-client": {
 | 
					    "node_modules/@actions/http-client": {
 | 
				
			||||||
      "version": "2.0.1",
 | 
					      "version": "1.0.11",
 | 
				
			||||||
      "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
 | 
					      "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz",
 | 
				
			||||||
      "integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
 | 
					      "integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==",
 | 
				
			||||||
      "dependencies": {
 | 
					      "dependencies": {
 | 
				
			||||||
        "tunnel": "^0.0.6"
 | 
					        "tunnel": "0.0.6"
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "node_modules/@actions/io": {
 | 
					    "node_modules/@actions/io": {
 | 
				
			||||||
@ -141,14 +133,6 @@
 | 
				
			|||||||
        "uuid": "^3.3.2"
 | 
					        "uuid": "^3.3.2"
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "node_modules/@actions/tool-cache/node_modules/@actions/http-client": {
 | 
					 | 
				
			||||||
      "version": "1.0.11",
 | 
					 | 
				
			||||||
      "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz",
 | 
					 | 
				
			||||||
      "integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==",
 | 
					 | 
				
			||||||
      "dependencies": {
 | 
					 | 
				
			||||||
        "tunnel": "0.0.6"
 | 
					 | 
				
			||||||
      }
 | 
					 | 
				
			||||||
    },
 | 
					 | 
				
			||||||
    "node_modules/@azure/abort-controller": {
 | 
					    "node_modules/@azure/abort-controller": {
 | 
				
			||||||
      "version": "1.0.4",
 | 
					      "version": "1.0.4",
 | 
				
			||||||
      "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.0.4.tgz",
 | 
					      "resolved": "https://registry.npmjs.org/@azure/abort-controller/-/abort-controller-1.0.4.tgz",
 | 
				
			||||||
@ -5148,16 +5132,6 @@
 | 
				
			|||||||
      "integrity": "sha512-NB1UAZomZlCV/LmJqkLhNTqtKfFXJZAUPcfl/zqG7EfsQdeUJtaWO98SGbuQ3pydJ3fHl2CvI/51OKYlCYYcaw==",
 | 
					      "integrity": "sha512-NB1UAZomZlCV/LmJqkLhNTqtKfFXJZAUPcfl/zqG7EfsQdeUJtaWO98SGbuQ3pydJ3fHl2CvI/51OKYlCYYcaw==",
 | 
				
			||||||
      "requires": {
 | 
					      "requires": {
 | 
				
			||||||
        "@actions/http-client": "^1.0.11"
 | 
					        "@actions/http-client": "^1.0.11"
 | 
				
			||||||
      },
 | 
					 | 
				
			||||||
      "dependencies": {
 | 
					 | 
				
			||||||
        "@actions/http-client": {
 | 
					 | 
				
			||||||
          "version": "1.0.11",
 | 
					 | 
				
			||||||
          "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz",
 | 
					 | 
				
			||||||
          "integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==",
 | 
					 | 
				
			||||||
          "requires": {
 | 
					 | 
				
			||||||
            "tunnel": "0.0.6"
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "@actions/exec": {
 | 
					    "@actions/exec": {
 | 
				
			||||||
@ -5187,11 +5161,11 @@
 | 
				
			|||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "@actions/http-client": {
 | 
					    "@actions/http-client": {
 | 
				
			||||||
      "version": "2.0.1",
 | 
					      "version": "1.0.11",
 | 
				
			||||||
      "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.0.1.tgz",
 | 
					      "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz",
 | 
				
			||||||
      "integrity": "sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==",
 | 
					      "integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==",
 | 
				
			||||||
      "requires": {
 | 
					      "requires": {
 | 
				
			||||||
        "tunnel": "^0.0.6"
 | 
					        "tunnel": "0.0.6"
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "@actions/io": {
 | 
					    "@actions/io": {
 | 
				
			||||||
@ -5210,16 +5184,6 @@
 | 
				
			|||||||
        "@actions/io": "^1.0.1",
 | 
					        "@actions/io": "^1.0.1",
 | 
				
			||||||
        "semver": "^6.1.0",
 | 
					        "semver": "^6.1.0",
 | 
				
			||||||
        "uuid": "^3.3.2"
 | 
					        "uuid": "^3.3.2"
 | 
				
			||||||
      },
 | 
					 | 
				
			||||||
      "dependencies": {
 | 
					 | 
				
			||||||
        "@actions/http-client": {
 | 
					 | 
				
			||||||
          "version": "1.0.11",
 | 
					 | 
				
			||||||
          "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-1.0.11.tgz",
 | 
					 | 
				
			||||||
          "integrity": "sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==",
 | 
					 | 
				
			||||||
          "requires": {
 | 
					 | 
				
			||||||
            "tunnel": "0.0.6"
 | 
					 | 
				
			||||||
          }
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    "@azure/abort-controller": {
 | 
					    "@azure/abort-controller": {
 | 
				
			||||||
 | 
				
			|||||||
@ -28,7 +28,7 @@
 | 
				
			|||||||
    "@actions/exec": "^1.1.0",
 | 
					    "@actions/exec": "^1.1.0",
 | 
				
			||||||
    "@actions/github": "^1.1.0",
 | 
					    "@actions/github": "^1.1.0",
 | 
				
			||||||
    "@actions/glob": "^0.2.0",
 | 
					    "@actions/glob": "^0.2.0",
 | 
				
			||||||
    "@actions/http-client": "^2.0.1",
 | 
					    "@actions/http-client": "^1.0.11",
 | 
				
			||||||
    "@actions/io": "^1.0.2",
 | 
					    "@actions/io": "^1.0.2",
 | 
				
			||||||
    "@actions/tool-cache": "^1.5.4",
 | 
					    "@actions/tool-cache": "^1.5.4",
 | 
				
			||||||
    "semver": "^6.1.1"
 | 
					    "semver": "^6.1.1"
 | 
				
			||||||
 | 
				
			|||||||
@ -495,12 +495,16 @@ function translateArchToDistUrl(arch: string): string {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export function parseNodeVersionFile(contents: string): string {
 | 
					export function parseNodeVersionFile(contents: string): string {
 | 
				
			||||||
  let nodeVersion = contents.trim();
 | 
					  const found = contents.match(/^(?:nodejs\s+)?v?(?<version>[^\s]+)$/m);
 | 
				
			||||||
 | 
					  const nodeVersion = found?.groups?.version;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (/^v\d/.test(nodeVersion)) {
 | 
					  if (nodeVersion) {
 | 
				
			||||||
    nodeVersion = nodeVersion.substring(1);
 | 
					    return nodeVersion;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  return nodeVersion;
 | 
					
 | 
				
			||||||
 | 
					  // In the case of an unknown format,
 | 
				
			||||||
 | 
					  // return as is and evaluate the version separately.
 | 
				
			||||||
 | 
					  return contents.trim();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function isLatestSyntax(versionSpec): boolean {
 | 
					function isLatestSyntax(versionSpec): boolean {
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user