Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nisaacson/fleet-ps-json
Transforms the output of fleet-ps into json.
https://github.com/nisaacson/fleet-ps-json
Last synced: about 1 month ago
JSON representation
Transforms the output of fleet-ps into json.
- Host: GitHub
- URL: https://github.com/nisaacson/fleet-ps-json
- Owner: nisaacson
- Created: 2013-03-22T06:00:32.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-03-22T06:01:18.000Z (over 11 years ago)
- Last Synced: 2024-04-14T14:46:37.101Z (7 months ago)
- Language: JavaScript
- Size: 105 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Fleet PS JSON
Transforms the output of fleet-ps into json.# Installation
```
npm install -S fleet-ps-json
``````
fleet-ps
drone#foo002
├─┬ pid#fa8666
│ ├── status: running
│ ├── commit: cabbage/gitHashHere
│ └── command: node cabbage.jsdrone#foo001
├─┬ pid#b0a13c
│ ├── status: running
│ ├── commit: bacon/gitHashHere
│ └── command: node bacon.js
├─┬ pid#eb2c86
│ ├── status: running
│ ├── commit: carrot/gitHashHere
│ └── command: node carrot.js
├─┬ pid#4401fc
│ ├── status: running
│ ├── commit: lettuce/gitHashHere
│ └── command: node lettuce.js
├─┬ pid#fb1b7b
│ ├── status: running
│ ├── commit: apples/gitHashHere
│ └── command: node apples.js
└─┬ pid#d1829a
├── status: running
├── commit: grapes/gitHashHere
└── command: node grapes.jsdrone#foo003
```## Output
```javascript
[
{
command: 'node cabbage.js',
commit: 'cabbage/gitHashHere',
pid: 'fa8666',
drone: 'foo002'
},
{
command: 'node bacon.js',
commit: 'bacon/gitHashHere',
pid: 'b0a13c',
drone: 'foo001'
},
{
command: 'node carrot.js',
commit: 'carrot/gitHashHere',
pid: 'eb2c86',
drone: 'foo001'
},
{
command: 'node lettuce.js',
commit: 'lettuce/gitHashHere',
pid: '4401fc',
drone: 'foo001'
},
{
command: 'node apples.js',
commit: 'apples/gitHashHere',
pid: 'fb1b7b',
drone: 'foo001'
},
{
command: 'node grapes.js',
commit: 'grapes/gitHashHere',
pid: 'd1829a',
drone: 'foo001'
}
]
```To group by drone
```javascript
var psJSON = require('fleet-ps-json')
var text = 'foo' // fleet ps text here
var json = psJSON(text)
var byDrone = json.reduce(function (prev, element) {
var drone = element.drone
delete element.drone
prev[drone] = element
return prev
}, {})
```Returns output that looks like
```javascript
{
foo001: {
pid: 'd1829a',
command: 'node grapes.js',
commit: 'grapes/gitHashHere'
},
foo002: {
pid: 'fa8666',
command: 'node cabbage.js',
commit: 'cabbage/gitHashHere'
}
}
```