Created
June 9, 2021 16:50
-
-
Save maggiben/32b42e000e17c55c00b3446417b9d83c to your computer and use it in GitHub Desktop.
Given a file path get the suffix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private getSuffixByFileName(fsPath: string): string | undefined { | |
| const metadataFileExt = '-meta.xml'; | |
| const fileName = path.basename(fsPath); | |
| if (fileName.endsWith(metadataFileExt)) { | |
| return fileName.substring(0, fileName.indexOf('-meta.xml')).split('.').slice(1, 2).pop(); | |
| } | |
| return undefined; | |
| } | |
| private getTypeDefinitionByFileName(fsPath: string): MetadataType | undefined { | |
| if (fs.fileExistsSync(fsPath)) { | |
| const suffix = this.getSuffixByFileName(fsPath); | |
| const registryAccess = new RegistryAccess(); | |
| return registryAccess.getTypeBySuffix(suffix); | |
| } | |
| return undefined; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment