-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(fix) Use Path for dirname resolution
- Loading branch information
1 parent
b194c62
commit c99e68e
Showing
7 changed files
with
133 additions
and
74 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#module=resolver | ||
//module=resolver,cli | ||
class Path { | ||
construct new(path) { | ||
_path = path | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//module=resolver,cli | ||
class PathType { | ||
static SIMPLE { 1 } | ||
static ABSOLUTE { 2 } | ||
static RELATIVE { 3 } | ||
|
||
static unixAbsolute(path) { path.startsWith("/") } | ||
static windowsAbsolute(path) { | ||
// TODO: is this not escaped properly by the stock Python code generator | ||
return path.count >= 3 && path[1..2] == ":\\" | ||
} | ||
static resolve(path) { | ||
if (path.startsWith(".")) return PathType.RELATIVE | ||
if (unixAbsolute(path)) return PathType.ABSOLUTE | ||
if (windowsAbsolute(path)) return PathType.ABSOLUTE | ||
|
||
return PathType.SIMPLE | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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