Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 22 days 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 (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-09-05T16:48:43.000Z (about 4 years ago)
- Last Synced: 2024-10-03T11:41:42.763Z (about 1 month ago)
- Topics: deno, deno-mod, deno-module, deno-modules
- Language: TypeScript
- Homepage:
- Size: 13.7 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# deno-username
[![tag](https://img.shields.io/github/release/justjavac/deno-username)](https://github.com/justjavac/deno-username/releases)
[![Build Status](https://github.com/justjavac/deno-username/workflows/ci/badge.svg?branch=master)](https://github.com/justjavac/deno-username/actions)
[![license](https://img.shields.io/github/license/justjavac/deno-username)](https://github.com/justjavac/deno-username/blob/master/LICENSE)
[![](https://img.shields.io/badge/deno-v1.0.0-green.svg)](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).