mirror of
				https://github.com/chickensoft-games/setup-godot.git
				synced 2025-10-31 19:23:57 +00:00 
			
		
		
		
	updated unittests so that they work under both windows and linux/Mac
This commit is contained in:
		
							parent
							
								
									1af6893043
								
							
						
					
					
						commit
						d57e873329
					
				| @ -8,6 +8,7 @@ import { | ||||
|   getPlatform, | ||||
|   parseVersion | ||||
| } from '../src/utils' | ||||
| import normalizePath from 'normalize-path' | ||||
| 
 | ||||
| describe('parseVersion', () => { | ||||
|   test('parses valid godot versions', () => { | ||||
| @ -172,116 +173,116 @@ describe('getExportTemplatePath', () => { | ||||
|       expect( | ||||
|         getExportTemplatePath('4.0.0-beta1', getPlatform('linux'), true) | ||||
|       ).toEqual( | ||||
|         path.join( | ||||
|         normalizePath(path.join( | ||||
|           os.homedir(), | ||||
|           '.local/share/godot/export_templates', | ||||
|           '.local', 'share','godot','export_templates', | ||||
|           '4.0.beta1.mono' | ||||
|         ) | ||||
|         )) | ||||
|       ) | ||||
|       expect( | ||||
|         getExportTemplatePath('4.0.0-beta1', getPlatform('win32'), true) | ||||
|       ).toEqual( | ||||
|         path.join( | ||||
|         normalizePath(path.join( | ||||
|           os.homedir(), | ||||
|           'AppData/Roaming/Godot/export_templates', | ||||
|           'AppData','Roaming','Godot','export_templates', | ||||
|           '4.0.beta1.mono' | ||||
|         ) | ||||
|         )) | ||||
|       ) | ||||
|       expect( | ||||
|         getExportTemplatePath('4.0.0-beta1', getPlatform('darwin'), true) | ||||
|       ).toEqual( | ||||
|         path.join( | ||||
|         normalizePath(path.join( | ||||
|           os.homedir(), | ||||
|           '/Library/Application Support/Godot/export_templates', | ||||
|           'Library','Application Support','Godot','export_templates', | ||||
|           '4.0.beta1.mono' | ||||
|         ) | ||||
|         )) | ||||
|       ) | ||||
|     }) | ||||
|     test('4.0.0', () => { | ||||
|       expect( | ||||
|         getExportTemplatePath('4.0.0', getPlatform('linux'), true) | ||||
|       ).toEqual( | ||||
|         path.join( | ||||
|         normalizePath(path.join( | ||||
|           os.homedir(), | ||||
|           '.local/share/godot/export_templates', | ||||
|           '.local','share','godot','export_templates', | ||||
|           '4.0.stable.mono' | ||||
|         ) | ||||
|         )) | ||||
|       ) | ||||
|       expect( | ||||
|         getExportTemplatePath('4.0.0', getPlatform('win32'), true) | ||||
|       ).toEqual( | ||||
|         path.join( | ||||
|         normalizePath(path.join( | ||||
|           os.homedir(), | ||||
|           'AppData/Roaming/Godot/export_templates', | ||||
|           'AppData','Roaming','Godot','export_templates', | ||||
|           '4.0.stable.mono' | ||||
|         ) | ||||
|         )) | ||||
|       ) | ||||
|       expect( | ||||
|         getExportTemplatePath('4.0.0', getPlatform('darwin'), true) | ||||
|       ).toEqual( | ||||
|         path.join( | ||||
|         normalizePath(path.join( | ||||
|           os.homedir(), | ||||
|           '/Library/Application Support/Godot/export_templates', | ||||
|           'Library','Application Support','Godot','export_templates', | ||||
|           '4.0.stable.mono' | ||||
|         ) | ||||
|         )) | ||||
|       ) | ||||
|     }) | ||||
|     test('3.5.1', () => { | ||||
|       expect( | ||||
|         getExportTemplatePath('3.5.1', getPlatform('linux'), true) | ||||
|       ).toEqual( | ||||
|         path.join( | ||||
|         normalizePath(path.join( | ||||
|           os.homedir(), | ||||
|           '.local/share/godot/templates', | ||||
|           '.local','share','godot','templates', | ||||
|           '3.5.1.stable.mono' | ||||
|         ) | ||||
|         )) | ||||
|       ) | ||||
|       expect( | ||||
|         getExportTemplatePath('3.5.1', getPlatform('win32'), true) | ||||
|       ).toEqual( | ||||
|         path.join( | ||||
|         normalizePath(path.join( | ||||
|           os.homedir(), | ||||
|           'AppData/Roaming/Godot/templates', | ||||
|           'AppData','Roaming','Godot','templates', | ||||
|           '3.5.1.stable.mono' | ||||
|         ) | ||||
|         )) | ||||
|       ) | ||||
|       expect( | ||||
|         getExportTemplatePath('3.5.1', getPlatform('darwin'), true) | ||||
|       ).toEqual( | ||||
|         path.join( | ||||
|         normalizePath(path.join( | ||||
|           os.homedir(), | ||||
|           '/Library/Application Support/Godot/templates', | ||||
|           'Library','Application Support','Godot','templates', | ||||
|           '3.5.1.stable.mono' | ||||
|         ) | ||||
|         )) | ||||
|       ) | ||||
|     }) | ||||
|     test('3.5.0', () => { | ||||
|       expect( | ||||
|         getExportTemplatePath('3.5.0', getPlatform('linux'), true) | ||||
|       ).toEqual( | ||||
|         path.join( | ||||
|         normalizePath(path.join( | ||||
|           os.homedir(), | ||||
|           '.local/share/godot/templates', | ||||
|           '.local','share','godot','templates', | ||||
|           '3.5.stable.mono' | ||||
|         ) | ||||
|         )) | ||||
|       ) | ||||
|       expect( | ||||
|         getExportTemplatePath('3.5.0', getPlatform('win32'), true) | ||||
|       ).toEqual( | ||||
|         path.join( | ||||
|         normalizePath(path.join( | ||||
|           os.homedir(), | ||||
|           'AppData/Roaming/Godot/templates', | ||||
|           'AppData','Roaming','Godot','templates', | ||||
|           '3.5.stable.mono' | ||||
|         ) | ||||
|         )) | ||||
|       ) | ||||
|       expect( | ||||
|         getExportTemplatePath('3.5.0', getPlatform('darwin'), true) | ||||
|       ).toEqual( | ||||
|         path.join( | ||||
|         normalizePath(path.join( | ||||
|           os.homedir(), | ||||
|           '/Library/Application Support/Godot/templates', | ||||
|           'Library','Application Support','Godot','templates', | ||||
|           '3.5.stable.mono' | ||||
|         ) | ||||
|         )) | ||||
|       ) | ||||
|     }) | ||||
|   }) | ||||
| @ -291,104 +292,104 @@ describe('getExportTemplatePath', () => { | ||||
|       expect( | ||||
|         getExportTemplatePath('4.0.0-beta1', getPlatform('linux'), false) | ||||
|       ).toEqual( | ||||
|         path.join( | ||||
|         normalizePath(path.join( | ||||
|           os.homedir(), | ||||
|           '.local/share/godot/export_templates', | ||||
|           '.local','share','godot','export_templates', | ||||
|           '4.0.beta1' | ||||
|         ) | ||||
|         )) | ||||
|       ) | ||||
|       expect( | ||||
|         getExportTemplatePath('4.0.0-beta1', getPlatform('win32'), false) | ||||
|       ).toEqual( | ||||
|         path.join( | ||||
|         normalizePath(path.join( | ||||
|           os.homedir(), | ||||
|           'AppData/Roaming/Godot/export_templates', | ||||
|           'AppData','Roaming','Godot','export_templates', | ||||
|           '4.0.beta1' | ||||
|         ) | ||||
|         )) | ||||
|       ) | ||||
|       expect( | ||||
|         getExportTemplatePath('4.0.0-beta1', getPlatform('darwin'), false) | ||||
|       ).toEqual( | ||||
|         path.join( | ||||
|         normalizePath(path.join( | ||||
|           os.homedir(), | ||||
|           '/Library/Application Support/Godot/export_templates', | ||||
|           'Library','Application Support','Godot','export_templates', | ||||
|           '4.0.beta1' | ||||
|         ) | ||||
|         )) | ||||
|       ) | ||||
|     }) | ||||
|     test('4.0.0', () => { | ||||
|       expect( | ||||
|         getExportTemplatePath('4.0.0', getPlatform('linux'), false) | ||||
|       ).toEqual( | ||||
|         path.join( | ||||
|         normalizePath(path.join( | ||||
|           os.homedir(), | ||||
|           '.local/share/godot/export_templates', | ||||
|           '.local','share','godot','export_templates', | ||||
|           '4.0.stable' | ||||
|         ) | ||||
|         )) | ||||
|       ) | ||||
|       expect( | ||||
|         getExportTemplatePath('4.0.0', getPlatform('win32'), false) | ||||
|       ).toEqual( | ||||
|         path.join( | ||||
|         normalizePath(path.join( | ||||
|           os.homedir(), | ||||
|           'AppData/Roaming/Godot/export_templates', | ||||
|           'AppData','Roaming','Godot','export_templates', | ||||
|           '4.0.stable' | ||||
|         ) | ||||
|         )) | ||||
|       ) | ||||
|       expect( | ||||
|         getExportTemplatePath('4.0.0', getPlatform('darwin'), false) | ||||
|       ).toEqual( | ||||
|         path.join( | ||||
|         normalizePath(path.join( | ||||
|           os.homedir(), | ||||
|           '/Library/Application Support/Godot/export_templates', | ||||
|           'Library','Application Support','Godot','export_templates', | ||||
|           '4.0.stable' | ||||
|         ) | ||||
|         )) | ||||
|       ) | ||||
|     }) | ||||
|     test('3.5.1', () => { | ||||
|       expect( | ||||
|         getExportTemplatePath('3.5.1', getPlatform('linux'), false) | ||||
|       ).toEqual( | ||||
|         path.join(os.homedir(), '.local/share/godot/templates', '3.5.1.stable') | ||||
|         normalizePath(path.join(os.homedir(), '.local','share','godot','templates', '3.5.1.stable')) | ||||
|       ) | ||||
|       expect( | ||||
|         getExportTemplatePath('3.5.1', getPlatform('win32'), false) | ||||
|       ).toEqual( | ||||
|         path.join( | ||||
|         normalizePath(path.join( | ||||
|           os.homedir(), | ||||
|           'AppData/Roaming/Godot/templates', | ||||
|           'AppData','Roaming','Godot','templates', | ||||
|           '3.5.1.stable' | ||||
|         ) | ||||
|         )) | ||||
|       ) | ||||
|       expect( | ||||
|         getExportTemplatePath('3.5.1', getPlatform('darwin'), false) | ||||
|       ).toEqual( | ||||
|         path.join( | ||||
|         normalizePath(path.join( | ||||
|           os.homedir(), | ||||
|           '/Library/Application Support/Godot/templates', | ||||
|           'Library','Application Support','Godot','templates', | ||||
|           '3.5.1.stable' | ||||
|         ) | ||||
|         )) | ||||
|       ) | ||||
|     }) | ||||
|     test('3.5.0', () => { | ||||
|       expect( | ||||
|         getExportTemplatePath('3.5.0', getPlatform('linux'), false) | ||||
|       ).toEqual( | ||||
|         path.join(os.homedir(), '.local/share/godot/templates', '3.5.stable') | ||||
|         normalizePath(path.join(os.homedir(), '.local','share','godot','templates', '3.5.stable')) | ||||
|       ) | ||||
|       expect( | ||||
|         getExportTemplatePath('3.5.0', getPlatform('win32'), false) | ||||
|       ).toEqual( | ||||
|         path.join(os.homedir(), 'AppData/Roaming/Godot/templates', '3.5.stable') | ||||
|         normalizePath(path.join(os.homedir(), 'AppData','Roaming','Godot','templates', '3.5.stable')) | ||||
|       ) | ||||
|       expect( | ||||
|         getExportTemplatePath('3.5.0', getPlatform('darwin'), false) | ||||
|       ).toEqual( | ||||
|         path.join( | ||||
|         normalizePath(path.join( | ||||
|           os.homedir(), | ||||
|           '/Library/Application Support/Godot/templates', | ||||
|           'Library','Application Support','Godot','templates', | ||||
|           '3.5.stable' | ||||
|         ) | ||||
|         )) | ||||
|       ) | ||||
|     }) | ||||
|   }) | ||||
|  | ||||
							
								
								
									
										2
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								package-lock.json
									
									
									
										generated
									
									
									
								
							| @ -26,7 +26,7 @@ | ||||
