Update helpers.expandTildePath to handle receiving an os object without homedir, address minor @ts-check confusion in same file.

This commit is contained in:
David Anson 2022-07-24 12:22:32 -07:00
parent 95466e29be
commit 5b0588f378
3 changed files with 6 additions and 5 deletions

View file

@ -1126,7 +1126,7 @@ module.exports.getNextChildToken = getNextChildToken;
* @returns {string} Absolute path (or original path).
*/
function expandTildePath(file, os) {
const homedir = os && os.homedir();
const homedir = os && os.homedir && os.homedir();
return homedir ? file.replace(/^~($|\/|\\)/, `${homedir}$1`) : file;
}
module.exports.expandTildePath = expandTildePath;