2 * expand-tilde <https://github.com/jonschlinkert/expand-tilde>
4 * Copyright (c) 2015 Jon Schlinkert.
5 * Licensed under the MIT license.
8 var path = require('path');
9 var homedir = require('os-homedir');
11 module.exports = function expandTilde(filepath) {
14 if (filepath.charCodeAt(0) === 126 /* ~ */) {
15 if (filepath.charCodeAt(1) === 43 /* + */) {
16 return path.join(process.cwd(), filepath.slice(2));
18 return home ? path.join(home, filepath.slice(1)) : filepath;