Skip to content

Commit

Permalink
fix: fix alias path with up-level references resolve issue (#93)
Browse files Browse the repository at this point in the history
* fix: fix alias path with up-level references resolve issue

This is another attempt to implement PR #84.

Signed-off-by: Jack Cherng <[email protected]>

* tidy codes

Signed-off-by: Jack Cherng <[email protected]>

---------

Signed-off-by: Jack Cherng <[email protected]>
  • Loading branch information
jfcherng authored Mar 23, 2023
1 parent 6122e4a commit 259e3dd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions hyper_click/generic_path_resolver.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from os import path
import json
import re

NODE_CORE_MODULES = {
'assert',
Expand Down Expand Up @@ -189,12 +190,11 @@ def resolve_in_lookup_paths(self, target):
return result

def resolve_from_alias(self, alias, alias_source):
path_parts = path.normpath(self.str_path).split(path.sep)
path_parts = re.split(r"[/\\]+", self.str_path)

if path_parts[0] == alias:
path_parts[0] = alias_source

return self.resolve_relative_to_dir(path.join(*path_parts), self.current_root)
unaliased_path = path.join(alias_source, *path_parts[1:])
return self.resolve_relative_to_dir(path.normpath(unaliased_path), self.current_root)

def resolve_with_exts(self, path_name):
# matching ../index to /index.js
Expand Down

0 comments on commit 259e3dd

Please sign in to comment.