# node-tool-utils

> node cross-platform tool library

Latest version **1.6.0** (published 2020-01-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-tool-utils
pnpm add node-tool-utils
yarn add node-tool-utils
bun add node-tool-utils
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.6.0 |
| Published | 2020-01-03 |
| First published | 2018-09-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.0.0 |
| Dependencies | 7 |
| Unpacked size | 18.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | hubcarl@126.com |
| Maintainers | hubcarl |
| Keywords | npm, npm package, unit test, eslint, travis, travis-ci, code coverage, changelog |

## Links

- npm: https://www.npmjs.com/package/node-tool-utils
- Repository: https://github.com/hubcarl/node-tool-utils
- Homepage: https://github.com/hubcarl/node-tool-utils#readme
- Issues: https://github.com/hubcarl/node-tool-utils/issues
- npm.io page: https://npm.io/package/node-tool-utils

## Dependencies (7)

- [opn](https://npm.io/package/opn.md) ^5.4.0
- [chalk](https://npm.io/package/chalk.md) ^2.0.1
- [mkdirp](https://npm.io/package/mkdirp.md) ^0.5.1
- [shelljs](https://npm.io/package/shelljs.md) ^0.8.2
- [node-glob](https://npm.io/package/node-glob.md) ^1.2.0
- [node-http-server](https://npm.io/package/node-http-server.md) ^8.1.2
- [cross-port-killer](https://npm.io/package/cross-port-killer.md) ^1.0.1

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@pandacss/eslint-plugin](https://npm.io/package/@pandacss/eslint-plugin.md) — 18.7K weekly downloads

## Recent versions

- 1.6.0 (latest) — 2020-01-03
- 1.5.0 — 2019-10-23
- 1.4.1 — 2019-10-22
- 1.4.0 — 2019-10-21
- 1.3.0 — 2019-09-07
- 1.2.3 — 2019-08-01
- 1.2.2 — 2019-07-05
- 1.2.1 — 2019-03-07
- 1.2.0 — 2019-01-22
- 1.1.1 — 2018-10-10
- 1.1.0 — 2018-09-28
- 1.0.0 — 2018-09-27
- 0.1.0 — 2018-09-27

## README

# node-tool-utils

[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Test coverage][codecov-image]][codecov-url]
[![David deps][david-image]][david-url]
[![Known Vulnerabilities][snyk-image]][snyk-url]
[![npm download][download-image]][download-url]

[npm-image]: https://img.shields.io/npm/v/node-tool-utils.svg?style=flat-square
[npm-url]: https://npmjs.org/package/node-tool-utils
[travis-image]: https://img.shields.io/travis/hubcarl/node-tool-utils.svg?style=flat-square
[travis-url]: https://travis-ci.org/hubcarl/node-tool-utils
[codecov-image]: https://img.shields.io/codecov/c/github/hubcarl/node-tool-utils.svg?style=flat-square
[codecov-url]: https://codecov.io/github/hubcarl/node-tool-utils?branch=master
[david-image]: https://img.shields.io/david/hubcarl/node-tool-utils.svg?style=flat-square
[david-url]: https://david-dm.org/hubcarl/node-tool-utils
[snyk-image]: https://snyk.io/test/npm/node-tool-utils/badge.svg?style=flat-square
[snyk-url]: https://snyk.io/test/npm/node-tool-utils
[download-image]: https://img.shields.io/npm/dm/node-tool-utils.svg?style=flat-square
[download-url]: https://npmjs.org/package/node-tool-utils

Node Cross-Platform Tool Library

## Featues

```bash
npm install node-tool-utils --save
```

## Usage

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

### Get Local IP Address

```js
const ip = tool.getIP();
```

### Get Local Host 

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

### Kill the occupied port

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

### Check port is available

```js
// 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.

```js
const port = tool.getPort(7001);
```

### Delete File

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

### Delete Dir

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

### Open Browser Or Window

Open the Window or Finder or Browser of the specified path

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

### Start Web Http Server

Default check HTML file as homepage

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

## License

[MIT](LICENSE)

---
_Source: https://npm.io/package/node-tool-utils · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
