# enex

> A minimalist command runner for npm packages, with a focus on developer ergonomics.

Latest version **0.0.6** (published 2023-02-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install enex
pnpm add enex
yarn add enex
bun add enex
```

Provides the command `enex`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2023-02-27 |
| First published | 2022-01-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Evan Purcer |
| Maintainers | evnp |

## Links

- npm: https://www.npmjs.com/package/enex
- Repository: https://github.com/evnp/enex
- Issues: https://github.com/evnp/enex/issues
- npm.io page: https://npm.io/package/enex

## Recent versions

- 0.0.6 (latest) — 2023-02-27
- 0.0.5 — 2022-04-19
- 0.0.4 — 2022-01-15
- 0.0.3 — 2022-01-15
- 0.0.2 — 2022-01-15
- 0.0.1 — 2022-01-15

## README

A minimalist command runner for npm packages, with a focus on developer ergonomics.

```
 ______    __    __    ______    __  __
/\  ___\  /\ `. /\ \  /\  ___\  /\_\_\_\
\ \  ___\ \ \  `. \ \ \ \  ___\ \/_/\_\/_
 \ \_____\ \ \_\ `.\_\ \ \_____\  /\_\/\_\
  \/_____/  \/_/  \/_/  \/_____/  \/_/\/_/  n(pm) execute
```

[![shellcheck](https://github.com/evnp/enex/workflows/shellcheck/badge.svg)](https://github.com/evnp/enex/actions)
[![latest release](https://img.shields.io/github/release/evnp/enex.svg)](https://github.com/evnp/enex/releases/latest)
[![npm package](https://img.shields.io/npm/v/enex.svg)](https://www.npmjs.com/package/enex)
[![license](https://img.shields.io/github/license/evnp/enex.svg?color=blue)](https://github.com/evnp/enex/blob/master/LICENSE.md)

`enex` lets you interact with any NPM package — that is, anything with a `package.json` — in as few keystrokes as you want (or as possible!). It's eminently configurable, but with a default setup of `source $HOME/enex/enex.sh` in your dotfile of choice, it will add these aliases to any shell:

```sh
n <cmd>     ->  npm <cmd> OR npm run <cmd> # enex intelligently adds `run`
                                           # only when necessary, but you
ns <opts>   ->  npm run start <opts>       # may use it if you prefer
nb <opts>   ->  npm run build <opts>
nf <opts>   ->  npm run format <opts>
nt <opts>   ->  npm run test <opts>
ntw <opts>  ->  npm run test -- --watch <opts>

ni <opts>   ->  npm install <opts>
nu <opts>   ->  npm uninstall <opts>
nis <opts>  ->  npm install --save <opts>
nus <opts>  ->  npm uninstall --save <opts>
nid <opts>  ->  npm install --save-dev <opts>
nud <opts>  ->  npm uninstall --save-dev <opts>
```

`enex` is only 60 lines of code (with comments!) — if you're interested in knowing exactly what will be running on your system, peruse it [here](https://github.com/evnp/enex/blob/main/enex.sh). Any project that touts minimalism should strive to be understood completely within a few minutes; this is, and will remain, a goal of `enex`.

Setup
-----
```sh
npm install -g enex
which enex
> /some/path/to/node_modules/.bin/enex.sh

# add to your .bashrc / .zshrc / etc. ->
source "/some/path/to/node_modules/.bin/enex.sh"
```
Or if you prefer, install by checking out the repository manually:
```sh
git clone https://github.com/evnp/enex.git

# add to your .bashrc / .zshrc / etc. ->
source "$HOME/enex/enex.sh"

# or if you didn't check the repository in $HOME directory:
source "/your/path/to/repository/enex/enex.sh"
```
Open a new shell instance and `enex` will have initialized these aliases:
```sh
alias n="enex"  # -> contextually equivalent to `npm ...` or `npm run ...`

alias ns="enex start"      # -> npm start
alias nt="enex test"       # -> npm test; also ntw -> npm run test -- --watch
alias nb="enex build"      # -> npm run build
alias nf="enex format"     # -> npm run format
alias ni="enex install"    # -> npm install
alias nu="enex uninstall"  # -> npm uninstall
# also nis, nid, nus, nud for install/uninstall --save/--save-dev combinations, see above
```
If you'd like to opt out of these default aliases or customize them, use env vars when initializing `enex` to configure:
```sh
# to opt out of `n` alias and simply use the full command `enex`:
ENEX_COMMAND=0 source "$HOME/enex/enex.sh"

# to opt out of enex aliasing altogether:
ENEX_COMMAND=0 ENEX_ALIASES=0 source "$HOME/enex/enex.sh"

# to use the custom command `myencmd` to invoke enex instead of `n`:
ENEX_COMMAND=myencmd source "$HOME/enex/enex.sh"
> alias myencmd="enex"

# to define your own custom set of enex aliases:
ENEX_ALIASES=build,push,deploy source "$HOME/enex/enex.sh"
> alias n="enex"
> alias nb="enex build"
> alias np="enex push"
> alias nd="enex deploy"
# note: this overrides the set of default aliases entirely, so you
#       will need to redefine them explicitly if some are desired
```

By default, if enex does not detect a `package.json` file within the directory it is being invoked from, it will search for one within directories up to 2 levels below, and arbitary levels above, exiting immediately if it reaches your home directory. This allows you to run enex commands from anywhere within a project with this very common directory structure, or similar project structures:
```sh
$HOME/
 └─project/
   ├─backend/
   │ └─dir/
   └─frontend/
     ├─src/
     └─dir/
```
Normally, you'd need to first navigate to the `frontend/` before invoking any `npm` command; enex handles this step invisibly for you in a subshell, so that you remain in the same directory you started in after the operation is complete.

If for any reason you prefer to skip this "auto-find" step, add the following env var to your enex configuration:
```sh
ENEX_FIND=0 source "$HOME/enex/enex.sh"
```

While sorting out configuration, it may be useful to have enex output the complete set of aliases that are generated when a new shell session begins. To do so, add:
```sh
ENEX_VERBOSE=1 source "$HOME/enex/enex.sh"
```

That's it!

License
-------
MIT

---
_Source: https://npm.io/package/enex · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
