You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.6 KiB

4 years ago
  1. <p align="center">
  2. <a href="http://gulpjs.com">
  3. <img height="257" width="114" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png">
  4. </a>
  5. </p>
  6. # replace-ext
  7. [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url]
  8. Replaces a file extension with another one.
  9. ## Usage
  10. ```js
  11. var replaceExt = require('replace-ext');
  12. var path = '/some/dir/file.js';
  13. var newPath = replaceExt(path, '.coffee');
  14. console.log(newPath); // /some/dir/file.coffee
  15. ```
  16. ## API
  17. ### `replaceExt(path, extension)`
  18. Replaces the extension from `path` with `extension` and returns the updated path string.
  19. Does not replace the extension if `path` is not a string or is empty.
  20. ## License
  21. MIT
  22. [downloads-image]: http://img.shields.io/npm/dm/replace-ext.svg
  23. [npm-url]: https://www.npmjs.com/package/replace-ext
  24. [npm-image]: http://img.shields.io/npm/v/replace-ext.svg
  25. [travis-url]: https://travis-ci.org/gulpjs/replace-ext
  26. [travis-image]: http://img.shields.io/travis/gulpjs/replace-ext.svg?label=travis-ci
  27. [appveyor-url]: https://ci.appveyor.com/project/gulpjs/replace-ext
  28. [appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/replace-ext.svg?label=appveyor
  29. [coveralls-url]: https://coveralls.io/r/gulpjs/replace-ext
  30. [coveralls-image]: http://img.shields.io/coveralls/gulpjs/replace-ext/master.svg
  31. [gitter-url]: https://gitter.im/gulpjs/gulp
  32. [gitter-image]: https://badges.gitter.im/gulpjs/gulp.svg