|         "js-yaml": "^4.1.0", | ||||
|         "prettier": "^2.8.8", | ||||
|         "ts-jest": "^29.1.0", | ||||
|         "typescript": "^5.2.0" | ||||
|         "typescript": "^5.2.2" | ||||
|       } | ||||
|     }, | ||||
|     "node_modules/@aashutoshrathi/word-wrap": { | ||||
|  | ||||
							
								
								
									
										20
									
								
								src/utils.ts
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								src/utils.ts
									
									
									
									
									
								
							| @ -30,7 +30,7 @@ export interface Platform { | ||||
| export class Linux implements Platform { | ||||
|   GODOT_EXPORT_TEMPLATE_BASE_PATH = path.join( | ||||
|     os.homedir(), | ||||
|     '.local/share/godot' | ||||
|     '.local','share','godot' | ||||
|   ) | ||||
| 
 | ||||
|   godotFilenameSuffix(useDotnet: boolean): string { | ||||
| @ -53,7 +53,7 @@ export class Linux implements Platform { | ||||
| 
 | ||||
| export class Windows implements Platform { | ||||
|   GODOT_EXPORT_TEMPLATE_BASE_PATH = path.normalize( | ||||
|     path.join(os.homedir(), '\\AppData\\Roaming\\Godot') | ||||
|     path.join(os.homedir(), 'AppData','Roaming','Godot') | ||||
|   ) | ||||
| 
 | ||||
|   godotFilenameSuffix(useDotnet: boolean): string { | ||||
| @ -77,7 +77,7 @@ export class Windows implements Platform { | ||||
| export class MacOS implements Platform { | ||||
|   GODOT_EXPORT_TEMPLATE_BASE_PATH = path.join( | ||||
|     os.homedir(), | ||||
|     '/Library/Application Support/Godot/' | ||||
|     'Library','Application Support','Godot' | ||||
|   ) | ||||
| 
 | ||||
|   godotFilenameSuffix(useDotnet: boolean): string { | ||||
| @ -201,13 +201,13 @@ export function getExportTemplatePath( | ||||
|   } | ||||
|   if (useDotnet) folderName += '.mono' | ||||
| 
 | ||||
|   return normalize( | ||||
|     path.join( | ||||
|       platform.GODOT_EXPORT_TEMPLATE_BASE_PATH, | ||||
|       version.major === '4' ? 'export_templates' : 'templates', | ||||
|       folderName | ||||
|     ) | ||||
|   ) | ||||
|   var exportTemplateFullPath = path.join( | ||||
|     platform.GODOT_EXPORT_TEMPLATE_BASE_PATH, | ||||
|     version.major === '4' ? 'export_templates' : 'templates', | ||||
|     folderName | ||||
|   ); | ||||
|   var normalizedPath = normalize(exportTemplateFullPath) | ||||
|   return normalizedPath; | ||||
| } | ||||
| 
 | ||||
| export function getGodotFilename( | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user