Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tzachbon/ensure-port
Makes sure you get an available port
https://github.com/tzachbon/ensure-port
e2e e2e-testing get-port ipc port server web
Last synced: 2 months ago
JSON representation
Makes sure you get an available port
- Host: GitHub
- URL: https://github.com/tzachbon/ensure-port
- Owner: tzachbon
- License: mit
- Created: 2022-05-01T08:13:57.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-04-27T10:10:09.000Z (9 months ago)
- Last Synced: 2024-04-28T09:46:33.838Z (9 months ago)
- Topics: e2e, e2e-testing, get-port, ipc, port, server, web
- Language: TypeScript
- Homepage:
- Size: 502 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Ensure Port
[![Build Status](https://github.com/tzachbon/ensure-port/workflows/tests/badge.svg)](https://github.com/tzachbon/ensure-port/actions)
Makes sure you get an available port.
## Installation
```bash
npm i ensure-port
``````bash
yarn add ensure-port
```## Usage
```ts
import { Ports } from 'ensure-port';const ports = new Ports({
startPort: 8000,
endPort: 9000,
});const port = await ports.ensure(); // This would be a random port between 8000 and 9000 that is not used (validated against file-system and http server)
// When you finish - remove watcher
await ports.dispose();
```## How does it work?
It saves inside your `node_modules` a directory that contain all the ports that are in use.
This is why it works in parallel.## License
[MIT](./LICENSE)
## Contributing
Feel free to fork and create pull requests!