summary refs log tree commit diff
path: root/resources/app/node_modules/modify-filename/index.js
blob: 1c53fbad24aeea13da72ceff61adc115415b1d44 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
'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));
};