untildify
Advanced tools
Comparing version 3.0.3 to 4.0.0
11
index.js
'use strict'; | ||
const os = require('os'); | ||
const home = require('os').homedir(); | ||
const homeDirectory = os.homedir(); | ||
module.exports = str => { | ||
if (typeof str !== 'string') { | ||
throw new TypeError(`Expected a string, got ${typeof str}`); | ||
module.exports = pathWithTilde => { | ||
if (typeof pathWithTilde !== 'string') { | ||
throw new TypeError(`Expected a string, got ${typeof pathWithTilde}`); | ||
} | ||
return home ? str.replace(/^~(?=$|\/|\\)/, home) : str; | ||
return homeDirectory ? pathWithTilde.replace(/^~(?=$|\/|\\)/, homeDirectory) : pathWithTilde; | ||
}; |
{ | ||
"name": "untildify", | ||
"version": "3.0.3", | ||
"description": "Convert a tilde path to an absolute path: ~/dev => /Users/sindresorhus/dev", | ||
"license": "MIT", | ||
"repository": "sindresorhus/untildify", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"contributors": [ | ||
"silverwind <me@silverwind.io> (https://silverwind.io)" | ||
], | ||
"engines": { | ||
"node": ">=4" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"files": [ | ||
"index.js" | ||
], | ||
"keywords": [ | ||
"tilde", | ||
"expansion", | ||
"expand", | ||
"untildify", | ||
"path", | ||
"home", | ||
"dir", | ||
"directory", | ||
"user", | ||
"shell", | ||
"bash" | ||
], | ||
"devDependencies": { | ||
"ava": "*", | ||
"xo": "*" | ||
}, | ||
"xo": { | ||
"esnext": true | ||
} | ||
"name": "untildify", | ||
"version": "4.0.0", | ||
"description": "Convert a tilde path to an absolute path: `~/dev` → `/Users/sindresorhus/dev`", | ||
"license": "MIT", | ||
"repository": "sindresorhus/untildify", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"contributors": [ | ||
"silverwind <me@silverwind.io> (https://silverwind.io)" | ||
], | ||
"engines": { | ||
"node": ">=8" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava && tsd" | ||
}, | ||
"files": [ | ||
"index.js", | ||
"index.d.ts" | ||
], | ||
"keywords": [ | ||
"tilde", | ||
"expansion", | ||
"expand", | ||
"untildify", | ||
"path", | ||
"home", | ||
"directory", | ||
"user", | ||
"shell", | ||
"bash" | ||
], | ||
"devDependencies": { | ||
"ava": "^1.4.1", | ||
"rewire": "^4.0.1", | ||
"tsd": "^0.7.2", | ||
"xo": "^0.24.0" | ||
} | ||
} |
# untildify [![Build Status](https://travis-ci.org/sindresorhus/untildify.svg?branch=master)](https://travis-ci.org/sindresorhus/untildify) | ||
> Convert a tilde path to an absolute path: `~/dev` => `/Users/sindresorhus/dev` | ||
> Convert a tilde path to an absolute path: `~/dev` → `/Users/sindresorhus/dev` | ||
@@ -9,3 +9,3 @@ | ||
``` | ||
$ npm install --save untildify | ||
$ npm install untildify | ||
``` | ||
@@ -12,0 +12,0 @@ |
Sorry, the diff of this file is not supported yet
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
3013
5
20
0
4