https://github.com/justjavac/deno-username
Get the username of the current user
https://github.com/justjavac/deno-username
deno deno-mod deno-module deno-modules
Last synced: about 1 month ago
JSON representation
Get the username of the current user
- Host: GitHub
- URL: https://github.com/justjavac/deno-username
- Owner: justjavac
- License: mit
- Created: 2019-12-05T14:29:23.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-09-05T16:48:43.000Z (almost 6 years ago)
- Last Synced: 2026-02-21T12:42:29.643Z (4 months ago)
- Topics: deno, deno-mod, deno-module, deno-modules
- Language: TypeScript
- Homepage:
- Size: 13.7 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# deno-username
[](https://github.com/justjavac/deno-username/releases)
[](https://github.com/justjavac/deno-username/actions)
[](https://github.com/justjavac/deno-username/blob/master/LICENSE)
[](https://github.com/denoland/deno)
> 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
```js
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` with the username.
## Thanks
Heavily inspired by [sindresorhus/usernameh](https://github.com/sindresorhus/username).