Expands the ~ home directory in a path
Path strings that use the
~\ at the front of the string will be expanded to use the home directory of the user. The home directory is dependent on the architecture. For Linux/OSX the environment variable
HOME is used. On the Windows operating system it uses
This module uses typescript and has a type definition file supplied with the package. It will also accept a
This module was inspired by the expand-home-dir package.
This module uses yarn to manage dependencies and run scripts for development.
To install as an application dependency:
$ yarn add --dev util.home
To build the app and run all tests:
$ yarn run all
let expand = require('util.home').expandHomeDirectory; // With USERPROFILE = 'C:\Users\foo' let dir = expand('~/Documents'); console.log(dir); // dir = 'C:\Users\foo\Documents'
let expand = require('util.home').expandHomeDirectory; // With HOME = '/home/foo`' let dir = expand('~/documents'); console.log(dir); // dir = '/home/foo/documents'