Files
release-action/node_modules/untildify/index.js
Nick Cipollo 880be3d0a7
Some checks failed
Test / check_pr (push) Has been cancelled
Prepare 1.8.6 release
2021-05-24 11:25:03 -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;
};