Package Exports
- parse-filepath
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (parse-filepath) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
parse-filepath 
Parse a filepath into an object, yielding predictable results for basename and extname.
Install
Install with npm
npm i parse-filepath --save
Usage
var parsePath = require('parse-filepath');
parsePath('foo/bar/baz/index.md.html');
// returns
{
name: 'index',
dirname: 'foo/bar/baz',
extname: '.md.html',
basename: 'index.md.html',
extSegments: ['.md', '.html']
}
Differences from node.js path
Given the following string:
var str = 'foo/bar/baz/quux.min.js';
.basename
Node.js:
path.basename(str)
=>quux.min.js
path.basename(str, path.extname(str))
=>quux.min
whaaaaa!?
parse-filepath:
parsePath(str).basename
=>quux.min.js
parsePath(str).name
=>quux
.extname
Node.js:
path.extname(str)
=>.js
parse-filepath
parsePath(str).extname
=>.min.js
.dotfiles
As an example, .travis.yml
is parsed to:
{
name: 'travis',
dirname: '.',
extname: '.yml',
basename: '.travis.yml',
extSegments: ['.yml']
}
And .gitignore
is parsed to:
{
name: 'gitignore',
dirname: '.',
extname: '',
basename: '.gitignore',
extSegments: []
}
Author
Jon Schlinkert
License
Copyright (c) 2014 Jon Schlinkert
Released under the MIT license
This file was generated by verb on November 13, 2014.