tildify
Advanced tools
Comparing version 0.2.0 to 1.0.0
10
index.js
'use strict'; | ||
var userHome = require('user-home'); | ||
module.exports = function (str) { | ||
var dir = process.env.HOME; | ||
if (process.platform === 'win32') { | ||
dir = dir || process.env.USERPROFILE || process.env.HOMEDRIVE + process.env.HOMEPATH; | ||
} | ||
return str.replace(dir, '~'); | ||
return str.replace(userHome, '~'); | ||
}; |
{ | ||
"name": "tildify", | ||
"version": "0.2.0", | ||
"description": "Convert an absolute path to tilde path: /Users/sindresorhus/dev => ~/dev", | ||
"version": "1.0.0", | ||
"description": "Convert an absolute path to a tilde path: /Users/sindresorhus/dev => ~/dev", | ||
"license": "MIT", | ||
@@ -16,3 +16,3 @@ "repository": "sindresorhus/tildify", | ||
"scripts": { | ||
"test": "mocha" | ||
"test": "node test.js" | ||
}, | ||
@@ -24,10 +24,17 @@ "files": [ | ||
"tilde", | ||
"tildify", | ||
"path", | ||
"home", | ||
"dir", | ||
"directory" | ||
"directory", | ||
"user", | ||
"expand", | ||
"unexpand" | ||
], | ||
"dependencies": { | ||
"user-home": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"mocha": "*" | ||
"ava": "0.0.3" | ||
} | ||
} |
# tildify [![Build Status](https://travis-ci.org/sindresorhus/tildify.svg?branch=master)](https://travis-ci.org/sindresorhus/tildify) | ||
> Convert an absolute path to tilde path: `/Users/sindresorhus/dev` => `~/dev` | ||
> Convert an absolute path to a tilde path: `/Users/sindresorhus/dev` => `~/dev` | ||
@@ -8,3 +8,3 @@ | ||
```bash | ||
```sh | ||
$ npm install --save tildify | ||
@@ -17,3 +17,3 @@ ``` | ||
```js | ||
var tildify = require('tildify'); | ||
var tildify = require('tildify'); | ||
@@ -25,4 +25,9 @@ tildify('/Users/sindresorhus/dev'); | ||
## Related | ||
See [untildify](https://github.com/sindresorhus/untildify) for the inverse. | ||
## License | ||
[MIT](http://opensource.org/licenses/MIT) © [Sindre Sorhus](http://sindresorhus.com) | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) |
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
Trivial Package
Supply chain riskPackages less than 10 lines of code are easily copied into your own project and may not warrant the additional supply chain risk of an external dependency.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1338
0
31
1
5
+ Addeduser-home@^1.0.0
+ Addeduser-home@1.1.1(transitive)