@fujia/user-home

Obtain the user home directory and fallback to the system temp directory if don't exist.

Usage no npm install needed!

<script type="module">
  import fujiaUserHome from 'https://cdn.skypack.dev/@fujia/user-home';
</script>

README

hammer logo

@fujia/user-home

Obtain the user home directory and fallback to the system temp directory if don't exist.

English | 简体中文

Installation

npm i @fujia/user-home

# or use yarn
yarn add @fujia/user-home

Usage

You can import the generated bundle to use the whole library generated by this starter:

import userHome from '@fujia/user-home'

console.log(await userHome()); // => '/Users/sunny'

// And if there is no home directory:
console.log(await userHome()); // => undefined, and log info: 'Doesn\'t exist home directory for current login user.'

// also, you can get the temp directory by pass true param
console.log(await userHome(true)); // => something look like(mac): /var/folders/70/x0nk_t0s2m93xbzq4x7px0t40000gn/T