|
|
@ -11,15 +11,19 @@ export function basename ( path ) { |
|
|
|
} |
|
|
|
|
|
|
|
export function dirname ( path ) { |
|
|
|
const match = /(\/|\\)[^\/\\]+$/.exec( path ); |
|
|
|
const match = /(\/|\\)[^\/\\]*$/.exec( path ); |
|
|
|
if ( !match ) return '.'; |
|
|
|
return path.slice( 0, -match[0].length ); |
|
|
|
|
|
|
|
const dir = path.slice( 0, -match[0].length ); |
|
|
|
|
|
|
|
// If `dir` is the empty string, we're at root.
|
|
|
|
return dir ? dir : '/'; |
|
|
|
} |
|
|
|
|
|
|
|
export function extname ( path ) { |
|
|
|
const match = /\.[^\.]+$/.exec( path ); |
|
|
|
if ( !match ) return ''; |
|
|
|
return match[0] |
|
|
|
return match[0]; |
|
|
|
} |
|
|
|
|
|
|
|
export function relative ( from, to ) { |
|
|
|