Comparing version 1.0.0 to 2.0.0
39
index.js
'use strict'; | ||
var path = require('path'); | ||
var childProcess = require('child_process'); | ||
var tasklist = require('tasklist'); | ||
var parseColumns = require('parse-columns'); | ||
@@ -15,3 +17,4 @@ function win(cb) { | ||
pid: el.pid, | ||
name: el.imageName | ||
name: el.imageName, | ||
cmd: el.imageName | ||
}; | ||
@@ -24,11 +27,4 @@ }); | ||
function def(opts, cb) { | ||
if (typeof opts !== 'object') { | ||
cb = opts; | ||
opts = {}; | ||
} | ||
var columns = 'pid,' + (opts.args ? 'args' : 'comm'); | ||
childProcess.execFile('ps', ['axo', columns], function (err, stdout) { | ||
function def(cb) { | ||
childProcess.execFile('ps', ['axo', 'pid,comm,args'], function (err, stdout) { | ||
if (err) { | ||
@@ -39,8 +35,19 @@ cb(err); | ||
var ret = stdout.trim().split('\n').slice(1).map(function (el) { | ||
var parts = el.trim().split(/\d /); | ||
return { | ||
pid: Number(parts[0]), | ||
name: parts[1] | ||
}; | ||
var ret = parseColumns(stdout, { | ||
headers: [ | ||
'pid', | ||
'name', | ||
'cmd' | ||
], | ||
transform: function (el, header) { | ||
if (header === 'pid') { | ||
return Number(el); | ||
} | ||
if (header === 'name') { | ||
return path.basename(el); | ||
} | ||
return el; | ||
} | ||
}); | ||
@@ -47,0 +54,0 @@ |
{ | ||
"name": "ps-list", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "Get running processes", | ||
@@ -30,2 +30,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"parse-columns": "^1.0.0", | ||
"tasklist": "^1.0.0" | ||
@@ -32,0 +33,0 @@ }, |
@@ -22,28 +22,9 @@ # ps-list [![Build Status](https://travis-ci.org/sindresorhus/ps-list.svg?branch=master)](https://travis-ci.org/sindresorhus/ps-list) [![Build status](https://ci.appveyor.com/api/projects/status/i733mfqw11sja2xf/branch/master?svg=true)](https://ci.appveyor.com/project/sindresorhus/ps-list/branch/master) | ||
console.log(data); | ||
//=> [{pid: 3213, name: 'node'}, ...] | ||
//=> [{pid: 3213, name: 'node', cmd: 'node test.js'}, ...] | ||
}); | ||
psList({args: true}, function (err, data) { | ||
console.log(data); | ||
//=> [{pid: 3213, name: 'node test.js'}, ...] | ||
}); | ||
``` | ||
## API | ||
### psList([options], callback) | ||
#### options | ||
##### args | ||
Type: `boolean` | ||
Default: `false` | ||
Include process startup arguments. Moot on Windows. | ||
## License | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) |
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
47
3300
2
30
+ Addedparse-columns@^1.0.0
+ Addedarray-uniq@1.0.3(transitive)
+ Addedarrify@1.0.1(transitive)
+ Addedclone-regexp@1.0.1(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedexecall@1.0.0(transitive)
+ Addedis-finite@1.1.0(transitive)
+ Addedis-regexp@1.0.0(transitive)
+ Addedis-supported-regexp-flag@1.0.1(transitive)
+ Addednum-sort@1.0.0(transitive)
+ Addednumber-is-nan@1.0.1(transitive)
+ Addedparse-columns@1.3.0(transitive)
+ Addedrepeating@2.0.1(transitive)
+ Addedsplit-at@1.2.0(transitive)