Skip to content

Commit

Permalink
cleanup #4
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Sep 18, 2015
1 parent 58a3a2c commit 6f207fd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 2 additions & 4 deletions index.js
Expand Up @@ -4,8 +4,6 @@ var osHomedir = require('os-homedir');
var home = osHomedir();

module.exports = function (str) {
str += path.sep;
str = str.replace(home + path.sep, '~' + path.sep);
str = str.slice(0, -1);
return str;
str = path.resolve(str) + path.sep;
return str.replace(home + path.sep, '~' + path.sep).slice(0, -1);
};
6 changes: 3 additions & 3 deletions test.js
Expand Up @@ -5,21 +5,21 @@ var path = require('path');
var osHomedir = require('os-homedir');
var home = osHomedir();

test(function (t) {
test('tildify home', function (t) {
var fixture = home;
t.assert(tildify(fixture) === '~');
t.end();
});

test(function (t) {
test('tildify path', function (t) {
var fixture = path.resolve(home, 'tildify');
t.assert(tildify(fixture)[0] === '~');
t.assert(/tildify$/.test(tildify(fixture)));
t.assert(tildify(fixture) !== fixture);
t.end();
});

test(function (t) {
test('ensure only a fully matching path is replaced', function (t) {
var fixture = path.resolve(home + 'foo', 'tildify');
t.assert(tildify(fixture) === fixture);
t.end();
Expand Down

0 comments on commit 6f207fd

Please sign in to comment.