Repository
Current version released
4 years ago
deno-username
Get the username of the current user
This module is meant for informational purposes and not for secure identification.
Requires the --allow-env
and --allow-run
flags.
Usage
import username from "https://deno.land/x/username/mod.ts";
await username();
// ---> 'justjavac'
API
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.
username()
Returns a Promise<string | undefined>
with the username.
Thanks
Heavily inspired by sindresorhus/usernameh.