GithubHelp home page GithubHelp logo

node-tool-utils's Introduction

node-tool-utils

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Node Cross-Platform Tool Library

Featues

npm install node-tool-utils --save

Usage

const tool = require('node-tool-utils');

Get Local IP Address

const ip = tool.getIP();

Get Local Host

const host = tool.getHost(7001);
// http://100.10.196.1:7001

Kill the occupied port

tool.kill(7001);
tool.kill([7001,7002]);

Check port is available

// return true or false
const isUsed = tool.checkPortUsed(7001);

Get an available port

When 7001 is occupied, it will automatically detect whether 7002 is occupied. If it is not occupied, it will return. Otherwise, it will continue to increment detection. The default check is 10 times.

const port = tool.getPort(7001);

Delete File

const dir = path.join(__dirname, 'dist/index.html');
tool.deleteFile(dir);

Delete Dir

const dir = path.join(__dirname, 'dist');
tool.rm(dir);

Open Browser Or Window

Open the Window or Finder or Browser of the specified path

tool.open('.'); // open Window or Finder
tool.openBrowser(); // open Browser

Start Web Http Server

Default check HTML file as homepage

const dist = path.join(__dirname, 'dist');
tool.httpserver({ port: 8088, dist },() => {});

License

MIT

node-tool-utils's People

Contributors

hubcarl avatar d3m0n-r00t avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.