thedesk/app/node_modules/modify-filename/index.js
2019-09-12 23:38:13 +09:00

18 lines
410 B
JavaScript

'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));
};