thedesk/app/node_modules/modify-filename/index.js

18 lines
410 B
JavaScript
Raw Permalink Normal View History

2019-09-13 00:38:13 +10:00
'use strict';
var path = require('path');
module.exports = function modifyFilename(pth, modifier) {
if (arguments.length !== 2) {
throw new Error('`path` and `modifier` required');
}
if (Array.isArray(pth)) {
return pth.map(function (el) {
return modifyFilename(el, modifier);
});
}
var ext = path.extname(pth);
return path.join(path.dirname(pth), modifier(path.basename(pth, ext), ext));
};