diff --git a/snippets/untildify.md b/snippets/untildify.md new file mode 100644 index 000000000..67e51efe8 --- /dev/null +++ b/snippets/untildify.md @@ -0,0 +1,13 @@ +### untildify + +Converts a tilde path to an absolute path. + +Use `String.replace()` with a regular expression and `OS.homedir()` to replace the `~` in the start of the path with the home directory. + +```js +const untildify = str => str.replace(/^~($|\/|\\)/, `${require('os').homedir()}$1`); +``` + +```js +untildify('~/node') // '/Users/aUser/node' +``` diff --git a/tag_database b/tag_database index 64503984d..e66052213 100644 --- a/tag_database +++ b/tag_database @@ -161,6 +161,7 @@ truncateString:string truthCheckCollection:object unescapeHTML:string union:array +untildify:node UUIDGeneratorBrowser:browser UUIDGeneratorNode:node validateNumber:utility