pax_global_header00006660000000000000000000000064127031236720014515gustar00rootroot0000000000000052 comment=c323a7ebf1098dfbf3e333a93c3f0c51c6ca48e0 tildify-1.2.0/000077500000000000000000000000001270312367200131615ustar00rootroot00000000000000tildify-1.2.0/.editorconfig000066400000000000000000000002761270312367200156430ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [{package.json,*.yml}] indent_style = space indent_size = 2 tildify-1.2.0/.gitattributes000066400000000000000000000000141270312367200160470ustar00rootroot00000000000000* text=auto tildify-1.2.0/.gitignore000066400000000000000000000000151270312367200151450ustar00rootroot00000000000000node_modules tildify-1.2.0/.travis.yml000066400000000000000000000001151270312367200152670ustar00rootroot00000000000000sudo: false language: node_js node_js: - '5' - '4' - '0.12' - '0.10' tildify-1.2.0/index.js000066400000000000000000000004331270312367200146260ustar00rootroot00000000000000'use strict'; var path = require('path'); var osHomedir = require('os-homedir'); var home = osHomedir(); module.exports = function (str) { str = path.normalize(str) + path.sep; return (str.indexOf(home) === 0 ? str.replace(home + path.sep, '~' + path.sep) : str).slice(0, -1); }; tildify-1.2.0/license000066400000000000000000000021371270312367200145310ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) Sindre Sorhus (sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. tildify-1.2.0/package.json000066400000000000000000000013261270312367200154510ustar00rootroot00000000000000{ "name": "tildify", "version": "1.2.0", "description": "Convert an absolute path to a tilde path: `/Users/sindresorhus/dev` → `~/dev`", "license": "MIT", "repository": "sindresorhus/tildify", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, "engines": { "node": ">=0.10.0" }, "scripts": { "test": "xo && ava" }, "files": [ "index.js" ], "keywords": [ "unexpand", "homedir", "tilde", "tildify", "collapse", "path", "home", "dir", "directory", "user", "expand" ], "dependencies": { "os-homedir": "^1.0.0" }, "devDependencies": { "ava": "*", "xo": "*" } } tildify-1.2.0/readme.md000066400000000000000000000010211270312367200147320ustar00rootroot00000000000000# tildify [![Build Status](https://travis-ci.org/sindresorhus/tildify.svg?branch=master)](https://travis-ci.org/sindresorhus/tildify) > Convert an absolute path to a tilde path: `/Users/sindresorhus/dev` → `~/dev` ## Install ``` $ npm install --save tildify ``` ## Usage ```js const tildify = require('tildify'); tildify('/Users/sindresorhus/dev'); //=> '~/dev' ``` ## Related See [untildify](https://github.com/sindresorhus/untildify) for the inverse. ## License MIT © [Sindre Sorhus](https://sindresorhus.com) tildify-1.2.0/test.js000066400000000000000000000014521270312367200145000ustar00rootroot00000000000000'use strict'; const path = require('path'); const test = require('ava'); const osHomedir = require('os-homedir'); const m = require('./'); const home = osHomedir(); test('tildify home', t => { const fixture = home; t.is(m(fixture), '~'); }); test('tildify path', t => { const fixture = path.resolve(home, 'tildify'); t.is(m(fixture)[0], '~'); t.true(/tildify$/.test(m(fixture))); t.not(m(fixture), fixture); }); test('ensure only a fully matching path is replaced', t => { const fixture = path.resolve(`${home}foo`, 'tildify'); t.is(m(fixture), fixture); }); test('ignore relative paths', t => { const fixture = 'tildify'; t.is(m(fixture), fixture); }); test('only tildify when home is at the start of a path', t => { const fixture = path.join('tildify', home); t.is(m(fixture), fixture); });