forked from srcbookdev/srcbook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement top level create file and folder (srcbookdev#346)
- Loading branch information
1 parent
d3dae44
commit ea9d6df
Showing
9 changed files
with
295 additions
and
41 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
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// This file and client side code assumes posix paths. It is incomplete and handles basic | ||
// functionality. That should be ok as we expect a subset of behavior and assume simple paths. | ||
|
||
const ROOT_PATH = '.'; | ||
|
||
export function dirname(path: string): string { | ||
path = path.trim(); | ||
|
||
if (path === '' || path === ROOT_PATH) { | ||
return ROOT_PATH; | ||
} | ||
|
||
const parts = path.split('/'); | ||
|
||
if (parts.length === 1) { | ||
return '.'; | ||
} | ||
|
||
return parts.pop() || '.'; | ||
} | ||
|
||
export function extname(path: string) { | ||
const idx = path.lastIndexOf('.'); | ||
return idx === -1 ? '' : path.slice(idx); | ||
} |
Oops, something went wrong.