blob: c82d3c1e6bee37dc41cc7dd03fdde32e90ca5b3d [file] [log] [blame]
'use strict';
const os = require('os');
const homeDirectory = os.homedir();
module.exports = pathWithTilde => {
if (typeof pathWithTilde !== 'string') {
throw new TypeError(`Expected a string, got ${typeof pathWithTilde}`);
}
return homeDirectory ? pathWithTilde.replace(/^~(?=$|\/|\\)/, homeDirectory) : pathWithTilde;
};