All files / src/utils path.js

83.33% Statements 5/6
50% Branches 1/2
100% Functions 0/0
83.33% Lines 5/6
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31        1x     1319x                   117x     117x             87x      
/* --------------------------------------------
 * Browser-implementations of NodeJS path module, adapted from Rich Harris, https://github.com/rollup/rollup/blob/master/browser/path.js
 */
 
const splitPathRe = /^(\/?|)([\s\S]*?)((?:\.{1,2}|[^/]+?|)(\.[^./]*|))(?:[/]*)$/
 
function posixSplitPath (filename) {
  const out = splitPathRe.exec(filename)
  out.shift()
  return out
}
 
export function extname (filename) {
  return posixSplitPath(filename)[3]
}
 
export function dirname (path) {
  const match = /(\/|\\)[^/\\]*$/.exec(path)
  if (!match) return '.'
 
  const dir = path.slice(0, -match[0].length)
 
  // If `dir` is the empty string, we're at root.
  return dir || '/'
}
 
export function joinPath () {
  var args = Array.prototype.slice.call(arguments)
  return args.join('/') // TODO, windows
}