update socials section
This commit is contained in:
128
node_modules/pidtree/bin/pidtree.js
generated
vendored
Executable file
128
node_modules/pidtree/bin/pidtree.js
generated
vendored
Executable file
@ -0,0 +1,128 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
var os = require('os');
|
||||
var pidtree = require('..');
|
||||
|
||||
// The method startsWith is not defined on string objects in node 0.10
|
||||
// eslint-disable-next-line no-extend-native
|
||||
String.prototype.startsWith = function(suffix) {
|
||||
return this.substring(0, suffix.length) === suffix;
|
||||
};
|
||||
|
||||
function help() {
|
||||
var help =
|
||||
' Usage\n' +
|
||||
' $ pidtree <ppid>\n' +
|
||||
'\n' +
|
||||
'Options\n' +
|
||||
' --list To print the pids as a list.\n' +
|
||||
'\n' +
|
||||
'Examples\n' +
|
||||
' $ pidtree\n' +
|
||||
' $ pidtree --list\n' +
|
||||
' $ pidtree 1\n' +
|
||||
' $ pidtree 1 --list\n';
|
||||
console.log(help);
|
||||
}
|
||||
|
||||
function list(ppid) {
|
||||
pidtree(ppid === undefined ? -1 : ppid, function(err, list) {
|
||||
if (err) {
|
||||
console.error(err.message);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(list.join(os.EOL));
|
||||
});
|
||||
}
|
||||
|
||||
function tree(ppid) {
|
||||
pidtree(ppid, {advanced: true}, function(err, list) {
|
||||
if (err) {
|
||||
console.error(err.message);
|
||||
return;
|
||||
}
|
||||
|
||||
var parents = {}; // Hash Map of parents
|
||||
var tree = {}; // Adiacency Hash Map
|
||||
while (list.length > 0) {
|
||||
var element = list.pop();
|
||||
if (tree[element.ppid]) {
|
||||
tree[element.ppid].push(element.pid);
|
||||
} else {
|
||||
tree[element.ppid] = [element.pid];
|
||||
}
|
||||
|
||||
if (ppid === -1) {
|
||||
parents[element.pid] = element.ppid;
|
||||
}
|
||||
}
|
||||
|
||||
var roots = [ppid];
|
||||
if (ppid === -1) {
|
||||
// Get all the roots
|
||||
roots = Object.keys(tree).filter(function(node) {
|
||||
return parents[node] === undefined;
|
||||
});
|
||||
}
|
||||
|
||||
roots.forEach(function(root) {
|
||||
print(tree, root);
|
||||
});
|
||||
});
|
||||
|
||||
function print(tree, start) {
|
||||
function printBranch(node, branch) {
|
||||
var isGraphHead = branch.length === 0;
|
||||
var children = tree[node] || [];
|
||||
|
||||
var branchHead = '';
|
||||
if (!isGraphHead) {
|
||||
branchHead = children.length > 0 ? '┬ ' : '─ ';
|
||||
}
|
||||
|
||||
console.log(branch + branchHead + node);
|
||||
|
||||
var baseBranch = branch;
|
||||
if (!isGraphHead) {
|
||||
var isChildOfLastBranch = branch.slice(-2) === '└─';
|
||||
baseBranch = branch.slice(0, -2) + (isChildOfLastBranch ? ' ' : '| ');
|
||||
}
|
||||
|
||||
var nextBranch = baseBranch + '├─';
|
||||
var lastBranch = baseBranch + '└─';
|
||||
children.forEach(function(child, index) {
|
||||
printBranch(
|
||||
child,
|
||||
children.length - 1 === index ? lastBranch : nextBranch
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
printBranch(start, '');
|
||||
}
|
||||
}
|
||||
|
||||
function run() {
|
||||
var flag;
|
||||
var ppid;
|
||||
for (var i = 2; i < process.argv.length; i++) {
|
||||
if (process.argv[i].startsWith('--')) {
|
||||
flag = process.argv[i];
|
||||
} else {
|
||||
ppid = process.argv[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (ppid === undefined) {
|
||||
ppid = -1;
|
||||
}
|
||||
|
||||
if (flag === '--list') list(ppid);
|
||||
else if (flag === undefined) tree(ppid);
|
||||
else help();
|
||||
}
|
||||
|
||||
run();
|
80
node_modules/pidtree/index.d.ts
generated
vendored
Normal file
80
node_modules/pidtree/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
declare namespace PidTree {
|
||||
export interface Options {
|
||||
/**
|
||||
* Include the provided PID in the list. Ignored if -1 is passed as PID.
|
||||
* @default false
|
||||
*/
|
||||
root?: boolean;
|
||||
}
|
||||
|
||||
export interface AdvancedResult {
|
||||
/**
|
||||
* PID of the parent.
|
||||
*/
|
||||
ppid: number;
|
||||
/**
|
||||
* PID
|
||||
*/
|
||||
pid: number;
|
||||
}
|
||||
|
||||
export type Result = number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of children pids of the given pid.
|
||||
* @param pid A PID. If -1 will return all the pids.
|
||||
* @param callback Called when the list is ready.
|
||||
*/
|
||||
declare function pidtree(
|
||||
pid: string | number,
|
||||
callback: (error: Error | undefined, result: PidTree.Result[]) => void
|
||||
): void;
|
||||
|
||||
/**
|
||||
* Get the list of children pids of the given pid.
|
||||
* @param pid A PID. If -1 will return all the pids.
|
||||
* @param options Options object.
|
||||
* @param callback Called when the list is ready.
|
||||
*/
|
||||
declare function pidtree(
|
||||
pid: string | number,
|
||||
options: PidTree.Options,
|
||||
callback: (error: Error | undefined, result: PidTree.Result[]) => void
|
||||
): void;
|
||||
|
||||
/**
|
||||
* Get the list of children pids of the given pid.
|
||||
* @param pid A PID. If -1 will return all the pids.
|
||||
* @param options Options object.
|
||||
* @param callback Called when the list is ready.
|
||||
*/
|
||||
declare function pidtree(
|
||||
pid: string | number,
|
||||
options: PidTree.Options & {advanced: true},
|
||||
callback: (error: Error | undefined, result: PidTree.AdvancedResult[]) => void
|
||||
): void;
|
||||
|
||||
/**
|
||||
* Get the list of children pids of the given pid.
|
||||
* @param pid A PID. If -1 will return all the pids.
|
||||
* @param [options] Optional options object.
|
||||
* @returns A promise containing the list.
|
||||
*/
|
||||
declare function pidtree(
|
||||
pid: string | number,
|
||||
options?: PidTree.Options
|
||||
): Promise<PidTree.Result[]>;
|
||||
|
||||
/**
|
||||
* Get the list of children pids of the given pid.
|
||||
* @param pid A PID. If -1 will return all the pids.
|
||||
* @param options Options object.
|
||||
* @returns A promise containing the list.
|
||||
*/
|
||||
declare function pidtree(
|
||||
pid: string | number,
|
||||
options: PidTree.Options & {advanced: true}
|
||||
): Promise<PidTree.AdvancedResult[]>;
|
||||
|
||||
export = pidtree;
|
49
node_modules/pidtree/index.js
generated
vendored
Normal file
49
node_modules/pidtree/index.js
generated
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
'use strict';
|
||||
|
||||
function pify(fn, arg1, arg2) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
fn(arg1, arg2, function(err, data) {
|
||||
if (err) return reject(err);
|
||||
resolve(data);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Node versions prior to 4.0.0 do not define have `startsWith`.
|
||||
/* istanbul ignore if */
|
||||
if (!String.prototype.startsWith) {
|
||||
// eslint-disable-next-line no-extend-native
|
||||
String.prototype.startsWith = function(suffix) {
|
||||
return this.substring(0, suffix.length) === suffix;
|
||||
};
|
||||
}
|
||||
|
||||
var pidtree = require('./lib/pidtree');
|
||||
|
||||
/**
|
||||
* Get the list of children pids of the given pid.
|
||||
* @public
|
||||
* @param {Number|String} pid A PID. If -1 will return all the pids.
|
||||
* @param {Object} [options] Optional options object.
|
||||
* @param {Boolean} [options.root=false] Include the provided PID in the list.
|
||||
* @param {Boolean} [options.advanced=false] Returns a list of objects in the
|
||||
* format {pid: X, ppid: Y}.
|
||||
* @param {Function} [callback=undefined] Called when the list is ready. If not
|
||||
* provided a promise is returned instead.
|
||||
* @returns {Promise.<Object[]>} Only when the callback is not provided.
|
||||
*/
|
||||
function list(pid, options, callback) {
|
||||
if (typeof options === 'function') {
|
||||
callback = options;
|
||||
options = undefined;
|
||||
}
|
||||
|
||||
if (typeof callback === 'function') {
|
||||
pidtree(pid, options, callback);
|
||||
return;
|
||||
}
|
||||
|
||||
return pify(pidtree, pid, options);
|
||||
}
|
||||
|
||||
module.exports = list;
|
61
node_modules/pidtree/lib/bin.js
generated
vendored
Normal file
61
node_modules/pidtree/lib/bin.js
generated
vendored
Normal file
@ -0,0 +1,61 @@
|
||||
'use strict';
|
||||
|
||||
var spawn = require('child_process').spawn;
|
||||
|
||||
function stripStderr(stderr) {
|
||||
if (!stderr) return;
|
||||
stderr = stderr.trim();
|
||||
// Strip bogus screen size error.
|
||||
// See https://github.com/microsoft/vscode/issues/98590
|
||||
var regex = /your \d+x\d+ screen size is bogus\. expect trouble/gi;
|
||||
stderr = stderr.replace(regex, '');
|
||||
|
||||
return stderr.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawn a binary and read its stdout.
|
||||
* @param {String} cmd The name of the binary to spawn.
|
||||
* @param {String[]} args The arguments for the binary.
|
||||
* @param {Object} [options] Optional option for the spawn function.
|
||||
* @param {Function} done(err, stdout)
|
||||
*/
|
||||
function run(cmd, args, options, done) {
|
||||
if (typeof options === 'function') {
|
||||
done = options;
|
||||
options = undefined;
|
||||
}
|
||||
|
||||
var executed = false;
|
||||
var ch = spawn(cmd, args, options);
|
||||
var stdout = '';
|
||||
var stderr = '';
|
||||
|
||||
ch.stdout.on('data', function(d) {
|
||||
stdout += d.toString();
|
||||
});
|
||||
|
||||
ch.stderr.on('data', function(d) {
|
||||
stderr += d.toString();
|
||||
});
|
||||
|
||||
ch.on('error', function(err) {
|
||||
if (executed) return;
|
||||
executed = true;
|
||||
done(new Error(err));
|
||||
});
|
||||
|
||||
ch.on('close', function(code) {
|
||||
if (executed) return;
|
||||
executed = true;
|
||||
|
||||
stderr = stripStderr(stderr);
|
||||
if (stderr) {
|
||||
return done(new Error(stderr));
|
||||
}
|
||||
|
||||
done(null, stdout, code);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = run;
|
45
node_modules/pidtree/lib/get.js
generated
vendored
Normal file
45
node_modules/pidtree/lib/get.js
generated
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
'use strict';
|
||||
|
||||
var os = require('os');
|
||||
|
||||
var platformToMethod = {
|
||||
darwin: 'ps',
|
||||
sunos: 'ps',
|
||||
freebsd: 'ps',
|
||||
netbsd: 'ps',
|
||||
win: 'wmic',
|
||||
linux: 'ps',
|
||||
aix: 'ps',
|
||||
};
|
||||
|
||||
var methodToRequireFn = {
|
||||
ps: () => require("./ps"),
|
||||
wmic: () => require("./wmic")
|
||||
};
|
||||
|
||||
var platform = os.platform();
|
||||
if (platform.startsWith('win')) {
|
||||
platform = 'win';
|
||||
}
|
||||
|
||||
var method = platformToMethod[platform];
|
||||
|
||||
/**
|
||||
* Gets the list of all the pids of the system.
|
||||
* @param {Function} callback Called when the list is ready.
|
||||
*/
|
||||
function get(callback) {
|
||||
if (method === undefined) {
|
||||
callback(
|
||||
new Error(
|
||||
os.platform() +
|
||||
' is not supported yet, please open an issue (https://github.com/simonepri/pidtree)'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
var list = methodToRequireFn[method]();
|
||||
list(callback);
|
||||
}
|
||||
|
||||
module.exports = get;
|
104
node_modules/pidtree/lib/pidtree.js
generated
vendored
Normal file
104
node_modules/pidtree/lib/pidtree.js
generated
vendored
Normal file
@ -0,0 +1,104 @@
|
||||
'use strict';
|
||||
|
||||
var getAll = require('./get');
|
||||
|
||||
/**
|
||||
* Get the list of children and grandchildren pids of the given PID.
|
||||
* @param {Number|String} PID A PID. If -1 will return all the pids.
|
||||
* @param {Object} [options] Optional options object.
|
||||
* @param {Boolean} [options.root=false] Include the provided PID in the list.
|
||||
* @param {Boolean} [options.advanced=false] Returns a list of objects in the
|
||||
* format {pid: X, ppid: Y}.
|
||||
* @param {Function} callback(err, list) Called when the list is ready.
|
||||
*/
|
||||
function list(PID, options, callback) {
|
||||
if (typeof options === 'function') {
|
||||
callback = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
if (typeof options !== 'object') {
|
||||
options = {};
|
||||
}
|
||||
|
||||
PID = parseInt(PID, 10);
|
||||
if (isNaN(PID) || PID < -1) {
|
||||
callback(new TypeError('The pid provided is invalid'));
|
||||
return;
|
||||
}
|
||||
|
||||
getAll(function(err, list) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
// If the user wants the whole list just return it
|
||||
if (PID === -1) {
|
||||
for (var i = 0; i < list.length; i++) {
|
||||
list[i] = options.advanced
|
||||
? {ppid: list[i][0], pid: list[i][1]}
|
||||
: (list[i] = list[i][1]);
|
||||
}
|
||||
|
||||
callback(null, list);
|
||||
return;
|
||||
}
|
||||
|
||||
var root;
|
||||
for (var l = 0; l < list.length; l++) {
|
||||
if (list[l][1] === PID) {
|
||||
root = options.advanced ? {ppid: list[l][0], pid: PID} : PID;
|
||||
break;
|
||||
}
|
||||
|
||||
if (list[l][0] === PID) {
|
||||
root = options.advanced ? {pid: PID} : PID; // Special pids like 0 on *nix
|
||||
}
|
||||
}
|
||||
|
||||
if (!root) {
|
||||
callback(new Error('No matching pid found'));
|
||||
return;
|
||||
}
|
||||
|
||||
// Build the adiacency Hash Map (pid -> [children of pid])
|
||||
var tree = {};
|
||||
while (list.length > 0) {
|
||||
var element = list.pop();
|
||||
if (tree[element[0]]) {
|
||||
tree[element[0]].push(element[1]);
|
||||
} else {
|
||||
tree[element[0]] = [element[1]];
|
||||
}
|
||||
}
|
||||
|
||||
// Starting by the PID provided by the user, traverse the tree using the
|
||||
// adiacency Hash Map until the whole subtree is visited.
|
||||
// Each pid encountered while visiting is added to the pids array.
|
||||
var idx = 0;
|
||||
var pids = [root];
|
||||
while (idx < pids.length) {
|
||||
var curpid = options.advanced ? pids[idx++].pid : pids[idx++];
|
||||
if (!tree[curpid]) continue;
|
||||
var length = tree[curpid].length;
|
||||
for (var j = 0; j < length; j++) {
|
||||
pids.push(
|
||||
options.advanced
|
||||
? {ppid: curpid, pid: tree[curpid][j]}
|
||||
: tree[curpid][j]
|
||||
);
|
||||
}
|
||||
|
||||
delete tree[curpid];
|
||||
}
|
||||
|
||||
if (!options.root) {
|
||||
pids.shift(); // Remove root
|
||||
}
|
||||
|
||||
callback(null, pids);
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = list;
|
47
node_modules/pidtree/lib/ps.js
generated
vendored
Normal file
47
node_modules/pidtree/lib/ps.js
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
'use strict';
|
||||
|
||||
var os = require('os');
|
||||
var bin = require('./bin');
|
||||
|
||||
/**
|
||||
* Gets the list of all the pids of the system through the ps command.
|
||||
* @param {Function} callback(err, list)
|
||||
*/
|
||||
function ps(callback) {
|
||||
var args = ['-A', '-o', 'ppid,pid'];
|
||||
|
||||
bin('ps', args, function(err, stdout, code) {
|
||||
if (err) return callback(err);
|
||||
if (code !== 0) {
|
||||
return callback(new Error('pidtree ps command exited with code ' + code));
|
||||
}
|
||||
|
||||
// Example of stdout
|
||||
//
|
||||
// PPID PID
|
||||
// 1 430
|
||||
// 430 432
|
||||
// 1 727
|
||||
// 1 7166
|
||||
|
||||
try {
|
||||
stdout = stdout.split(os.EOL);
|
||||
|
||||
var list = [];
|
||||
for (var i = 1; i < stdout.length; i++) {
|
||||
stdout[i] = stdout[i].trim();
|
||||
if (!stdout[i]) continue;
|
||||
stdout[i] = stdout[i].split(/\s+/);
|
||||
stdout[i][0] = parseInt(stdout[i][0], 10); // PPID
|
||||
stdout[i][1] = parseInt(stdout[i][1], 10); // PID
|
||||
list.push(stdout[i]);
|
||||
}
|
||||
|
||||
callback(null, list);
|
||||
} catch (error) {
|
||||
callback(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = ps;
|
49
node_modules/pidtree/lib/wmic.js
generated
vendored
Normal file
49
node_modules/pidtree/lib/wmic.js
generated
vendored
Normal file
@ -0,0 +1,49 @@
|
||||
'use strict';
|
||||
|
||||
var os = require('os');
|
||||
var bin = require('./bin');
|
||||
|
||||
/**
|
||||
* Gets the list of all the pids of the system through the wmic command.
|
||||
* @param {Function} callback(err, list)
|
||||
*/
|
||||
function wmic(callback) {
|
||||
var args = ['PROCESS', 'get', 'ParentProcessId,ProcessId'];
|
||||
var options = {windowsHide: true, windowsVerbatimArguments: true};
|
||||
bin('wmic', args, options, function(err, stdout, code) {
|
||||
if (err) {
|
||||
callback(err);
|
||||
return;
|
||||
}
|
||||
|
||||
if (code !== 0) {
|
||||
callback(new Error('pidtree wmic command exited with code ' + code));
|
||||
return;
|
||||
}
|
||||
|
||||
// Example of stdout
|
||||
//
|
||||
// ParentProcessId ProcessId
|
||||
// 0 777
|
||||
|
||||
try {
|
||||
stdout = stdout.split(os.EOL);
|
||||
|
||||
var list = [];
|
||||
for (var i = 1; i < stdout.length; i++) {
|
||||
stdout[i] = stdout[i].trim();
|
||||
if (!stdout[i]) continue;
|
||||
stdout[i] = stdout[i].split(/\s+/);
|
||||
stdout[i][0] = parseInt(stdout[i][0], 10); // PPID
|
||||
stdout[i][1] = parseInt(stdout[i][1], 10); // PID
|
||||
list.push(stdout[i]);
|
||||
}
|
||||
|
||||
callback(null, list);
|
||||
} catch (error) {
|
||||
callback(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = wmic;
|
21
node_modules/pidtree/license
generated
vendored
Normal file
21
node_modules/pidtree/license
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Simone Primarosa
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
90
node_modules/pidtree/package.json
generated
vendored
Normal file
90
node_modules/pidtree/package.json
generated
vendored
Normal file
@ -0,0 +1,90 @@
|
||||
{
|
||||
"name": "pidtree",
|
||||
"version": "0.6.0",
|
||||
"description": "Cross platform children list of a PID",
|
||||
"license": "MIT",
|
||||
"homepage": "http://github.com/simonepri/pidtree#readme",
|
||||
"repository": "github:simonepri/pidtree",
|
||||
"bugs": {
|
||||
"url": "https://github.com/simonepri/pidtree/issues",
|
||||
"email": "simonepri@outlook.com"
|
||||
},
|
||||
"author": "Simone Primarosa <simonepri@outlook.com> (https://github.com/simonepri)",
|
||||
"contributors": [
|
||||
"Simone Primarosa <simonepri@outlook.com> (https://github.com/simonepri)"
|
||||
],
|
||||
"keywords": [
|
||||
"ps-tree",
|
||||
"ps",
|
||||
"tree",
|
||||
"ppid",
|
||||
"pid",
|
||||
"pidtree",
|
||||
"pgrep",
|
||||
"list",
|
||||
"all",
|
||||
"system",
|
||||
"process",
|
||||
"processes"
|
||||
],
|
||||
"main": "index.js",
|
||||
"types": "index.d.ts",
|
||||
"bin": {
|
||||
"pidtree": "./bin/pidtree.js"
|
||||
},
|
||||
"files": [
|
||||
"bin",
|
||||
"lib",
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=0.10"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "node ./bin/pidtree.js",
|
||||
"update": "npm-check -u",
|
||||
"release": "np",
|
||||
"lint": "xo",
|
||||
"test": "nyc ava -m \"!*benchmark*\"",
|
||||
"test:windows": "ava -m \"!*benchmark*\"",
|
||||
"types": "tsd",
|
||||
"bench": "ava -m \"*benchmark*\""
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "~0.25.0",
|
||||
"mockery": "^2.1.0",
|
||||
"np": "^2.20.1",
|
||||
"npm-check": "^5.9.2",
|
||||
"nyc": "^11.6.0",
|
||||
"pify": "^3.0.0",
|
||||
"string-to-stream": "^1.1.0",
|
||||
"through": "^2.3.8",
|
||||
"time-span": "^2.0.0",
|
||||
"tree-kill": "^1.1.0",
|
||||
"tsd": "^0.11.0",
|
||||
"xo": "~0.20.3"
|
||||
},
|
||||
"ava": {
|
||||
"verbose": true
|
||||
},
|
||||
"nyc": {
|
||||
"reporter": [
|
||||
"lcovonly",
|
||||
"text"
|
||||
]
|
||||
},
|
||||
"xo": {
|
||||
"prettier": true,
|
||||
"space": true,
|
||||
"rules": {
|
||||
"prefer-destructuring": 0,
|
||||
"prefer-arrow-callback": 0,
|
||||
"no-var": 0,
|
||||
"object-shorthand": 0,
|
||||
"unicorn/no-for-loop": 0,
|
||||
"unicorn/prefer-string-slice": 0,
|
||||
"unicorn/string-content": 0
|
||||
}
|
||||
}
|
||||
}
|
197
node_modules/pidtree/readme.md
generated
vendored
Normal file
197
node_modules/pidtree/readme.md
generated
vendored
Normal file
@ -0,0 +1,197 @@
|
||||
<h1 align="center">
|
||||
<b>pidtree</b>
|
||||
</h1>
|
||||
<p align="center">
|
||||
<!-- Version - npm -->
|
||||
<a href="https://www.npmjs.com/package/pidtree">
|
||||
<img src="https://img.shields.io/npm/v/pidtree.svg" alt="Latest version on npm" />
|
||||
</a>
|
||||
<!-- Downloads - npm -->
|
||||
<a href="https://npm-stat.com/charts.html?package=pidtree">
|
||||
<img src="https://img.shields.io/npm/dt/pidtree.svg" alt="Downloads on npm" />
|
||||
</a>
|
||||
<!-- License - MIT -->
|
||||
<a href="https://github.com/simonepri/pidtree/tree/master/license">
|
||||
<img src="https://img.shields.io/github/license/simonepri/pidtree.svg" alt="Project license" />
|
||||
</a>
|
||||
|
||||
<br/>
|
||||
|
||||
<!-- Lint -->
|
||||
<a href="https://github.com/simonepri/pidtree/actions?query=workflow:lint+branch:master">
|
||||
<img src="https://github.com/simonepri/pidtree/workflows/lint/badge.svg?branch=master" alt="Lint status" />
|
||||
</a>
|
||||
<!-- Test - macOS -->
|
||||
<a href="https://github.com/simonepri/pidtree/actions?query=workflow:test-macos+branch:master">
|
||||
<img src="https://github.com/simonepri/pidtree/workflows/test-macos/badge.svg?branch=master" alt="Test macOS status" />
|
||||
</a>
|
||||
<!-- Test - Ubuntu -->
|
||||
<a href="https://github.com/simonepri/pidtree/actions?query=workflow:test-ubuntu+branch:master">
|
||||
<img src="https://github.com/simonepri/pidtree/workflows/test-ubuntu/badge.svg?branch=master" alt="Test Ubuntu status" />
|
||||
</a>
|
||||
<!-- Test - Windows -->
|
||||
<a href="https://github.com/simonepri/pidtree/actions?query=workflow:test-windows+branch:master">
|
||||
<img src="https://github.com/simonepri/pidtree/workflows/test-windows/badge.svg?branch=master" alt="Test Windows status" />
|
||||
</a>
|
||||
<!-- Coverage - Codecov -->
|
||||
<a href="https://codecov.io/gh/simonepri/pidtree">
|
||||
<img src="https://img.shields.io/codecov/c/github/simonepri/pidtree/master.svg" alt="Codecov Coverage report" />
|
||||
</a>
|
||||
<!-- DM - Snyk -->
|
||||
<a href="https://snyk.io/test/github/simonepri/pidtree?targetFile=package.json">
|
||||
<img src="https://snyk.io/test/github/simonepri/pidtree/badge.svg?targetFile=package.json" alt="Known Vulnerabilities" />
|
||||
</a>
|
||||
|
||||
<br/>
|
||||
|
||||
<!-- Code Style - XO-Prettier -->
|
||||
<a href="https://github.com/xojs/xo">
|
||||
<img src="https://img.shields.io/badge/code_style-XO+Prettier-5ed9c7.svg" alt="XO Code Style used" />
|
||||
</a>
|
||||
<!-- Test Runner - AVA -->
|
||||
<a href="https://github.com/avajs/ava">
|
||||
<img src="https://img.shields.io/badge/test_runner-AVA-fb3170.svg" alt="AVA Test Runner used" />
|
||||
</a>
|
||||
<!-- Test Coverage - Istanbul -->
|
||||
<a href="https://github.com/istanbuljs/nyc">
|
||||
<img src="https://img.shields.io/badge/test_coverage-NYC-fec606.svg" alt="Istanbul Test Coverage used" />
|
||||
</a>
|
||||
<!-- Init - ni -->
|
||||
<a href="https://github.com/simonepri/ni">
|
||||
<img src="https://img.shields.io/badge/initialized_with-ni-e74c3c.svg" alt="NI Scaffolding System used" />
|
||||
</a>
|
||||
<!-- Release - np -->
|
||||
<a href="https://github.com/sindresorhus/np">
|
||||
<img src="https://img.shields.io/badge/released_with-np-6c8784.svg" alt="NP Release System used" />
|
||||
</a>
|
||||
</p>
|
||||
<p align="center">
|
||||
🚸 Cross platform children list of a PID.
|
||||
|
||||
<br/>
|
||||
|
||||
<sub>
|
||||
Coded with ❤️ by <a href="#authors">Simone Primarosa</a>.
|
||||
</sub>
|
||||
</p>
|
||||
|
||||
## Synopsis
|
||||
|
||||
This package is really similar to [ps-tree][gh:ps-tree] but is faster, safer and
|
||||
provides sub-children results.
|
||||
Furthermore ps-tree is [unmaintained][gh:ps-tree-um].
|
||||
|
||||
Uuh, and a fancy [CLI](#cli) is also available!
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var pidtree = require('pidtree')
|
||||
|
||||
// Get childs of current process
|
||||
pidtree(process.pid, function (err, pids) {
|
||||
console.log(pids)
|
||||
// => []
|
||||
})
|
||||
|
||||
// Include the given pid in the result array
|
||||
pidtree(process.pid, {root: true}, function (err, pids) {
|
||||
console.log(pids)
|
||||
// => [727]
|
||||
})
|
||||
|
||||
// Get all the processes of the System (-1 is a special value of this package)
|
||||
pidtree(-1, function (err, pids) {
|
||||
console.log(pids)
|
||||
// => [530, 42, ..., 41241]
|
||||
})
|
||||
|
||||
// Include PPID in the results
|
||||
pidtree(1, {advanced: true}, function (err, pids) {
|
||||
console.log(pids)
|
||||
// => [{ppid: 1, pid: 530}, {ppid: 1, pid: 42}, ..., {ppid: 1, pid: 41241}]
|
||||
})
|
||||
|
||||
// If no callback is given it returns a promise instead
|
||||
const pids = await pidtree(1)
|
||||
console.log(pids)
|
||||
// => [141, 42, ..., 15242]
|
||||
```
|
||||
|
||||
## Compatibility
|
||||
|
||||
| Linux | FreeBSD | NetBSD | SunOS | macOS | Win | AIX |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| ✅ | ❓ | ❓ | ❓ | ✅ | ✅ | ❓ |
|
||||
|
||||
✅ = Working
|
||||
❓ = Not tested but should work
|
||||
|
||||
Please if your platform is not supported [file an issue][new issue].
|
||||
|
||||
## CLI
|
||||
|
||||
<img src="https://github.com/simonepri/pidtree/raw/master/media/cli.gif" alt="pidtree cli" width="300" align="right"/>
|
||||
Show a tree of the processes inside your system inside your terminal.
|
||||
|
||||
```bash
|
||||
npx pidtree $PPID
|
||||
```
|
||||
Just replace `$PPID` with one of the pids inside your system.
|
||||
|
||||
Or don't pass anything if you want all the pids inside your system.
|
||||
|
||||
```bash
|
||||
npx pidtree
|
||||
```
|
||||
|
||||
To display the output as a list, similar to the one produced from `pgrep -P $PID`,
|
||||
pass the `--list` flag.
|
||||
|
||||
```bash
|
||||
npx pidtree --list
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
<a name="pidtree"></a>
|
||||
|
||||
## pidtree(pid, [options], [callback]) ⇒ <code>[Promise.<Array.<Object>>]</code>
|
||||
Get the list of children pids of the given pid.
|
||||
|
||||
**Kind**: global function
|
||||
**Returns**: <code>Promise.<Array.<Object>></code> - Only when the callback is not provided.
|
||||
**Access**: public
|
||||
|
||||
| Param | Type | Default | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| pid | <code>Number</code> \| <code>String</code> | | A pid. If -1 will return all the pids. |
|
||||
| [options] | <code>Object</code> | | Optional options object. |
|
||||
| [options.root] | <code>Boolean</code> | <code>false</code> | Include the provided pid in the list. Ignored if -1 is passed as pid. |
|
||||
| [callback] | <code>function</code> | | Called when the list is ready. If not provided a promise is returned instead. |
|
||||
|
||||
## Related
|
||||
|
||||
- [pidusage][gh:pidusage] -
|
||||
Cross-platform process cpu % and memory usage of a PID
|
||||
|
||||
## Authors
|
||||
|
||||
- **Simone Primarosa** - [simonepri][github:simonepri]
|
||||
|
||||
See also the list of [contributors][contributors] who participated in this project.
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the MIT License - see the [license][license] file for details.
|
||||
|
||||
<!-- Links -->
|
||||
[new issue]: https://github.com/simonepri/pidtree/issues/new
|
||||
[license]: https://github.com/simonepri/pidtree/tree/master/license
|
||||
[contributors]: https://github.com/simonepri/pidtree/contributors
|
||||
|
||||
[github:simonepri]: https://github.com/simonepri
|
||||
|
||||
[gh:pidusage]: https://github.com/soyuka/pidusage
|
||||
[gh:ps-tree]: https://github.com/indexzero/ps-tree
|
||||
[gh:ps-tree-um]: https://github.com/indexzero/ps-tree/issues/30
|
Reference in New Issue
Block a user