1.2.1 • Published 6 years ago

ko-port v1.2.1

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

ko-port

make sure get an available port on your server

支持本地安装(Local Installation)

$ npm install ko-port

支持全局安装(Global Installation)

$ npm install ko-port -g

支持API

  • asyncPort(port: number): Promise<any>

识别指定port是否可用,否则递归加1,返回有效port

样例:

var koport = require('ko-port');

koport.asyncPort(3000)
  .then((port) => {
      // 返回有效port
      http.createServer(app).listen(port, function () {
          console.log('listening on port ', port)
      })
  })
  .catch((err) => {
      // 返回err
  });
  • killPort(port: number): Promise<any>

杀死指定的port占用进程

样例:

var koport = require('ko-port');

koport.killPort(3000)
  .then(() => {
      // success
  })
  .catch((err) => {
      // error
  });

如果是全局(Global)安装:

$ koport 3000
1.2.1

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago