Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gulpjs/replace-ext
Replaces a file extension with another one.
https://github.com/gulpjs/replace-ext
basename file-extension filepath gulp path
Last synced: 6 days ago
JSON representation
Replaces a file extension with another one.
- Host: GitHub
- URL: https://github.com/gulpjs/replace-ext
- Owner: gulpjs
- License: mit
- Created: 2014-02-25T20:17:18.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2023-03-14T00:13:11.000Z (almost 2 years ago)
- Last Synced: 2025-01-20T00:08:27.543Z (13 days ago)
- Topics: basename, file-extension, filepath, gulp, path
- Language: JavaScript
- Homepage:
- Size: 20.5 KB
- Stars: 46
- Watchers: 8
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# replace-ext
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coveralls Status][coveralls-image]][coveralls-url]
Replaces a file extension with another one.
## Usage
```js
var replaceExt = require('replace-ext');var path = '/some/dir/file.js';
var newPath = replaceExt(path, '.coffee');console.log(newPath); // /some/dir/file.coffee
```## API
### `replaceExt(path, extension)`
Replaces the extension from `path` with `extension` and returns the updated path string.
Does not replace the extension if `path` is not a string or is empty.
## License
MIT
[downloads-image]: https://img.shields.io/npm/dm/replace-ext.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/replace-ext
[npm-image]: https://img.shields.io/npm/v/replace-ext.svg?style=flat-square[ci-url]: https://github.com/gulpjs/replace-ext/actions?query=workflow:dev
[ci-image]: https://img.shields.io/github/actions/workflow/status/gulpjs/replace-ext/dev.yml?branch=master&style=flat-square[coveralls-url]: https://coveralls.io/r/gulpjs/replace-ext
[coveralls-image]: https://img.shields.io/coveralls/gulpjs/replace-ext/master.svg?style=flat-square