Cypress_TS/CyLukTs/lukan/node_modules/untildify/index.js

13 lines
331 B
JavaScript
Raw Normal View History

2023-08-15 16:35:50 +00:00
'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;
};