Comparing version 0.0.5 to 0.0.6
51
index.js
@@ -1,39 +0,30 @@ | ||
'use strict'; | ||
require('native-promise-only'); | ||
var exec = require('child_process').exec; | ||
const util = require('util'); | ||
const exec = util.promisify(require('child_process').exec); | ||
function command(port) { | ||
var win = { | ||
exe: '\\windows\\system32\\netstat.exe', | ||
arg: ['-a -n -o ^| findstr :' + port], | ||
cmd: '\\windows\\system32\\netstat.exe -a -n -o | findstr.exe :' + port | ||
}; | ||
const win = { | ||
exe: '\\windows\\system32\\netstat.exe', | ||
arg: [`-a -n -o ^| findstr :${port}`], | ||
cmd: `\\windows\\system32\\netstat.exe -a -n -o | findstr.exe :${port}`, | ||
}; | ||
var dar = { | ||
exe: 'lsof', | ||
arg: ['-i', ':' + port], | ||
cmd: 'lsof -i :' + port | ||
}; | ||
const dar = { | ||
exe: 'lsof', | ||
arg: ['-i', `:${port}`], | ||
cmd: `lsof -i :${port}`, | ||
}; | ||
return process.platform === 'win32' ? win : dar; | ||
return process.platform === 'win32' ? win : dar; | ||
} | ||
module.exports = function (port, opts) { | ||
if (typeof port !== 'number') { | ||
throw new TypeError('Expected a port number'); | ||
} | ||
function netstats(port) { | ||
if (typeof port !== 'number') { | ||
throw new TypeError('Expected a port number'); | ||
} | ||
opts = opts || {}; | ||
const cmd = command(port); | ||
return new Promise(function (resolve, reject) { | ||
var cmd = command(port); | ||
return exec(cmd.cmd).then(({ stdout }) => Promise.resolve(stdout.split('\n'))).catch(err => Promise.reject(err)); | ||
} | ||
exec(cmd.cmd, function (err, stdout, stderr) { | ||
var _err = err || stderr; | ||
if (_err) { | ||
reject(_err); | ||
} | ||
resolve(stdout.split('\n')); | ||
}); | ||
}); | ||
}; | ||
module.exports = netstats; |
{ | ||
"name": "netstats", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Get the netstat activity on a given port.", | ||
@@ -10,9 +10,9 @@ "license": "MIT", | ||
"email": "wuergler@gmail.com", | ||
"url": "numetriclabs.com" | ||
"url": "https://github.com/radiovisual" | ||
}, | ||
"engines": { | ||
"node": ">=0.10.0" | ||
"node": ">=8" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava --verbose" | ||
"test": "eslint index.js test.js && jest" | ||
}, | ||
@@ -32,19 +32,14 @@ "files": [ | ||
], | ||
"dependencies": { | ||
"native-promise-only": "^0.8.1" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"ava": "^0.8.0", | ||
"express": "^4.13.4", | ||
"selective-whitespace": "^1.0.0", | ||
"xo": "^0.12.1" | ||
}, | ||
"ava": { | ||
"verbose": true | ||
}, | ||
"xo": { | ||
"rules": { | ||
"linebreak-style": 0 | ||
} | ||
"eslint": "^5.3.0", | ||
"eslint-config-airbnb": "^17.1.0", | ||
"eslint-plugin-import": "^2.17.3", | ||
"eslint-plugin-jest": "^22.6.4", | ||
"eslint-plugin-jsx-a11y": "^6.2.1", | ||
"eslint-plugin-react": "^7.13.0", | ||
"express": "^4.17.1", | ||
"jest": "^24.8.0", | ||
"selective-whitespace": "^1.0.0" | ||
} | ||
} |
@@ -1,8 +0,5 @@ | ||
# netstats | ||
# netstats [![Build Status](https://travis-ci.org/radiovisual/netstats.svg?branch=master)](https://travis-ci.org/radiovisual/netstats) | ||
> Get the netstat activity on a given port. | ||
[![Build Status](https://travis-ci.org/radiovisual/netstats.svg?branch=master)](https://travis-ci.org/radiovisual/netstats) | ||
## Install | ||
@@ -59,3 +56,3 @@ | ||
Type: `number` | ||
Type: `number`<br/> | ||
*Required* | ||
@@ -67,2 +64,2 @@ | ||
MIT © [Michael Wuergler](http://numetriclabs.com) | ||
MIT © [Michael Wuergler](https://github.com/radiovisual) |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4584
0
9
23
64
- Removednative-promise-only@^0.8.1
- Removednative-promise-only@0.8.1(transitive)