Browse Source

Merge branch 'gh-53' of https://github.com/Victorystick/rollup into Victorystick-gh-53

contingency-plan
Rich Harris 10 years ago
parent
commit
850085f1f6
  1. 10
      src/utils/path.js

10
src/utils/path.js

@ -11,15 +11,19 @@ export function basename ( path ) {
} }
export function dirname ( path ) { export function dirname ( path ) {
const match = /(\/|\\)[^\/\\]+$/.exec( path ); const match = /(\/|\\)[^\/\\]*$/.exec( path );
if ( !match ) return '.'; 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 ) { export function extname ( path ) {
const match = /\.[^\.]+$/.exec( path ); const match = /\.[^\.]+$/.exec( path );
if ( !match ) return ''; if ( !match ) return '';
return match[0] return match[0];
} }
export function relative ( from, to ) { export function relative ( from, to ) {

Loading…
Cancel
Save