New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

blockaid

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blockaid

Require that a port is listening, not listening, or kill if listening

  • 1.1.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
341
decreased by-23.71%
Maintainers
1
Weekly downloads
 
Created
Source

blockaid

Blockaid is an npm CLI tool (node.js) that allows you to require that a port is listening, or not listening, before taking an action. It also allows you to kill whatever is found listening on a port before taking an action.

Example usage

If you use package.json scripts to start a server, you might have configured something like:

(package.json)

"scripts": {
  "dev": "nodemon server.js"
}

If server.js depends on another service (e.g. a mysql database running on port 3306), you could require that port 3306 is running first, like so:

"scripts": {
  "dev": "blockaid -r mysql:3306 && nodemon server.js"
}

In this example, if port 3306 is not running, then an easy-to-understand error message will be printed with the failure to run server.js:

$ npm run dev
mysql is required, but is not listening on port 3306.

You can also use an environment variable, such as PORT, rather than a concrete port number. Here, we kill an existing listening process on PORT before starting the server:

"scripts": {
  "dev": "PORT=3000 blockaid -k service:PORT && nodemon server.js"
}

The shell return value will be "0" (indicating success) or "1" (indicating failure to meet the requirement specified).

Instructions

>>> blockaid : Require that a port is listening, not listening, or kill whatever is found listening.


  -r, --require-listening PROGRAM_NAME:PORT

    Require that a process is listening at PORT; PROGRAM_NAME is used for error messages


  -x, --require-not-listening PROGRAM_NAME:PORT

    Require that a process is NOT listening at PORT; PROGRAM_NAME is used for error messages


  -k, --kill-if-listening PROGRAM_NAME:PORT

    If a process is listening at PORT, kill it; PROGRAM_NAME is used for console message

Keywords

FAQs

Package last updated on 11 Apr 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc