Skip to content

Commit 0c522e6

Browse files
committed
feat(exec): add first version
1 parent 3fe8e8a commit 0c522e6

File tree

8 files changed

+240
-90
lines changed

8 files changed

+240
-90
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules/
2-
coverage/
2+
coverage/
3+
dist

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,29 @@
1-
# Typescript project template
1+
# Wrapper for [child_process.exec](https://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback)
2+
3+
## Usage
4+
5+
As a function:
6+
7+
```ts
8+
import { exec } from '@cloud-cli/exec';
9+
10+
// ...
11+
12+
const { stdout, ok } = await exec('ls', ['-l']);
13+
14+
if (ok) {
15+
console.log(stdout);
16+
}
17+
```
18+
19+
As an event emitter:
20+
21+
```ts
22+
import { Process } from '@cloud-cli/exec';
23+
import { spawn } from 'child_process';
24+
25+
const ps = new Process(spawn('ls', ['-l']));
26+
ps.on('done', (result) => {
27+
console.log(result.ok, result.stdout);
28+
});
29+
```

jest.config.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
export default {
22
collectCoverage: true,
33
coverageDirectory: 'coverage',
4-
coverageProvider: 'v8',
54
coverageThreshold: {
65
global: {
76
branches: 100,
@@ -10,7 +9,7 @@ export default {
109
statements: 100,
1110
},
1211
},
13-
maxWorkers: '90%',
12+
maxWorkers: 1,
1413
moduleFileExtensions: ['js', 'ts'],
1514
preset: 'ts-jest',
1615
slowTestThreshold: 1,

package-lock.json

Lines changed: 71 additions & 72 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22
"name": "@cloud-cli/exec",
33
"version": "0.0.0",
44
"description": "Promise wrapper for child_process.spawn",
5-
"main": "index.js",
5+
"main": "./dist/index.js",
6+
"types": "./dist/index.d.ts",
67
"scripts": {
7-
"test": "jest"
8+
"build": "tsc",
9+
"test": "jest",
10+
"tdd": "jest --watchAll"
811
},
912
"repository": {
1013
"type": "git",
@@ -23,7 +26,8 @@
2326
"@types/jest": "^26.0.23",
2427
"jest": "^27.0.4",
2528
"ts-jest": "^27.0.3",
26-
"ts-node": "^10.0.0"
29+
"ts-node": "^10.0.0",
30+
"typescript": "^4.4.2"
2731
},
2832
"dependencies": {
2933
"string_decoder": "^1.3.0"

0 commit comments

Comments
 (0)