Skip to content

Commit

Permalink
chore: finish readme
Browse files Browse the repository at this point in the history
  • Loading branch information
dmZhan committed May 28, 2024
1 parent 70e1986 commit deef519
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 27 deletions.
166 changes: 140 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,149 @@
# release-port
<div align="center">
<img src="./logo.png" alt="Logo" width="500px">
</div>
<h1 align="center">release-port</h1>
<div align="center">
<strong>Kill process running on given port</strong>
</div>
<br>
<div align="center">
<a href="https://npmjs.org/package/release-port">
<img src="https://img.shields.io/npm/v/release-port.svg?style=flat-square" alt="Package version" />
</a>
<a href="https://npmjs.org/package/release-port">
<img src="https://img.shields.io/npm/dm/release-port.svg?style=flat-square" alt="Downloads" />
</a>
<a href="http://makeapullrequest.com">
<img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square" alt="PRs" />
</a>
</div>
<br>

[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![bundle][bundle-src]][bundle-href]
[![JSDocs][jsdocs-src]][jsdocs-href]
[![License][license-src]][license-href]
> **Note**:
> Forked from [`kill-port`](https://www.npmjs.com/package/kill-port)
_description_
## Changes in this fork

> **Note**:
> Replace `release-port`, `_description_` and `dmZhan` globally to use this template.
- no dependencies
- add sync function to kill port
- typescript
- viteset

## Usage

```js
const http = require('node:http')
const { release, releaseSync } = require('release-port')
const port = 8080

const server = http.createServer((req, res) => {
res.writeHead(200, {
'Content-Type': 'text/plain'
})

res.end('Hi!')
})

server.listen(port, () => {
setTimeout(() => {
// Currently you can kill ports running on TCP or UDP protocols
release(port, 'tcp')
.then(console.log)
.catch(console.log)

// or sync function
const { out, err, error } = releaseSync(port, 'tcp')
}, 1000)
})
```

## API

### release, releaseSync

```js
release(port, method)
releaseSync(port, method)
```

releaseSync is release's sync function.

#### Options

##### port

- Required: `true`
- Type: `string | number`

process port

##### method

## Sponsors
- Required: `false`
- Type: `'udp' | 'tcp'`
- Default: `'tcp'`

<p align="center">
No One
</p>
process type

### execa, execaSync

```js
execa(command)
execaSync(command)
```

#### Options

##### command

- Required: `true`
- Type: `string`

command to execute in shell.

## CLI

You can use `release-port` as a global package.

Install the package globally:

```sh
$ npm install --global release-port
# OR
$ yarn global add release-port
```

Then:

```sh
$ release-port --port 8080
# OR
$ release-port 9000
# OR you can use UDP
$ release-port 9000 --method udp
```

You can also kill multiple ports:

```sh
$ release-port --port 8080,5000,3000
# OR
$ release-port 9000 3000 5000
```

You can also use [npx](https://nodejs.dev/learn/the-npx-nodejs-package-runner) to `release-port` without installing:

```sh
# Kill a single port
$ npx release-port --port 8080
$ npx release-port 8080
# Use UDP
$ npx release-port 9000 --method udp
# Kill multiple ports
$ npx release-port --port 8080,5000,3000
$ npx release-port 9000 3000 5000
```

## License

[MIT](./LICENSE) License © 2023-PRESENT [dmZhan](https://github.com/dmZhan)

<!-- Badges -->

[npm-version-src]: https://img.shields.io/npm/v/release-port?style=flat&colorA=080f12&colorB=1fa669
[npm-version-href]: https://npmjs.com/package/release-port
[npm-downloads-src]: https://img.shields.io/npm/dm/release-port?style=flat&colorA=080f12&colorB=1fa669
[npm-downloads-href]: https://npmjs.com/package/release-port
[bundle-src]: https://img.shields.io/bundlephobia/minzip/release-port?style=flat&colorA=080f12&colorB=1fa669&label=minzip
[bundle-href]: https://bundlephobia.com/result?p=release-port
[license-src]: https://img.shields.io/github/license/dm/release-port.svg?style=flat&colorA=080f12&colorB=1fa669
[license-href]: https://github.com/dmZhan/release-port/blob/main/LICENSE
[jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=1fa669
[jsdocs-href]: https://www.jsdocs.io/package/release-port
1 change: 0 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export default dmzj(
},
{
rules: {
'no-console': 'error',
},
},
)
Binary file added logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit deef519

Please sign in to comment.