change-file-extension
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

change-file-extension

Change the file extension of a path

Install

npm install change-file-extension

Usage

import changeFileExtension from 'change-file-extension';

changeFileExtension('foo/bar.txt', 'md');
//=> 'foo/bar.md'

changeFileExtension('foo/bar.txt', '.md');
//=> 'foo/bar.md'

changeFileExtension('bar.txt', '');
//=> 'bar'

API

changeFileExtension(filePath, extension)

filePath

Type: string

The file path whose extension needs to be changed.

extension

Type: string

The new extension to replace the old one.

To remove the extension, pass an empty string.

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.1
    45,886
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.1
    45,886
  • 0.1.0
    385

Package Sidebar

Install

npm i change-file-extension

Weekly Downloads

46,271

Version

0.1.1

License

MIT

Unpacked Size

3.82 kB

Total Files

5

Last publish

Collaborators

  • sindresorhus