Skip to content

Commit

Permalink
Merge pull request #5 from JerryCauser/feature/cli
Browse files Browse the repository at this point in the history
Feature/cli
  • Loading branch information
JerryCauser committed Aug 28, 2022
2 parents eece171 + 0dbc093 commit 2c843c3
Show file tree
Hide file tree
Showing 12 changed files with 596 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .husky/post-commit
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
npm run build

git add cjs/index.js
git commit -a -m "build: build cjs"
git status | grep modified | grep 'cjs/index.js' && git commit -a -m "build: build cjs"

9 changes: 0 additions & 9 deletions .npmignore

This file was deleted.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
[![tests](https://img.shields.io/github/workflow/status/JerryCauser/tcp-exists/tests?label=tests&logo=github)](https://github.com/JerryCauser/tcp-exists/actions/workflows/tests.yml)
[![LGTM Grade](https://img.shields.io/lgtm/grade/javascript/github/JerryCauser/tcp-exists)](https://lgtm.com/projects/g/JerryCauser/tcp-exists)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![node-current](https://img.shields.io/node/v/tcp-exists)](https://nodejs.org)
[![GitHub](https://img.shields.io/github/license/JerryCauser/tcp-exists)](https://github.com/JerryCauser/tcp-exists/blob/master/LICENSE)

Check if some tcp endpoint (or many) exists. Can be used as a port scanner
Expand Down
23 changes: 23 additions & 0 deletions bin/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env node

import events from 'node:events'
import { cmd } from '../src/cli.js'

const ac = new AbortController()
events.setMaxListeners(0, ac.signal)

cmd(process.argv.slice(2), ac)
.then(() => {
process.exit(0)
})
.catch((error) => {
console.error(error)
process.exit(1)
})

process.on('exit', () => ac.abort())
process.on('SIGINT', () => ac.abort())
process.on('SIGUSR1', () => ac.abort())
process.on('SIGUSR2', () => ac.abort())
process.on('uncaughtException', () => ac.abort())
process.on('SIGTERM', () => ac.abort())
6 changes: 4 additions & 2 deletions cjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ async function tcpExistsChunk(endpoints, options) {
var chunk_default = tcpExistsChunk;

// src/many.js
var DEFAULT_CHUNK_SIZE = 1400;
var DEFAULT_TIMEOUT = 160;
async function* tcpExistsMany(endpoints, options) {
const {
chunkSize = 1400,
timeout = 160,
chunkSize = DEFAULT_CHUNK_SIZE,
timeout = DEFAULT_TIMEOUT,
returnOnlyExisted = true,
signal
} = options || {};
Expand Down
16 changes: 15 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
"version": "1.4.6",
"description": "Small and fast functions to check if some tcp endpoint exists",
"type": "module",
"bin": {
"tcp-exists": "./bin/index.js"
},
"main": "cjs/index.js",
"module": "index.js",
"exports": {
Expand All @@ -15,7 +18,7 @@
"node": ">=16.0.0"
},
"scripts": {
"build": "esbuild index.js --bundle --platform=node --target=node16 --outfile='./cjs/index.js'",
"build": "esbuild index.js --bundle --platform=node --format=cjs --target=node16 --outfile='./cjs/index.js'",
"release:patch": "standard-version --release-as patch",
"release:minor": "standard-version --release-as minor",
"release:major": "standard-version --release-as major",
Expand Down Expand Up @@ -65,5 +68,16 @@
"cjs/index.js",
"cjs/constants.js",
"types"
],
"files": [
"/bin/index.js",
"/cjs/index.js",
"/cjs/package.json",
"/src",
"/types",
"index.js",
"LICENSE",
"CHANGELOG.md",
"README.md"
]
}
Loading

0 comments on commit 2c843c3

Please sign in to comment.