npm stats
  • Search
  • About
  • Repo
  • Sponsor
  • more
    • Search
    • About
    • Repo
    • Sponsor

Made by Antonio Ramirez

file-name

0.1.0

@jonschlinkert

npmHomeRepoSnykSocket
Downloads:9903
$ npm install file-name
DailyWeeklyMonthlyYearly

file-name NPM version

Get the basename of a filepath excluding extension.

Because I've typed the following one too many times:

function filename(fp) {
  return path.basename(fp, path.extname(fp));
}

Install

Install with npm

$ npm i file-name --save

Usage

var filename = require('file-name');
filename('a/b/c/foo.json');
//=> 'foo'

Related projects

Other useful node.js path utils:

  • is-absolute: Return true if a file path is absolute. | homepage
  • is-relative: Returns true if the path appears to be relative. | homepage
  • parse-filepath: Parse a filepath into an object. Falls back on the native node.js path.parse method if… more | homepage
  • relative: Get the relative filepath from path A to path B. Calculates from file-to-directory, file-to-file, directory-to-file,… more | homepage

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Author

Jon Schlinkert

  • github/jonschlinkert
  • twitter/jonschlinkert

License

Copyright © 2015 Jon Schlinkert Released under the MIT license.


This file was generated by verb-cli on October 20, 2015.