| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 1× 1× 26× 26× 26× 2× 1× 1× 24× 18× 6× 4× 2× 1× | 'use strict';
var join = require('path').join;
function expandHomeDir(path) {
var isWindows = process.platform == 'win32';
var homeDir = process.env[isWindows ? 'USERPROFILE' : 'HOME'];
if (path === '~') {
if (!homeDir) {
return false;
}
return homeDir;
}
if (!path || path[0] !== '~') {
return path;
}
if (!homeDir) {
return false;
}
return join(homeDir, path.slice(2));
}
module.exports = expandHomeDir;
|