File tree 2 files changed +18
-5
lines changed
2 files changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -88,16 +88,16 @@ export function getEnvPaths(): Paths {
88
88
}
89
89
90
90
/**
91
- * humanPath replaces the home directory in p with ~.
91
+ * humanPath replaces the home directory in path with ~.
92
92
* Makes it more readable.
93
93
*
94
- * @param p
94
+ * @param path - a file path
95
95
*/
96
- export function humanPath ( p ?: string ) : string {
97
- if ( ! p ) {
96
+ export function humanPath ( path ?: string ) : string {
97
+ if ( ! path ) {
98
98
return ""
99
99
}
100
- return p . replace ( os . homedir ( ) , "~" )
100
+ return path . replace ( os . homedir ( ) , "~" )
101
101
}
102
102
103
103
export const generateCertificate = async ( hostname : string ) : Promise < { cert : string ; certKey : string } > => {
Original file line number Diff line number Diff line change @@ -476,3 +476,16 @@ describe("isFile", () => {
476
476
expect ( await util . isFile ( pathToFile ) ) . toBe ( true )
477
477
} )
478
478
} )
479
+
480
+ describe ( "humanPath" , ( ) => {
481
+ it ( "should return an empty string if no path provided" , ( ) => {
482
+ const actual = util . humanPath ( )
483
+ const expected = ""
484
+ expect ( actual ) . toBe ( expected )
485
+ } )
486
+ it ( "should replace the homedir with ~" , ( ) => {
487
+ const actual = util . humanPath ( `/home/coder/code-server` )
488
+ const expected = "~/code-server"
489
+ expect ( actual ) . toBe ( expected )
490
+ } )
491
+ } )
You can’t perform that action at this time.
0 commit comments