index.js 283 B

123456789
  1. 'use strict';
  2. var path = require('path');
  3. var osHomedir = require('os-homedir');
  4. var home = osHomedir();
  5. module.exports = function (str) {
  6. str = path.normalize(str) + path.sep;
  7. return (str.indexOf(home) === 0 ? str.replace(home + path.sep, '~' + path.sep) : str).slice(0, -1);
  8. };