Files
release-action/node_modules/untildify/index.js
Nick Cipollo 95215a3cb6
Some checks failed
Test / check_pr (push) Has been cancelled
Prepate 1.8.5 release
2021-05-12 11:44:59 -04:00

13 lines
331 B
JavaScript

'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;
};