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.

18 lines
338 B

4 years ago
  1. 'use strict';
  2. var path = require('path');
  3. function replaceExt(npath, ext) {
  4. if (typeof npath !== 'string') {
  5. return npath;
  6. }
  7. if (npath.length === 0) {
  8. return npath;
  9. }
  10. var nFileName = path.basename(npath, path.extname(npath)) + ext;
  11. return path.join(path.dirname(npath), nFileName);
  12. }
  13. module.exports = replaceExt;