-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathindex.d.ts
33 lines (24 loc) · 1018 Bytes
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
Get the username of the current user.
It first tries to get the username from the `SUDO_USER` `LOGNAME` `USER` `LNAME` `USERNAME` environment variables. Then falls back to `$ id -un` on macOS / Linux and `$ whoami` on Windows, in the rare case none of the environment variables are set. The result is cached.
@returns The username.
@example
```
import {username} from 'username';
console.log(await username());
//=> 'sindresorhus'
```
*/
export function username(): Promise<string | undefined>;
/**
Synchronously get the username of the current user.
It first tries to get the username from the `SUDO_USER` `LOGNAME` `USER` `LNAME` `USERNAME` environment variables. Then falls back to `$ id -un` on macOS / Linux and `$ whoami` on Windows, in the rare case none of the environment variables are set. The result is cached.
@returns The username.
@example
```
import {usernameSync} from 'username';
console.log(usernameSync());
//=> 'sindresorhus'
```
*/
export function usernameSync(): string | undefined;