diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index cf83e93..6278daa 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -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' - ) + )) ) }) }) diff --git a/package-lock.json b/package-lock.json index 64565ae..0401098 100644 --- a/package-lock.json +++ b/package-lock.json @@ -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": { diff --git a/src/utils.ts b/src/utils.ts index 93831aa..5daac8d 100644 --- a/src/utils.ts +++ b/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(