Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ps-list

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ps-list - npm Package Compare versions

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)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc