Skip to content

Commit d3bc13e

Browse files
committed
Added docs and coverage testing
1 parent 6d5be90 commit d3bc13e

2 files changed

Lines changed: 25 additions & 3 deletions

File tree

README.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,28 @@
77
![module type: official](https://img.shields.io/badge/module%20type-official-%23015ba0)
88

99
A module for the server-state project.
10+
This module allows running "raw" terminal commands and getting their output to
11+
stdout and stderr. Commands do **not** get run in chronological order and each
12+
command may only get run once per *SM*.
1013

11-
This module allows to run commands specified on the server-side and return their output to gather data not covered by
12-
another module. Commands may **not** get called multiple times and the order of execution of the commands is not specified.
14+
### Example
15+
To use the module, you'll need to pass a configuartion object containing the connect information to the [*SMF*](https://github.com/server-state/specs/blob/master/terminology/server-module-function.md).
16+
17+
Since the module uses `mysql2`, which is *mostly API-compatible with `mysqljs/mysql`*, you may refer to https://github.com/mysqljs/mysql#connection-options for specifications. In most cases, though, you'll need to pass a `host`, a `user`, a `password` and possibly a `port`:
18+
19+
```js
20+
serverState.registerModule('raw', require('@server-state/raw-module'), [
21+
'ls',
22+
'whoami',
23+
'echo Hello'
24+
]);
25+
```
26+
27+
Example return object:
28+
```json
29+
{
30+
"ls":{"stdout":"[...]","stderr":"","cmd":"ls","code":0},
31+
"whoami":{"stdout":"[...]","stderr":"","cmd":"whoami","code":0},
32+
"echo Hello":{"stdout":"Hello","stderr":"","cmd":"echo Hello","code":0}
33+
}
34+
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Module for raw exec output for the server-state project",
55
"main": "index.js",
66
"scripts": {
7-
"test": "jest",
7+
"test": "jest --coverage",
88
"lint": "eslint ./src",
99
"build": "webpack --config webpack.config.js --mode production"
1010
},

0 commit comments

Comments
 (0)