# docker-exec-websocket-client

> ## Purpose Client for [docker-exec-websocket-server](https://github.com/taskcluster/docker-exec-websocket-server).

Latest version **3.0.0** (published 2022-02-07) · MPL-2.0 license · 0 weekly downloads

## Install

```sh
npm install docker-exec-websocket-client
pnpm add docker-exec-websocket-client
yarn add docker-exec-websocket-client
bun add docker-exec-websocket-client
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2022-02-07 |
| First published | 2020-09-21 |
| Weekly downloads | 0 |
| License | MPL-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >12.0 |
| Dependencies | 3 |
| Unpacked size | 32.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Maintainers | jwhitlock, bsieber, pmoore, taskcluster-bot, bstack |

## Links

- npm: https://www.npmjs.com/package/docker-exec-websocket-client
- Repository: https://github.com/taskcluster/docker-exec-websocket-client
- Issues: https://github.com/taskcluster/docker-exec-websocket-client/issues
- npm.io page: https://npm.io/package/docker-exec-websocket-client

## Dependencies (3)

- [ws](https://npm.io/package/ws.md) ^8.4.2
- [debug](https://npm.io/package/debug.md) ^4.1.1
- [through2](https://npm.io/package/through2.md) ^4.0.2

## Recent versions

- 3.0.0 (latest) — 2022-02-07
- 1.4.0 — 2020-09-21

## README

# docker-exec-websocket-client

## Purpose
Client for [docker-exec-websocket-server](https://github.com/taskcluster/docker-exec-websocket-server).

## Usage
Client:

```js
var DockerClient = require('../lib/client.js');
var client = new DockerClient({
  url: 'ws://localhost:8081/a' //whole url of websocket, preface with wss if secure
  tty: 'true', //Whether or not we expect VT100 style output, also enables exit codes
  command: '/bin/bash', //Command to be run, can be an array with options such as ['cat', '-E']
  wsopts: {}, //Pass in websocket options for the underlying websocket
});
await client.execute();
process.stdin.pipe(client.stdin);
client.stdout.pipe(process.stdout);
client.stderr.pipe(process.stderr);
client.on('exit', (exitCode) => {
  //exitCode is a number between 0 and 255
  process.exit(exitCode);
});
```
There are also other client events:
* `open` signifies the opening of the websocket
* `pause` and `resume` signify when the server has paused/resumed sending data
* `shutdown` signifies the server was shut down
* `error` signifies that some sort of internal error occured, and may carry a utf-8 payload

## Testing

Ensure Docker is installed.

To test locally:

* Run ``yarn install`` to install the dependencies, including developer dependencies
* Run ``yarn test``
* You can pass environment variables and commands to mocha as well, such as ``DEBUG=* yarn test -f 'docker exec wc'``

To test with ``docker-compose``, similar to CI:

* Run ``docker-compose build --build-arg NODE_VERSION=16-bullseye``, or change to the desired
  [Node.js image tag](https://hub.docker.com/_/node/)
* Run ``docker-compose run --rm test``
* Repeat ``docker-compose build ...`` when the code changes or you want to try a different Node.js image.

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