fix #12130 ; improve naming scheme in fakePackageName

This commit is contained in:
Timothee Cour
2019-09-06 11:26:48 -07:00
parent e0f3e8432a
commit 4129993689

View File

@@ -39,13 +39,11 @@ proc getPackageName*(conf: ConfigRef; path: string): string =
if parents <= 0: break
proc fakePackageName*(conf: ConfigRef; path: AbsoluteFile): string =
# foo/../bar becomes foo7_7bar
result = relativeTo(path, conf.projectPath, '/').string.multiReplace(
{"/": "7", "..": "_", "7": "77", "_": "__", ":": "8", "8": "88"})
# foo/../bar becomes foo@..@bar
result = relativeTo(path, conf.projectPath, '/').string.multiReplace({"/": "@", "@": "@@"})
proc demanglePackageName*(path: string): string =
result = path.multiReplace(
{"88": "8", "8": ":", "77": "7", "__": "_", "_7": "../", "7": "/"})
result = path.multiReplace({"@@": "@", "@": "/"})
proc withPackageName*(conf: ConfigRef; path: AbsoluteFile): AbsoluteFile =
let x = getPackageName(conf, path.string)