mirror of
				https://github.com/actions/setup-dotnet.git
				synced 2025-10-31 19:33:45 +00:00 
			
		
		
		
	Feedback
This commit is contained in:
		
							parent
							
								
									3280df5864
								
							
						
					
					
						commit
						db362d751e
					
				
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @ -4,4 +4,5 @@ node_modules/.bin | ||||
| node_modules/typescript | ||||
| node_modules/@types | ||||
| node_modules/prettier | ||||
| __tests__/runner/* | ||||
| __tests__/runner/* | ||||
| global.json | ||||
| @ -9,6 +9,7 @@ const tempDir = path.join(__dirname, 'runner', 'temp'); | ||||
| 
 | ||||
| process.env['RUNNER_TOOL_CACHE'] = toolDir; | ||||
| process.env['RUNNER_TEMP'] = tempDir; | ||||
| import * as setup from '../src/setup-dotnet'; | ||||
| import * as installer from '../src/installer'; | ||||
| 
 | ||||
| const IS_WINDOWS = process.platform === 'win32'; | ||||
| @ -40,6 +41,25 @@ describe('installer tests', () => { | ||||
|     } | ||||
|   }, 100000); | ||||
| 
 | ||||
|   it('Acquires version of dotnet if no matching version is installed', async () => { | ||||
|     const dotnetDir = path.join(toolDir, 'dncs', '2.2.105', os.arch()); | ||||
| 
 | ||||
|     const globalJsonPath = path.join(process.cwd(), 'global.json'); | ||||
|     const jsonContents = `{${os.EOL}"sdk": {${os.EOL}"version": "2.2.105"${os.EOL}}${os.EOL}}` | ||||
|     if(!fs.existsSync(globalJsonPath)) { | ||||
|       fs.writeFileSync(globalJsonPath, jsonContents); | ||||
|     } | ||||
|     await setup.run(); | ||||
| 
 | ||||
|     expect(fs.existsSync(`${dotnetDir}.complete`)).toBe(true); | ||||
|     if (IS_WINDOWS) { | ||||
|       expect(fs.existsSync(path.join(dotnetDir, 'dotnet.exe'))).toBe(true); | ||||
|     } else { | ||||
|       expect(fs.existsSync(path.join(dotnetDir, 'dotnet'))).toBe(true); | ||||
|     } | ||||
|     fs.unlinkSync(globalJsonPath); | ||||
|   }, 100000); | ||||
| 
 | ||||
|   it('Throws if no location contains correct dotnet version', async () => { | ||||
|     let thrown = false; | ||||
|     try { | ||||
|  | ||||
| @ -29,6 +29,7 @@ function run() { | ||||
|             let version = core.getInput('version'); | ||||
|             if (!version) { | ||||
|                 // Try to fall back to global.json
 | ||||
|                 core.debug('No version found, trying to find version from global.json'); | ||||
|                 const globalJsonPath = path.join(process.cwd(), 'global.json'); | ||||
|                 if (fs.existsSync(globalJsonPath)) { | ||||
|                     const globalJson = JSON.parse(fs.readFileSync(globalJsonPath, { encoding: 'utf8' })); | ||||
| @ -50,4 +51,5 @@ function run() { | ||||
|         } | ||||
|     }); | ||||
| } | ||||
| exports.run = run; | ||||
| run(); | ||||
|  | ||||
| @ -3,15 +3,16 @@ import * as installer from './installer'; | ||||
| import * as fs from 'fs'; | ||||
| import * as path from 'path'; | ||||
| 
 | ||||
| async function run() { | ||||
| export async function run() { | ||||
|   try { | ||||
|     //
 | ||||
|     // Version is optional.  If supplied, install / use from the tool cache
 | ||||
|     // If not supplied then task is still used to setup proxy, auth, etc...
 | ||||
|     //
 | ||||
|     let version = core.getInput('version'); | ||||
|     let version: string = core.getInput('version'); | ||||
|     if (!version) { | ||||
|       // Try to fall back to global.json
 | ||||
|       core.debug('No version found, trying to find version from global.json'); | ||||
|       const globalJsonPath = path.join(process.cwd(), 'global.json'); | ||||
|       if (fs.existsSync(globalJsonPath)) { | ||||
|         const globalJson = JSON.parse( | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user