mirror of
				https://github.com/actions/setup-node.git
				synced 2025-11-01 00:23:59 +08:00 
			
		
		
		
	feat: install corepack before enabling
This commit is contained in:
		| @@ -288,30 +288,37 @@ describe('main tests', () => { | |||||||
|     it('should not enable corepack when no input', async () => { |     it('should not enable corepack when no input', async () => { | ||||||
|       inputs['corepack'] = ''; |       inputs['corepack'] = ''; | ||||||
|       await main.run(); |       await main.run(); | ||||||
|       expect(getCommandOutputSpy).not.toHaveBeenCalledWith(expect.stringContaining('corepack')); |       expect(getCommandOutputSpy).not.toHaveBeenCalledWith( | ||||||
|  |         expect.stringContaining('corepack') | ||||||
|  |       ); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|     it('should not enable corepack when input is "false"', async () => { |     it('should not enable corepack when input is "false"', async () => { | ||||||
|       inputs['corepack'] = 'false'; |       inputs['corepack'] = 'false'; | ||||||
|       await main.run(); |       await main.run(); | ||||||
|       expect(getCommandOutputSpy).not.toHaveBeenCalledWith(expect.stringContaining('corepack')); |       expect(getCommandOutputSpy).not.toHaveBeenCalledWith( | ||||||
|  |         expect.stringContaining('corepack') | ||||||
|  |       ); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|     it('should enable corepack when input is "true"', async () => { |     it('should enable corepack when input is "true"', async () => { | ||||||
|       inputs['corepack'] = 'true'; |       inputs['corepack'] = 'true'; | ||||||
|       await main.run(); |       await main.run(); | ||||||
|  |       expect(getCommandOutputSpy).toHaveBeenCalledWith('npm i -g corepack'); | ||||||
|       expect(getCommandOutputSpy).toHaveBeenCalledWith('corepack enable'); |       expect(getCommandOutputSpy).toHaveBeenCalledWith('corepack enable'); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|     it('should enable corepack with a single package manager', async () => { |     it('should enable corepack with a single package manager', async () => { | ||||||
|       inputs['corepack'] = 'npm'; |       inputs['corepack'] = 'npm'; | ||||||
|       await main.run(); |       await main.run(); | ||||||
|  |       expect(getCommandOutputSpy).toHaveBeenCalledWith('npm i -g corepack'); | ||||||
|       expect(getCommandOutputSpy).toHaveBeenCalledWith('corepack enable npm'); |       expect(getCommandOutputSpy).toHaveBeenCalledWith('corepack enable npm'); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|     it('should enable corepack with multiple package managers', async () => { |     it('should enable corepack with multiple package managers', async () => { | ||||||
|       inputs['corepack'] = 'npm yarn'; |       inputs['corepack'] = 'npm yarn'; | ||||||
|       await main.run(); |       await main.run(); | ||||||
|  |       expect(getCommandOutputSpy).toHaveBeenCalledWith('npm i -g corepack'); | ||||||
|       expect(getCommandOutputSpy).toHaveBeenCalledWith( |       expect(getCommandOutputSpy).toHaveBeenCalledWith( | ||||||
|         'corepack enable npm yarn' |         'corepack enable npm yarn' | ||||||
|       ); |       ); | ||||||
|   | |||||||
							
								
								
									
										4
									
								
								dist/cache-save/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								dist/cache-save/index.js
									
									
									
									
										vendored
									
									
								
							| @@ -88239,12 +88239,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) { | |||||||
|     return (mod && mod.__esModule) ? mod : { "default": mod }; |     return (mod && mod.__esModule) ? mod : { "default": mod }; | ||||||
| }; | }; | ||||||
| Object.defineProperty(exports, "__esModule", ({ value: true })); | Object.defineProperty(exports, "__esModule", ({ value: true })); | ||||||
| exports.unique = exports.printEnvDetailsAndSetOutput = exports.getNodeVersionFromFile = void 0; | exports.enableCorepack = exports.unique = exports.printEnvDetailsAndSetOutput = exports.getNodeVersionFromFile = void 0; | ||||||
| const core = __importStar(__nccwpck_require__(7484)); | const core = __importStar(__nccwpck_require__(7484)); | ||||||
| const exec = __importStar(__nccwpck_require__(5236)); | const exec = __importStar(__nccwpck_require__(5236)); | ||||||
| const io = __importStar(__nccwpck_require__(4994)); | const io = __importStar(__nccwpck_require__(4994)); | ||||||
| const fs_1 = __importDefault(__nccwpck_require__(9896)); | const fs_1 = __importDefault(__nccwpck_require__(9896)); | ||||||
| const path_1 = __importDefault(__nccwpck_require__(6928)); | const path_1 = __importDefault(__nccwpck_require__(6928)); | ||||||
|  | const cache_utils_1 = __nccwpck_require__(4673); | ||||||
| function getNodeVersionFromFile(versionFilePath) { | function getNodeVersionFromFile(versionFilePath) { | ||||||
|     var _a, _b, _c, _d, _e; |     var _a, _b, _c, _d, _e; | ||||||
|     if (!fs_1.default.existsSync(versionFilePath)) { |     if (!fs_1.default.existsSync(versionFilePath)) { | ||||||
| @@ -88345,6 +88346,7 @@ function enableCorepack(input) { | |||||||
|                 const packageManagers = input.split(' '); |                 const packageManagers = input.split(' '); | ||||||
|                 corepackArgs.push(...packageManagers); |                 corepackArgs.push(...packageManagers); | ||||||
|             } |             } | ||||||
|  |             yield (0, cache_utils_1.getCommandOutput)('npm i -g corepack'); | ||||||
|             yield (0, cache_utils_1.getCommandOutput)(`corepack ${corepackArgs.join(' ')}`); |             yield (0, cache_utils_1.getCommandOutput)(`corepack ${corepackArgs.join(' ')}`); | ||||||
|         } |         } | ||||||
|     }); |     }); | ||||||
|   | |||||||
							
								
								
									
										4
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								dist/setup/index.js
									
									
									
									
										vendored
									
									
								
							| @@ -97917,12 +97917,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) { | |||||||
|     return (mod && mod.__esModule) ? mod : { "default": mod }; |     return (mod && mod.__esModule) ? mod : { "default": mod }; | ||||||
| }; | }; | ||||||
| Object.defineProperty(exports, "__esModule", ({ value: true })); | Object.defineProperty(exports, "__esModule", ({ value: true })); | ||||||
| exports.unique = exports.printEnvDetailsAndSetOutput = exports.getNodeVersionFromFile = void 0; | exports.enableCorepack = exports.unique = exports.printEnvDetailsAndSetOutput = exports.getNodeVersionFromFile = void 0; | ||||||
| const core = __importStar(__nccwpck_require__(7484)); | const core = __importStar(__nccwpck_require__(7484)); | ||||||
| const exec = __importStar(__nccwpck_require__(5236)); | const exec = __importStar(__nccwpck_require__(5236)); | ||||||
| const io = __importStar(__nccwpck_require__(4994)); | const io = __importStar(__nccwpck_require__(4994)); | ||||||
| const fs_1 = __importDefault(__nccwpck_require__(9896)); | const fs_1 = __importDefault(__nccwpck_require__(9896)); | ||||||
| const path_1 = __importDefault(__nccwpck_require__(6928)); | const path_1 = __importDefault(__nccwpck_require__(6928)); | ||||||
|  | const cache_utils_1 = __nccwpck_require__(4673); | ||||||
| function getNodeVersionFromFile(versionFilePath) { | function getNodeVersionFromFile(versionFilePath) { | ||||||
|     var _a, _b, _c, _d, _e; |     var _a, _b, _c, _d, _e; | ||||||
|     if (!fs_1.default.existsSync(versionFilePath)) { |     if (!fs_1.default.existsSync(versionFilePath)) { | ||||||
| @@ -98023,6 +98024,7 @@ function enableCorepack(input) { | |||||||
|                 const packageManagers = input.split(' '); |                 const packageManagers = input.split(' '); | ||||||
|                 corepackArgs.push(...packageManagers); |                 corepackArgs.push(...packageManagers); | ||||||
|             } |             } | ||||||
|  |             yield (0, cache_utils_1.getCommandOutput)('npm i -g corepack'); | ||||||
|             yield (0, cache_utils_1.getCommandOutput)(`corepack ${corepackArgs.join(' ')}`); |             yield (0, cache_utils_1.getCommandOutput)(`corepack ${corepackArgs.join(' ')}`); | ||||||
|         } |         } | ||||||
|     }); |     }); | ||||||
|   | |||||||
| @@ -115,6 +115,7 @@ export async function enableCorepack(input: string): Promise<void> { | |||||||
|       const packageManagers = input.split(' '); |       const packageManagers = input.split(' '); | ||||||
|       corepackArgs.push(...packageManagers); |       corepackArgs.push(...packageManagers); | ||||||
|     } |     } | ||||||
|  |     await getCommandOutput('npm i -g corepack'); | ||||||
|     await getCommandOutput(`corepack ${corepackArgs.join(' ')}`); |     await getCommandOutput(`corepack ${corepackArgs.join(' ')}`); | ||||||
|   } |   } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jacob Parish
					Jacob Parish