pnpm
Version:
A fast implementation of npm install
23 lines • 683 B
JavaScript
;
const osHomedir = require('os-homedir');
const path = require('path');
function expandTilde(filepath) {
const home = getHomedir();
if (!isHomepath(filepath)) {
return filepath;
}
return path.resolve(home, filepath.substr(2));
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = expandTilde;
function getHomedir() {
const home = osHomedir();
if (!home)
throw new Error('Could not find the homedir');
return home;
}
function isHomepath(filepath) {
return filepath.indexOf('~/') === 0 || filepath.indexOf('~\\') === 0;
}
exports.isHomepath = isHomepath;
//# sourceMappingURL=expandTilde.js.map