From 1d0805a21c15e3c75c418dd8cc90220914ded384 Mon Sep 17 00:00:00 2001 From: Zhuohuan LI Date: Wed, 1 Jun 2016 07:48:48 +0000 Subject: [PATCH 01/12] add appveyor win32 ci support --- appveyor.yml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 0000000..599abe5 --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,38 @@ +# http://www.appveyor.com/docs/appveyor-yml + +# Test against these versions of Io.js and Node.js. +environment: + matrix: + # node.js + - nodejs_version: "0.8" + - nodejs_version: "0.10" + - nodejs_version: "0.12" + - nodejs_version: "4" + - nodejs_version: "5" + - nodejs_version: "6" + +# Install scripts. (runs after repo cloning) +install: + # Get the latest stable version of Node 0.STABLE.latest + - ps: Install-Product node $env:nodejs_version + - IF %nodejs_version% EQU 0.8 npm -g install npm@2 + - IF %nodejs_version% EQU 0.8 set PATH=%APPDATA%\npm;%PATH% + - npm -g install npm + - IF %nodejs_version% NEQ 0.8 set PATH=%APPDATA%\npm;%PATH% + # Typical npm stuff. + - npm install + - npm run rebuild-tests + +# Post-install test scripts. +test_script: + # Output useful info for debugging. + - node --version + - npm --version + # run tests + - npm test + +# Don't actually build. +build: off + +# Set build version format here instead of in the admin panel. +version: "{build}" From 0f315313276d0bb5128d5b8cfb6b04de7bb21810 Mon Sep 17 00:00:00 2001 From: Zhuohuan LI Date: Wed, 1 Jun 2016 07:53:01 +0000 Subject: [PATCH 02/12] add appveyor ci badge --- README.md | 3 +++ appveyor.yml | 9 ++------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 62ac16c..8bcd91c 100644 --- a/README.md +++ b/README.md @@ -47,10 +47,13 @@ If you prefer to run **psTree** from the command line, use: `node ./bin/ps-tree. P.S. ps-tree also support Win32. [![Build Status](https://travis-ci.org/nelsonic/ps-tree.svg)](https://travis-ci.org/nelsonic/ps-tree) +[![Build status](https://ci.appveyor.com/api/projects/status/15yvc221rx8lt8o7?svg=true)](https://ci.appveyor.com/project/zixia/ps-tree) + [![Code Climate](https://codeclimate.com/github/nelsonic/ps-tree/badges/gpa.svg)](https://codeclimate.com/github/nelsonic/ps-tree) [![Test Coverage](https://codeclimate.com/github/nelsonic/ps-tree/badges/coverage.svg)](https://codeclimate.com/github/nelsonic/ps-tree) [![npm version](https://badge.fury.io/js/ps-tree.svg)](http://badge.fury.io/js/ps-tree) [![Node.js Version][node-version-image]][node-version-url] [![Dependency Status](https://david-dm.org/nelsonic/ps-tree.svg)](https://david-dm.org/nelsonic/ps-tree) + [node-version-image]: https://img.shields.io/node/v/listdirs.svg?style=flat [node-version-url]: http://nodejs.org/download/ diff --git a/appveyor.yml b/appveyor.yml index 599abe5..0126c45 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,15 +13,10 @@ environment: # Install scripts. (runs after repo cloning) install: - # Get the latest stable version of Node 0.STABLE.latest + # Get the latest stable version of Node.js or io.js - ps: Install-Product node $env:nodejs_version - - IF %nodejs_version% EQU 0.8 npm -g install npm@2 - - IF %nodejs_version% EQU 0.8 set PATH=%APPDATA%\npm;%PATH% - - npm -g install npm - - IF %nodejs_version% NEQ 0.8 set PATH=%APPDATA%\npm;%PATH% - # Typical npm stuff. + # install modules - npm install - - npm run rebuild-tests # Post-install test scripts. test_script: From 65f794666f79617cc6270dbfbf08229d92e5c075 Mon Sep 17 00:00:00 2001 From: Zhuohuan LI Date: Wed, 1 Jun 2016 08:03:29 +0000 Subject: [PATCH 03/12] fix old npm on appveyor --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index 0126c45..fbad73c 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -16,6 +16,7 @@ install: # Get the latest stable version of Node.js or io.js - ps: Install-Product node $env:nodejs_version # install modules + - npm install -g npm - npm install # Post-install test scripts. From a55429f033def6d2f486383c6c254727da81a991 Mon Sep 17 00:00:00 2001 From: Zhuohuan LI Date: Wed, 1 Jun 2016 08:10:52 +0000 Subject: [PATCH 04/12] file permissions --- bin/ps-tree.js | 0 index.js | 0 package.json | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 bin/ps-tree.js mode change 100755 => 100644 index.js mode change 100755 => 100644 package.json diff --git a/bin/ps-tree.js b/bin/ps-tree.js old mode 100644 new mode 100755 diff --git a/index.js b/index.js old mode 100755 new mode 100644 diff --git a/package.json b/package.json old mode 100755 new mode 100644 From 209a45e89f5e3d1749a9484c25895a6099cddd39 Mon Sep 17 00:00:00 2001 From: Zhuohuan LI Date: Tue, 21 Jun 2016 13:23:53 +0800 Subject: [PATCH 05/12] fix #18 get the same name `COMMAND` for child under darwin --- index.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/index.js b/index.js index 24e3284..c5b3f54 100644 --- a/index.js +++ b/index.js @@ -28,6 +28,12 @@ module.exports = function childrenOfPid(pid, callback) { // ps 20688 16965 R+ // ``` // + // Darwin: + // $ ps -A -o comm,ppid,pid,stat + // COMM PPID PID STAT + // /sbin/launchd 0 1 Ss + // /usr/libexec/Use 1 43 Ss + // // Win32: // 1. wmic PROCESS WHERE ParentProcessId=4604 GET Name,ParentProcessId,ProcessId,Status) // 2. The order of head columns is fixed @@ -112,6 +118,9 @@ function normalizeHeader(str) { case 'Status': return 'STAT'; break; + case 'COMM': // for darwin + return 'COMMAND'; + break; default: throw new Error('Unknown process listing header: ' + str); } From fd82297469cc3635e6ec1239c8e5ed56013cb53e Mon Sep 17 00:00:00 2001 From: Zhuohuan LI Date: Tue, 21 Jun 2016 14:40:20 +0800 Subject: [PATCH 06/12] darwin & win32 together --- index.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index c5b3f54..aa88ed9 100644 --- a/index.js +++ b/index.js @@ -106,7 +106,8 @@ function normalizeHeader(str) { } switch (str) { - case 'Name': + case 'Name': // for win32 + case 'COMM': // for darwin return 'COMMAND'; break; case 'ParentProcessId': @@ -118,9 +119,6 @@ function normalizeHeader(str) { case 'Status': return 'STAT'; break; - case 'COMM': // for darwin - return 'COMMAND'; - break; default: throw new Error('Unknown process listing header: ' + str); } From 76cc0e0ccced0afecbbbfcf2a83063253fcf38b2 Mon Sep 17 00:00:00 2001 From: soyuka Date: Sun, 30 Apr 2017 15:04:52 +0200 Subject: [PATCH 07/12] normalize darwin header also --- index.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/index.js b/index.js index aa88ed9..6fe23cd 100644 --- a/index.js +++ b/index.js @@ -101,10 +101,6 @@ module.exports = function childrenOfPid(pid, callback) { * @param {string} str Header string to normalize */ function normalizeHeader(str) { - if (process.platform !== 'win32') { - return str; - } - switch (str) { case 'Name': // for win32 case 'COMM': // for darwin @@ -120,6 +116,6 @@ function normalizeHeader(str) { return 'STAT'; break; default: - throw new Error('Unknown process listing header: ' + str); + return str } } From af2a5ebc4715325e6df7c7174adbc4e6ce5133b7 Mon Sep 17 00:00:00 2001 From: Huan LI Date: Fri, 16 Mar 2018 17:59:18 +0800 Subject: [PATCH 08/12] remove appveyor for https://github.com/indexzero/ps-tree/issues/30 --- appveyor.yml | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index fbad73c..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,34 +0,0 @@ -# http://www.appveyor.com/docs/appveyor-yml - -# Test against these versions of Io.js and Node.js. -environment: - matrix: - # node.js - - nodejs_version: "0.8" - - nodejs_version: "0.10" - - nodejs_version: "0.12" - - nodejs_version: "4" - - nodejs_version: "5" - - nodejs_version: "6" - -# Install scripts. (runs after repo cloning) -install: - # Get the latest stable version of Node.js or io.js - - ps: Install-Product node $env:nodejs_version - # install modules - - npm install -g npm - - npm install - -# Post-install test scripts. -test_script: - # Output useful info for debugging. - - node --version - - npm --version - # run tests - - npm test - -# Don't actually build. -build: off - -# Set build version format here instead of in the admin panel. -version: "{build}" From faec1188cd7df0509c18c0c44ad6324a678c6426 Mon Sep 17 00:00:00 2001 From: Huan LI Date: Fri, 16 Mar 2018 18:00:54 +0800 Subject: [PATCH 09/12] remove readme for https://github.com/indexzero/ps-tree/issues/30 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a9df1b6..40a238a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# ps-tree [![Build Status](https://travis-ci.org/indexzero/ps-tree.svg)](https://travis-ci.org/indexzero/ps-tree) [![Build status](https://ci.appveyor.com/api/projects/status/15yvc221rx8lt8o7?svg=true)](https://ci.appveyor.com/project/zixia/ps-tree) +# ps-tree [![Build Status](https://travis-ci.org/indexzero/ps-tree.svg)](https://travis-ci.org/indexzero/ps-tree) [![Code Climate](https://codeclimate.com/github/indexzero/ps-tree/badges/gpa.svg)](https://codeclimate.com/github/indexzero/ps-tree) [![Test Coverage](https://codeclimate.com/github/indexzero/ps-tree/badges/coverage.svg)](https://codeclimate.com/github/indexzero/ps-tree) From c17a5bbfe1d363bfbe2862f581aea74dfb245733 Mon Sep 17 00:00:00 2001 From: Huan LI Date: Fri, 16 Mar 2018 18:01:33 +0800 Subject: [PATCH 10/12] remove readme for https://github.com/indexzero/ps-tree/issues/30 --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 40a238a..36cb2e2 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ -# ps-tree [![Build Status](https://travis-ci.org/indexzero/ps-tree.svg)](https://travis-ci.org/indexzero/ps-tree) +# ps-tree +[![Build Status](https://travis-ci.org/indexzero/ps-tree.svg)](https://travis-ci.org/indexzero/ps-tree) [![Code Climate](https://codeclimate.com/github/indexzero/ps-tree/badges/gpa.svg)](https://codeclimate.com/github/indexzero/ps-tree) [![Test Coverage](https://codeclimate.com/github/indexzero/ps-tree/badges/coverage.svg)](https://codeclimate.com/github/indexzero/ps-tree) [![npm version](https://badge.fury.io/js/ps-tree.svg)](http://badge.fury.io/js/ps-tree) From 426de404f4fcc0486ada7eaa47bd5faa4d0b4011 Mon Sep 17 00:00:00 2001 From: Huan LI Date: Fri, 16 Mar 2018 18:01:53 +0800 Subject: [PATCH 11/12] remove readme for https://github.com/indexzero/ps-tree/issues/30 --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 36cb2e2..a3f9e8d 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ If you prefer to run **psTree** from the command line, use: `node ./bin/ps-tree. ## Cross Platform support + The `ps-tree` module behaves differently on *nix vs. Windows by spawning different programs and parsing their output. This is based on `process.platform` and not on checking to see if a `ps` compatible program exists on the system. #### *nix From 142329be6229bc38bbcabdd40bba83ccbb47a7b7 Mon Sep 17 00:00:00 2001 From: Huan LI Date: Fri, 16 Mar 2018 18:12:03 +0800 Subject: [PATCH 12/12] add doc --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index a3f9e8d..66297ef 100644 --- a/README.md +++ b/README.md @@ -80,4 +80,15 @@ System 0 4 smss.exe 4 228 ``` +### Mac/Darwin + +1. " " need to be striped + +```shell +$ ps -A -o comm,ppid,pid,stat +COMM PPID PID STAT +/sbin/launchd 0 1 Ss +/usr/libexec/Use 1 43 Ss +``` + ### LICENSE: MIT