jest-runner-cli 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +349 -0
- package/dist/CliRunner.d.ts +147 -0
- package/dist/CliRunner.d.ts.map +1 -0
- package/dist/CliRunner.js +384 -0
- package/dist/CliRunner.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/run.d.ts +14 -0
- package/dist/run.d.ts.map +1 -0
- package/dist/run.js +14 -0
- package/dist/run.js.map +1 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 nojaja
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,349 @@
|
|
|
1
|
+
# jest-runner-cli
|
|
2
|
+
|
|
3
|
+
> A custom Jest runner with an imperative CLI process helper for testing CLI applications.
|
|
4
|
+
|
|
5
|
+
**jest-runner-cli** is a lightweight, ESM-native Jest runner package that provides:
|
|
6
|
+
- A custom Jest runner built with `create-jest-runner` for seamless integration
|
|
7
|
+
- A `CliRunner` helper class to spawn and interact with child processes in tests
|
|
8
|
+
- Full support for stdout/stderr monitoring, JSON parsing, and process management
|
|
9
|
+
|
|
10
|
+
Perfect for testing CLI tools, scripts, and command-line applications in your Jest test suite.
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
✅ **Custom Jest Runner** — Drop-in replacement for running tests with a custom runner
|
|
15
|
+
✅ **CliRunner Helper** — Easy-to-use imperative API for spawning and controlling CLI processes
|
|
16
|
+
✅ **Flexible Output Reading** — Read stdout as lines, raw text, or parse JSON
|
|
17
|
+
✅ **Auto-Exit Protection** — Automatically detect and terminate hung processes
|
|
18
|
+
✅ **Cross-Platform** — Works on Windows, macOS, and Linux
|
|
19
|
+
✅ **ESM Native** — Built with modern ESM module support
|
|
20
|
+
✅ **TypeScript Ready** — Full type definitions included
|
|
21
|
+
|
|
22
|
+
⚠️ **Limitations** — Advanced retry strategies and custom signal handling not yet implemented
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install --save-dev jest-runner-cli
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Peer Dependency:** Jest ^29.6.1
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
### 1. Configure Jest
|
|
35
|
+
|
|
36
|
+
Update `jest.config.js`:
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
// jest.config.js (ESM)
|
|
40
|
+
export default {
|
|
41
|
+
runner: 'jest-runner-cli',
|
|
42
|
+
testMatch: ['<rootDir>/test/**/*.test.ts']
|
|
43
|
+
};
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 2. Use in Tests
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { CliRunner } from 'jest-runner-cli';
|
|
50
|
+
|
|
51
|
+
describe('CLI testing', () => {
|
|
52
|
+
it('runs node -v and captures output', async () => {
|
|
53
|
+
const cli = new CliRunner();
|
|
54
|
+
cli.start({ command: process.execPath, args: ['-v'] });
|
|
55
|
+
|
|
56
|
+
const lines = await cli.readStdout().toLines(2000);
|
|
57
|
+
expect(lines[0]).toMatch(/^v\d+\.\d+\.\d+/);
|
|
58
|
+
|
|
59
|
+
await cli.sendCtrlC();
|
|
60
|
+
cli.dispose();
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Usage Guide
|
|
66
|
+
|
|
67
|
+
### Jest Runner Configuration
|
|
68
|
+
|
|
69
|
+
The package acts as a Jest custom runner. Once configured in `jest.config.js`, Jest will automatically use it to execute your test files.
|
|
70
|
+
|
|
71
|
+
### CliRunner API
|
|
72
|
+
|
|
73
|
+
#### Basic Usage
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
import { CliRunner } from 'jest-runner-cli';
|
|
77
|
+
|
|
78
|
+
const runner = new CliRunner();
|
|
79
|
+
|
|
80
|
+
// Start a process
|
|
81
|
+
runner.start({
|
|
82
|
+
command: 'node',
|
|
83
|
+
args: ['./my-script.js'],
|
|
84
|
+
cwd: process.cwd(),
|
|
85
|
+
env: process.env
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// Write to stdin
|
|
89
|
+
runner.writeln('input data');
|
|
90
|
+
|
|
91
|
+
// Read output
|
|
92
|
+
const output = await runner.readStdout().toLines();
|
|
93
|
+
|
|
94
|
+
// Gracefully stop
|
|
95
|
+
await runner.sendCtrlC();
|
|
96
|
+
runner.dispose();
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
#### Reading Output
|
|
100
|
+
|
|
101
|
+
```ts
|
|
102
|
+
// Read as array of lines
|
|
103
|
+
const lines = await runner.readStdout().toLines(2000); // timeout in ms
|
|
104
|
+
|
|
105
|
+
// Read as raw string
|
|
106
|
+
const text = await runner.readStdout(2000);
|
|
107
|
+
|
|
108
|
+
// Extract JSON
|
|
109
|
+
const json = await runner.readStdout().toJson(2000);
|
|
110
|
+
|
|
111
|
+
// Get stderr
|
|
112
|
+
const errors = runner.readStderr();
|
|
113
|
+
|
|
114
|
+
// Clear buffer
|
|
115
|
+
runner.readStdout().clear();
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
#### Handling Process Events
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
// Listen for process exit
|
|
122
|
+
runner.on('exit', ({ code, signal }) => {
|
|
123
|
+
console.log(`Process exited with code ${code}`);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// Auto-exit on timeout (e.g., hung process)
|
|
127
|
+
runner.start({ command: 'node', args: ['long-running.js'] }, 5000); // 5s timeout
|
|
128
|
+
|
|
129
|
+
// Listen for auto-exit error
|
|
130
|
+
runner.once('error', (err) => {
|
|
131
|
+
if (err.message === 'auto-exit timeout reached') {
|
|
132
|
+
console.log('Process was auto-terminated');
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Complete Example
|
|
138
|
+
|
|
139
|
+
```ts
|
|
140
|
+
import { CliRunner } from 'jest-runner-cli';
|
|
141
|
+
|
|
142
|
+
describe('My CLI App', () => {
|
|
143
|
+
let cli: CliRunner;
|
|
144
|
+
|
|
145
|
+
beforeEach(() => {
|
|
146
|
+
cli = new CliRunner();
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
afterEach(async () => {
|
|
150
|
+
await cli.sendCtrlC().catch(() => {});
|
|
151
|
+
cli.dispose();
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('displays help text', async () => {
|
|
155
|
+
cli.start({ command: 'node', args: ['./bin/cli.js', '--help'] });
|
|
156
|
+
const output = await cli.readStdout().toLines(2000);
|
|
157
|
+
|
|
158
|
+
expect(output.join('\n')).toContain('Usage:');
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('handles JSON output', async () => {
|
|
162
|
+
cli.start({ command: 'node', args: ['./bin/cli.js', '--json'] });
|
|
163
|
+
const data = await cli.readStdout().toJson(2000);
|
|
164
|
+
|
|
165
|
+
expect(data).toHaveProperty('version');
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it('detects hung process', async () => {
|
|
169
|
+
const error = await new Promise((resolve) => {
|
|
170
|
+
cli.once('error', resolve);
|
|
171
|
+
cli.start(
|
|
172
|
+
{ command: 'node', args: ['-e', 'setTimeout(() => {}, 60000)'] },
|
|
173
|
+
3000 // 3s timeout
|
|
174
|
+
);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
expect(error.message).toBe('auto-exit timeout reached');
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## API Reference
|
|
183
|
+
|
|
184
|
+
### CliRunner
|
|
185
|
+
|
|
186
|
+
#### Methods
|
|
187
|
+
|
|
188
|
+
| Method | Parameters | Returns | Description |
|
|
189
|
+
|--------|-----------|---------|-------------|
|
|
190
|
+
| `start()` | `SpawnOptions`, `exitWaitTimeout?` | `this` | Spawn a child process. If `exitWaitTimeout` is set (ms), the process will auto-terminate if it doesn't exit within that time. |
|
|
191
|
+
| `write()` | `data: string` | `void` | Write to stdin without a newline. |
|
|
192
|
+
| `writeln()` | `data: string` | `void` | Write to stdin with a newline appended. |
|
|
193
|
+
| `readStdout()` | `timeout?: number` | `Promise<string>` \| `OutputHelper` | Read stdout buffer. With timeout arg, returns raw string. Without arg, returns helper with `.toLines()`, `.toJson()`, `.clear()` methods. |
|
|
194
|
+
| `readStderr()` | — | `string` | Get stderr buffer (non-blocking). |
|
|
195
|
+
| `sendCtrlC()` | `timeout?: number` | `Promise<void>` | Send SIGINT and wait for process exit. Falls back to SIGKILL on timeout. |
|
|
196
|
+
| `dispose()` | — | `void` | Force-kill process and release resources. |
|
|
197
|
+
|
|
198
|
+
#### Events
|
|
199
|
+
|
|
200
|
+
| Event | Callback Arguments | Description |
|
|
201
|
+
|-------|-------------------|-------------|
|
|
202
|
+
| `exit` | `{ code, signal }` | Process exited. |
|
|
203
|
+
| `stdout` | `chunk: string` | Data received on stdout. |
|
|
204
|
+
| `stderr` | `chunk: string` | Data received on stderr. |
|
|
205
|
+
| `error` | `err: Error` | Error occurred (e.g., auto-exit timeout). |
|
|
206
|
+
|
|
207
|
+
#### Types
|
|
208
|
+
|
|
209
|
+
```ts
|
|
210
|
+
type SpawnOptions = {
|
|
211
|
+
command?: string; // Required: command to execute
|
|
212
|
+
args?: string[]; // Command arguments
|
|
213
|
+
cwd?: string; // Working directory
|
|
214
|
+
env?: NodeJS.ProcessEnv; // Environment variables
|
|
215
|
+
};
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Project Structure
|
|
219
|
+
|
|
220
|
+
```
|
|
221
|
+
jest-runner-cli/
|
|
222
|
+
├── src/
|
|
223
|
+
│ ├── index.ts # Main entry point, Jest runner export
|
|
224
|
+
│ ├── run.ts # Jest runner implementation
|
|
225
|
+
│ └── CliRunner.ts # CliRunner class
|
|
226
|
+
├── test/unit/
|
|
227
|
+
│ └── cliRunner.test.ts # Unit tests
|
|
228
|
+
├── dist/ # Compiled output (generated)
|
|
229
|
+
├── jest.config.js # Jest configuration
|
|
230
|
+
├── tsconfig.json # TypeScript base config
|
|
231
|
+
├── tsconfig.build.json # TypeScript build config
|
|
232
|
+
└── package.json # Package metadata
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## Development
|
|
236
|
+
|
|
237
|
+
### Setup
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
git clone https://github.com/yourusername/jest-runner-cli.git
|
|
241
|
+
cd jest-runner-cli
|
|
242
|
+
npm install
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Common Commands
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
npm run build # Compile TypeScript
|
|
249
|
+
npm run test # Run tests
|
|
250
|
+
npm run lint # Check code quality
|
|
251
|
+
npm run type-check # Check TypeScript types
|
|
252
|
+
npm run docs # Generate TypeDoc documentation
|
|
253
|
+
npm run depcruise # Analyze dependencies
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Testing
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
# Run all tests
|
|
260
|
+
npm test
|
|
261
|
+
|
|
262
|
+
# Run specific test file
|
|
263
|
+
npm test -- cliRunner.test.ts
|
|
264
|
+
|
|
265
|
+
# Run with coverage
|
|
266
|
+
npm run test:ci
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## Technical Details
|
|
270
|
+
|
|
271
|
+
- **Runtime:** Node.js 18+, TypeScript 5.3+
|
|
272
|
+
- **Module Format:** ESM (ECMAScript Modules)
|
|
273
|
+
- **Jest Version:** 29.6.1+
|
|
274
|
+
- **Build:** TypeScript compiled to `dist/` folder
|
|
275
|
+
- **No Bundler:** Raw JS output, no webpack or similar
|
|
276
|
+
|
|
277
|
+
### Implementation Notes
|
|
278
|
+
|
|
279
|
+
- The Jest runner is built using `create-jest-runner` and delegates to Jest's core `runTest` function
|
|
280
|
+
- TypeScript is compiled with separate configs:
|
|
281
|
+
- `tsconfig.json` — development (no emit)
|
|
282
|
+
- `tsconfig.build.json` — build (emits to `dist/`)
|
|
283
|
+
- `CliRunner` is based on Node.js `child_process.spawn()` with event-driven stdout/stderr handling
|
|
284
|
+
- Auto-exit timeout uses `setTimeout` to detect hung processes and escalates from `SIGINT` to `SIGKILL`
|
|
285
|
+
|
|
286
|
+
## Troubleshooting
|
|
287
|
+
|
|
288
|
+
### Process Not Starting
|
|
289
|
+
|
|
290
|
+
**Error:** `No command provided`
|
|
291
|
+
|
|
292
|
+
```ts
|
|
293
|
+
// ❌ Wrong
|
|
294
|
+
runner.start({});
|
|
295
|
+
|
|
296
|
+
// ✅ Correct
|
|
297
|
+
runner.start({ command: 'node', args: ['script.js'] });
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Timeout Reading Output
|
|
301
|
+
|
|
302
|
+
**Error:** `stdout timeout`
|
|
303
|
+
|
|
304
|
+
Increase the timeout value:
|
|
305
|
+
|
|
306
|
+
```ts
|
|
307
|
+
// Default 2000ms, increase if needed
|
|
308
|
+
const output = await runner.readStdout().toLines(5000);
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### Process Still Running After sendCtrlC
|
|
312
|
+
|
|
313
|
+
On Windows, the process may not respond to SIGINT. The runner will auto-escalate to force-kill after timeout:
|
|
314
|
+
|
|
315
|
+
```ts
|
|
316
|
+
// Will escalate to taskkill after 2000ms
|
|
317
|
+
await runner.sendCtrlC();
|
|
318
|
+
|
|
319
|
+
// Or specify custom timeout
|
|
320
|
+
await runner.sendCtrlC(5000);
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
## Changelog
|
|
324
|
+
|
|
325
|
+
### v0.2.0 (Current)
|
|
326
|
+
|
|
327
|
+
- ✅ Refactored to ESM with `type: module`
|
|
328
|
+
- ✅ Integrated with `create-jest-runner` for Jest runner functionality
|
|
329
|
+
- ✅ Added comprehensive TypeScript type definitions
|
|
330
|
+
- ✅ Added auto-exit timeout feature for hung process detection
|
|
331
|
+
- ✅ Updated test suite with async/await patterns
|
|
332
|
+
|
|
333
|
+
### v0.1.0
|
|
334
|
+
|
|
335
|
+
- Initial release with basic `CliRunner` functionality
|
|
336
|
+
|
|
337
|
+
## License
|
|
338
|
+
|
|
339
|
+
MIT © 2026
|
|
340
|
+
|
|
341
|
+
## Contributing
|
|
342
|
+
|
|
343
|
+
Contributions are welcome! Please feel free to submit issues or pull requests.
|
|
344
|
+
|
|
345
|
+
For development, ensure:
|
|
346
|
+
- TypeScript strict mode is enabled
|
|
347
|
+
- All tests pass (`npm test`)
|
|
348
|
+
- Linting passes (`npm run lint`)
|
|
349
|
+
- New features include unit tests in `test/unit/`
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import { EventEmitter } from 'events';
|
|
4
|
+
/**
|
|
5
|
+
* Options describing how to spawn the child CLI process.
|
|
6
|
+
*/
|
|
7
|
+
export type SpawnOptions = {
|
|
8
|
+
command?: string;
|
|
9
|
+
args?: string[];
|
|
10
|
+
cwd?: string;
|
|
11
|
+
env?: NodeJS.ProcessEnv;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* CliRunner
|
|
15
|
+
*
|
|
16
|
+
* A small helper used in tests to spawn a child CLI process and read
|
|
17
|
+
* stdout/stderr conveniently. This is a near-direct extraction from the
|
|
18
|
+
* sample project and adapted to be a reusable library class.
|
|
19
|
+
*/
|
|
20
|
+
export declare class CliRunner extends EventEmitter {
|
|
21
|
+
private proc;
|
|
22
|
+
private stdoutBuffer;
|
|
23
|
+
private stdoutFragment;
|
|
24
|
+
private stdoutLines;
|
|
25
|
+
private stderrBuffer;
|
|
26
|
+
private _autoExitTimer;
|
|
27
|
+
/**
|
|
28
|
+
* 処理名: CliRunner 初期化
|
|
29
|
+
*
|
|
30
|
+
* 処理概要: イベントエミッタを初期化し、内部状態をセットアップする
|
|
31
|
+
*
|
|
32
|
+
* 実装理由: テスト用に子プロセスを制御するユーティリティとして振る舞うため
|
|
33
|
+
*/
|
|
34
|
+
constructor();
|
|
35
|
+
private exitWaitTimeout;
|
|
36
|
+
/**
|
|
37
|
+
* 処理名: 子プロセス起動
|
|
38
|
+
*
|
|
39
|
+
* 処理概要: 指定されたコマンドで子プロセスを spawn し、stdout/stderr を監視する
|
|
40
|
+
*
|
|
41
|
+
* 実装理由: テスト内で CLI を起動・操作し出力を検査するため
|
|
42
|
+
* @param {SpawnOptions} options - 起動オプション
|
|
43
|
+
* @param {number} exitWaitTimeout - 自動終了タイムアウト (ms)
|
|
44
|
+
* @returns {this} this インスタンス
|
|
45
|
+
*/
|
|
46
|
+
start(options?: SpawnOptions, exitWaitTimeout?: number): this;
|
|
47
|
+
/**
|
|
48
|
+
* stdout のハンドラを登録する
|
|
49
|
+
*/
|
|
50
|
+
private _attachStdoutHandler;
|
|
51
|
+
/**
|
|
52
|
+
* stderr のハンドラを登録する
|
|
53
|
+
*/
|
|
54
|
+
private _attachStderrHandler;
|
|
55
|
+
/**
|
|
56
|
+
* プロセスレベルのハンドラを登録する
|
|
57
|
+
*/
|
|
58
|
+
private _attachProcessHandlers;
|
|
59
|
+
/**
|
|
60
|
+
* 処理名: stdin 書き込み
|
|
61
|
+
*
|
|
62
|
+
* 処理概要: 子プロセスの stdin にデータを書き込む
|
|
63
|
+
* @param {string} data - 書き込む文字列
|
|
64
|
+
*/
|
|
65
|
+
write(data: string): void;
|
|
66
|
+
/**
|
|
67
|
+
* 処理名: stdin 書き込み(改行付き)
|
|
68
|
+
*
|
|
69
|
+
* 処理概要: 引数に改行を付与して stdin に書き込む
|
|
70
|
+
* @param {string} data - 書き込む文字列(改行は自動で追加される)
|
|
71
|
+
*/
|
|
72
|
+
writeln(data: string): void;
|
|
73
|
+
/**
|
|
74
|
+
* 処理名: stdout 一括取得
|
|
75
|
+
*
|
|
76
|
+
* 処理概要: キューされている stdout 行をまとめて返す。タイムアウト付き。
|
|
77
|
+
* @param {number} timeout - タイムアウト(ms)
|
|
78
|
+
* @returns {Promise<string>} キュー内の文字列(改行区切り)を返す Promise
|
|
79
|
+
*/
|
|
80
|
+
private _readStdoutOnce;
|
|
81
|
+
/**
|
|
82
|
+
* 処理名: stdout 1行取得
|
|
83
|
+
*
|
|
84
|
+
* 処理概要: キューから1行を取り出して返す。タイムアウト付き。
|
|
85
|
+
* @param {number} timeout - タイムアウト(ms)
|
|
86
|
+
* @returns {Promise<string>} キューの先頭行を返す Promise
|
|
87
|
+
*/
|
|
88
|
+
private _readStdoutLineOnce;
|
|
89
|
+
/**
|
|
90
|
+
* 処理名: stdout 内の JSON を探索して返す
|
|
91
|
+
* @param {number} timeout - 総タイムアウト(ms)
|
|
92
|
+
* @returns {Promise<unknown>} 見つかった JSON オブジェクト
|
|
93
|
+
*/
|
|
94
|
+
private _findJsonInStdout;
|
|
95
|
+
/**
|
|
96
|
+
* 処理名: 強制終了ユーティリティ
|
|
97
|
+
*
|
|
98
|
+
* 処理概要: タイムアウト時に子プロセスを強制終了する。Windows では `taskkill` を利用し、
|
|
99
|
+
* それ以外は `SIGKILL` を送る。
|
|
100
|
+
* @returns {Promise<void>} 終了を待機する Promise
|
|
101
|
+
*/
|
|
102
|
+
private _forceTerminate;
|
|
103
|
+
/**
|
|
104
|
+
* 処理名: stdout 取得ユーティリティ(オーバーロード)
|
|
105
|
+
*
|
|
106
|
+
* 処理概要: 引数を与えると一度にバッファを返す。引数を与えない場合は補助オブジェクトを返す。
|
|
107
|
+
* @returns `Promise<string>` または `toLines/toJson/clear` を持つヘルパオブジェクト
|
|
108
|
+
*/
|
|
109
|
+
/**
|
|
110
|
+
*
|
|
111
|
+
*/
|
|
112
|
+
readStdout(): {
|
|
113
|
+
toJson: (_timeout?: number) => Promise<unknown>;
|
|
114
|
+
toLines: (_timeout?: number) => Promise<string[]>;
|
|
115
|
+
clear: () => void;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* 処理名: stdout 一括取得(タイムアウト付き)
|
|
119
|
+
* @param timeout - タイムアウト(ms)
|
|
120
|
+
* @returns stdout 全体を表す Promise<string>
|
|
121
|
+
*/
|
|
122
|
+
readStdout(_timeout: number): Promise<string>;
|
|
123
|
+
/**
|
|
124
|
+
* 処理名: stderr 取得
|
|
125
|
+
*
|
|
126
|
+
* 処理概要: これまでに受信した stderr バッファを返す
|
|
127
|
+
* @returns {string} stderr バッファ文字列
|
|
128
|
+
*/
|
|
129
|
+
readStderr(): string;
|
|
130
|
+
/**
|
|
131
|
+
* 処理名: SIGINT 送信と終了待ち
|
|
132
|
+
*
|
|
133
|
+
* 処理概要: 子プロセスへ SIGINT を送信し、終了するまで待機する。タイムアウト時は強制終了を試みる
|
|
134
|
+
* @param {number} timeout - 待機タイムアウト(ms)
|
|
135
|
+
* @returns {Promise<void>} Promise<void>
|
|
136
|
+
*/
|
|
137
|
+
sendCtrlC(timeout?: number): Promise<void>;
|
|
138
|
+
/**
|
|
139
|
+
* 処理名: リソース解放
|
|
140
|
+
*
|
|
141
|
+
* 処理概要: 子プロセスが生存していれば終了させ、内部参照をクリアする
|
|
142
|
+
* @returns {void}
|
|
143
|
+
*/
|
|
144
|
+
dispose(): void;
|
|
145
|
+
}
|
|
146
|
+
export default CliRunner;
|
|
147
|
+
//# sourceMappingURL=CliRunner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CliRunner.d.ts","sourceRoot":"","sources":["../src/CliRunner.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IAEzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACzB,CAAC;AAEF;;;;;;GAMG;AACH,qBAAa,SAAU,SAAQ,YAAY;IACzC,OAAO,CAAC,IAAI,CAA+C;IAC3D,OAAO,CAAC,YAAY,CAAM;IAC1B,OAAO,CAAC,cAAc,CAAM;IAC5B,OAAO,CAAC,WAAW,CAAgB;IACnC,OAAO,CAAC,YAAY,CAAM;IAC1B,OAAO,CAAC,cAAc,CAA+B;IAErD;;;;;;OAMG;;IAKH,OAAO,CAAC,eAAe,CAAQ;IAE/B;;;;;;;;;OASG;IACH,KAAK,CAAC,OAAO,GAAE,YAAiB,EAAE,eAAe,CAAC,EAAE,MAAM;IAsC1D;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAgB5B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAQ5B;;OAEG;IACH,OAAO,CAAC,sBAAsB;IAc9B;;;;;OAKG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM;IAKlB;;;;;OAKG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM;IAIpB;;;;;;OAMG;IACH,OAAO,CAAC,eAAe;IAqCvB;;;;;;OAMG;IACH,OAAO,CAAC,mBAAmB;IA4B3B;;;;OAIG;YACW,iBAAiB;IAiB/B;;;;;;OAMG;IACH,OAAO,CAAC,eAAe;IAoBvB;;;;;OAKG;IAEH;;OAEG;IACH,UAAU,IAAI;QAAE,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;QAAC,OAAO,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;QAAC,KAAK,EAAE,MAAM,IAAI,CAAA;KAAE;IACvI;;;;OAIG;IACH,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAuC7C;;;;;OAKG;IACH,UAAU;IAIV;;;;;;OAMG;IACH,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAmD1C;;;;;OAKG;IACH,OAAO;CAUR;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
import { spawn } from 'child_process';
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
/**
|
|
4
|
+
* CliRunner
|
|
5
|
+
*
|
|
6
|
+
* A small helper used in tests to spawn a child CLI process and read
|
|
7
|
+
* stdout/stderr conveniently. This is a near-direct extraction from the
|
|
8
|
+
* sample project and adapted to be a reusable library class.
|
|
9
|
+
*/
|
|
10
|
+
export class CliRunner extends EventEmitter {
|
|
11
|
+
proc = null;
|
|
12
|
+
stdoutBuffer = '';
|
|
13
|
+
stdoutFragment = '';
|
|
14
|
+
stdoutLines = [];
|
|
15
|
+
stderrBuffer = '';
|
|
16
|
+
_autoExitTimer = null;
|
|
17
|
+
/**
|
|
18
|
+
* 処理名: CliRunner 初期化
|
|
19
|
+
*
|
|
20
|
+
* 処理概要: イベントエミッタを初期化し、内部状態をセットアップする
|
|
21
|
+
*
|
|
22
|
+
* 実装理由: テスト用に子プロセスを制御するユーティリティとして振る舞うため
|
|
23
|
+
*/
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
}
|
|
27
|
+
exitWaitTimeout = 2000;
|
|
28
|
+
/**
|
|
29
|
+
* 処理名: 子プロセス起動
|
|
30
|
+
*
|
|
31
|
+
* 処理概要: 指定されたコマンドで子プロセスを spawn し、stdout/stderr を監視する
|
|
32
|
+
*
|
|
33
|
+
* 実装理由: テスト内で CLI を起動・操作し出力を検査するため
|
|
34
|
+
* @param {SpawnOptions} options - 起動オプション
|
|
35
|
+
* @param {number} exitWaitTimeout - 自動終了タイムアウト (ms)
|
|
36
|
+
* @returns {this} this インスタンス
|
|
37
|
+
*/
|
|
38
|
+
start(options = {}, exitWaitTimeout) {
|
|
39
|
+
if (this.proc)
|
|
40
|
+
throw new Error('process already started');
|
|
41
|
+
const cwd = options.cwd || process.cwd();
|
|
42
|
+
let command;
|
|
43
|
+
let args;
|
|
44
|
+
if (options.command) {
|
|
45
|
+
command = options.command;
|
|
46
|
+
args = options.args || [];
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
throw new Error('No command provided. CliRunner.start requires options.command to be set.');
|
|
50
|
+
}
|
|
51
|
+
const childEnv = options.env ? options.env : process.env;
|
|
52
|
+
this.proc = spawn(command, args, {
|
|
53
|
+
cwd,
|
|
54
|
+
env: childEnv,
|
|
55
|
+
stdio: 'pipe',
|
|
56
|
+
});
|
|
57
|
+
// stdout / stderr / process イベントを設定
|
|
58
|
+
this._attachStdoutHandler();
|
|
59
|
+
this._attachStderrHandler();
|
|
60
|
+
this._attachProcessHandlers();
|
|
61
|
+
if (typeof exitWaitTimeout === 'number') {
|
|
62
|
+
this.exitWaitTimeout = exitWaitTimeout;
|
|
63
|
+
this._autoExitTimer = setTimeout(() => {
|
|
64
|
+
if (this.proc) {
|
|
65
|
+
this.emit('error', new Error('auto-exit timeout reached'));
|
|
66
|
+
this.sendCtrlC().catch(() => { });
|
|
67
|
+
}
|
|
68
|
+
}, this.exitWaitTimeout);
|
|
69
|
+
}
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* stdout のハンドラを登録する
|
|
74
|
+
*/
|
|
75
|
+
_attachStdoutHandler() {
|
|
76
|
+
if (!this.proc)
|
|
77
|
+
return;
|
|
78
|
+
this.proc.stdout.setEncoding('utf8');
|
|
79
|
+
this.proc.stdout.on('data', (chunk) => {
|
|
80
|
+
this.stdoutBuffer += chunk;
|
|
81
|
+
this.stdoutFragment += chunk;
|
|
82
|
+
const parts = this.stdoutFragment.split('\n');
|
|
83
|
+
this.stdoutFragment = parts.pop() || '';
|
|
84
|
+
for (const p of parts) {
|
|
85
|
+
const line = p.trim();
|
|
86
|
+
if (line)
|
|
87
|
+
this.stdoutLines.push(line);
|
|
88
|
+
}
|
|
89
|
+
this.emit('stdout', chunk);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* stderr のハンドラを登録する
|
|
94
|
+
*/
|
|
95
|
+
_attachStderrHandler() {
|
|
96
|
+
if (!this.proc)
|
|
97
|
+
return;
|
|
98
|
+
this.proc.stderr.on('data', (chunk) => {
|
|
99
|
+
this.stderrBuffer += chunk;
|
|
100
|
+
this.emit('stderr', chunk);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* プロセスレベルのハンドラを登録する
|
|
105
|
+
*/
|
|
106
|
+
_attachProcessHandlers() {
|
|
107
|
+
if (!this.proc)
|
|
108
|
+
return;
|
|
109
|
+
this.proc.on('exit', (code, signal) => {
|
|
110
|
+
this.emit('exit', { code, signal });
|
|
111
|
+
this.proc = null;
|
|
112
|
+
if (this._autoExitTimer) {
|
|
113
|
+
clearTimeout(this._autoExitTimer);
|
|
114
|
+
this._autoExitTimer = null;
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
this.proc.on('error', (err) => this.emit('error', err));
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* 処理名: stdin 書き込み
|
|
121
|
+
*
|
|
122
|
+
* 処理概要: 子プロセスの stdin にデータを書き込む
|
|
123
|
+
* @param {string} data - 書き込む文字列
|
|
124
|
+
*/
|
|
125
|
+
write(data) {
|
|
126
|
+
if (!this.proc || !this.proc.stdin.writable)
|
|
127
|
+
throw new Error('process not started or stdin not writable');
|
|
128
|
+
this.proc.stdin.write(data);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* 処理名: stdin 書き込み(改行付き)
|
|
132
|
+
*
|
|
133
|
+
* 処理概要: 引数に改行を付与して stdin に書き込む
|
|
134
|
+
* @param {string} data - 書き込む文字列(改行は自動で追加される)
|
|
135
|
+
*/
|
|
136
|
+
writeln(data) {
|
|
137
|
+
this.write(data + '\n');
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* 処理名: stdout 一括取得
|
|
141
|
+
*
|
|
142
|
+
* 処理概要: キューされている stdout 行をまとめて返す。タイムアウト付き。
|
|
143
|
+
* @param {number} timeout - タイムアウト(ms)
|
|
144
|
+
* @returns {Promise<string>} キュー内の文字列(改行区切り)を返す Promise
|
|
145
|
+
*/
|
|
146
|
+
_readStdoutOnce(timeout = 2000) {
|
|
147
|
+
if (this.stdoutLines.length > 0) {
|
|
148
|
+
const out = this.stdoutLines.join('\n');
|
|
149
|
+
this.stdoutLines = [];
|
|
150
|
+
return Promise.resolve(out);
|
|
151
|
+
}
|
|
152
|
+
if (!this.proc)
|
|
153
|
+
return Promise.reject(new Error('stdout timeout'));
|
|
154
|
+
return new Promise((resolve, reject) => {
|
|
155
|
+
if (this.stdoutLines.length > 0) {
|
|
156
|
+
const out = this.stdoutLines.join('\n');
|
|
157
|
+
this.stdoutLines = [];
|
|
158
|
+
return resolve(out);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
*
|
|
162
|
+
*/
|
|
163
|
+
const onData = () => {
|
|
164
|
+
if (this.stdoutLines.length > 0) {
|
|
165
|
+
this.removeListener('stdout', onData);
|
|
166
|
+
clearTimeout(t);
|
|
167
|
+
const out = this.stdoutLines.join('\n');
|
|
168
|
+
this.stdoutLines = [];
|
|
169
|
+
resolve(out);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
const t = setTimeout(() => {
|
|
173
|
+
this.removeListener('stdout', onData);
|
|
174
|
+
this.stdoutLines = [];
|
|
175
|
+
reject(new Error('stdout timeout'));
|
|
176
|
+
}, timeout);
|
|
177
|
+
this.on('stdout', onData);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* 処理名: stdout 1行取得
|
|
182
|
+
*
|
|
183
|
+
* 処理概要: キューから1行を取り出して返す。タイムアウト付き。
|
|
184
|
+
* @param {number} timeout - タイムアウト(ms)
|
|
185
|
+
* @returns {Promise<string>} キューの先頭行を返す Promise
|
|
186
|
+
*/
|
|
187
|
+
_readStdoutLineOnce(timeout = 2000) {
|
|
188
|
+
if (this.stdoutLines.length > 0) {
|
|
189
|
+
return Promise.resolve(this.stdoutLines.shift());
|
|
190
|
+
}
|
|
191
|
+
if (!this.proc)
|
|
192
|
+
return Promise.reject(new Error('stdout line timeout'));
|
|
193
|
+
return new Promise((resolve, reject) => {
|
|
194
|
+
if (this.stdoutLines.length > 0)
|
|
195
|
+
return resolve(this.stdoutLines.shift());
|
|
196
|
+
/**
|
|
197
|
+
*
|
|
198
|
+
*/
|
|
199
|
+
const onData = () => {
|
|
200
|
+
if (this.stdoutLines.length > 0) {
|
|
201
|
+
this.removeListener('stdout', onData);
|
|
202
|
+
clearTimeout(t);
|
|
203
|
+
resolve(this.stdoutLines.shift());
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
const t = setTimeout(() => {
|
|
207
|
+
this.removeListener('stdout', onData);
|
|
208
|
+
reject(new Error('stdout line timeout'));
|
|
209
|
+
}, timeout);
|
|
210
|
+
this.on('stdout', onData);
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* 処理名: stdout 内の JSON を探索して返す
|
|
215
|
+
* @param {number} timeout - 総タイムアウト(ms)
|
|
216
|
+
* @returns {Promise<unknown>} 見つかった JSON オブジェクト
|
|
217
|
+
*/
|
|
218
|
+
async _findJsonInStdout(timeout) {
|
|
219
|
+
const deadline = Date.now() + timeout;
|
|
220
|
+
while (Date.now() < deadline) {
|
|
221
|
+
const remaining = Math.max(0, deadline - Date.now());
|
|
222
|
+
const line = await this._readStdoutLineOnce(remaining);
|
|
223
|
+
if (!line)
|
|
224
|
+
break;
|
|
225
|
+
try {
|
|
226
|
+
const obj = JSON.parse(line);
|
|
227
|
+
if (obj)
|
|
228
|
+
return obj;
|
|
229
|
+
}
|
|
230
|
+
catch (_e) {
|
|
231
|
+
// 継続して次の行を探す
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
throw new Error('no JSON found in stdout within timeout');
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* 処理名: 強制終了ユーティリティ
|
|
239
|
+
*
|
|
240
|
+
* 処理概要: タイムアウト時に子プロセスを強制終了する。Windows では `taskkill` を利用し、
|
|
241
|
+
* それ以外は `SIGKILL` を送る。
|
|
242
|
+
* @returns {Promise<void>} 終了を待機する Promise
|
|
243
|
+
*/
|
|
244
|
+
_forceTerminate() {
|
|
245
|
+
if (!this.proc)
|
|
246
|
+
return Promise.resolve();
|
|
247
|
+
if (process.platform === 'win32') {
|
|
248
|
+
return new Promise((resolve) => {
|
|
249
|
+
const tk = spawn('taskkill', ['/PID', String(this.proc.pid), '/T', '/F']);
|
|
250
|
+
tk.on('close', () => {
|
|
251
|
+
resolve();
|
|
252
|
+
});
|
|
253
|
+
tk.on('error', () => resolve());
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
try {
|
|
257
|
+
this.proc.kill('SIGKILL');
|
|
258
|
+
}
|
|
259
|
+
catch (_e) {
|
|
260
|
+
// ignore
|
|
261
|
+
}
|
|
262
|
+
return Promise.resolve();
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* @param {number} timeout - 省略時はヘルパを返す
|
|
266
|
+
* @returns {unknown} ヘルパオブジェクトまたは Promise<string>
|
|
267
|
+
*/
|
|
268
|
+
readStdout(timeout) {
|
|
269
|
+
if (typeof timeout === 'number')
|
|
270
|
+
return this._readStdoutOnce(timeout);
|
|
271
|
+
return {
|
|
272
|
+
/**
|
|
273
|
+
* 処理名: stdout を行単位で取得
|
|
274
|
+
* @param {number} t - タイムアウト(ms)
|
|
275
|
+
* @returns {Promise<string[]>} 行配列の Promise
|
|
276
|
+
*/
|
|
277
|
+
toLines: async (t = 2000) => {
|
|
278
|
+
const buf = await this._readStdoutOnce(t);
|
|
279
|
+
if (!buf)
|
|
280
|
+
return [];
|
|
281
|
+
return buf.split('\n').map((s) => s.trim()).filter(Boolean);
|
|
282
|
+
},
|
|
283
|
+
/**
|
|
284
|
+
* 処理名: stdout から JSON 行を探して返す
|
|
285
|
+
* @param {number} t - 総タイムアウト(ms)
|
|
286
|
+
* @returns {Promise<unknown>} 見つかった JSON オブジェクトを返す Promise
|
|
287
|
+
*/
|
|
288
|
+
toJson: async (t = 2000) => {
|
|
289
|
+
return this._findJsonInStdout(t);
|
|
290
|
+
},
|
|
291
|
+
/**
|
|
292
|
+
* 処理名: stdout バッファクリア
|
|
293
|
+
*/
|
|
294
|
+
clear: () => {
|
|
295
|
+
this.stdoutLines = [];
|
|
296
|
+
this.stdoutFragment = '';
|
|
297
|
+
this.stdoutBuffer = '';
|
|
298
|
+
},
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
/* eslint-enable no-unused-vars */
|
|
302
|
+
/**
|
|
303
|
+
* 処理名: stderr 取得
|
|
304
|
+
*
|
|
305
|
+
* 処理概要: これまでに受信した stderr バッファを返す
|
|
306
|
+
* @returns {string} stderr バッファ文字列
|
|
307
|
+
*/
|
|
308
|
+
readStderr() {
|
|
309
|
+
return this.stderrBuffer;
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* 処理名: SIGINT 送信と終了待ち
|
|
313
|
+
*
|
|
314
|
+
* 処理概要: 子プロセスへ SIGINT を送信し、終了するまで待機する。タイムアウト時は強制終了を試みる
|
|
315
|
+
* @param {number} timeout - 待機タイムアウト(ms)
|
|
316
|
+
* @returns {Promise<void>} Promise<void>
|
|
317
|
+
*/
|
|
318
|
+
sendCtrlC(timeout) {
|
|
319
|
+
const wait = typeof timeout === 'number' ? timeout : this.exitWaitTimeout;
|
|
320
|
+
return new Promise((resolve, reject) => {
|
|
321
|
+
if (!this.proc)
|
|
322
|
+
return resolve();
|
|
323
|
+
/**
|
|
324
|
+
*
|
|
325
|
+
*/
|
|
326
|
+
const onExit = () => {
|
|
327
|
+
clearTimeout(to);
|
|
328
|
+
this.removeListener('error', onError);
|
|
329
|
+
resolve();
|
|
330
|
+
};
|
|
331
|
+
/**
|
|
332
|
+
* エラーハンドラ
|
|
333
|
+
* @param {unknown} e - 発生したエラー
|
|
334
|
+
*/
|
|
335
|
+
const onError = (e) => {
|
|
336
|
+
clearTimeout(to);
|
|
337
|
+
this.removeListener('exit', onExit);
|
|
338
|
+
reject(e);
|
|
339
|
+
};
|
|
340
|
+
const to = setTimeout(async () => {
|
|
341
|
+
try {
|
|
342
|
+
await this._forceTerminate();
|
|
343
|
+
resolve();
|
|
344
|
+
}
|
|
345
|
+
catch (e) {
|
|
346
|
+
reject(e);
|
|
347
|
+
}
|
|
348
|
+
}, wait);
|
|
349
|
+
this.once('exit', onExit);
|
|
350
|
+
this.once('error', onError);
|
|
351
|
+
try {
|
|
352
|
+
this.proc.stdin.end();
|
|
353
|
+
}
|
|
354
|
+
catch (_e) {
|
|
355
|
+
// ignore
|
|
356
|
+
}
|
|
357
|
+
try {
|
|
358
|
+
this.proc.kill('SIGINT');
|
|
359
|
+
}
|
|
360
|
+
catch (_e) {
|
|
361
|
+
// ignore
|
|
362
|
+
}
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* 処理名: リソース解放
|
|
367
|
+
*
|
|
368
|
+
* 処理概要: 子プロセスが生存していれば終了させ、内部参照をクリアする
|
|
369
|
+
* @returns {void}
|
|
370
|
+
*/
|
|
371
|
+
dispose() {
|
|
372
|
+
if (!this.proc)
|
|
373
|
+
return;
|
|
374
|
+
try {
|
|
375
|
+
this.proc.kill();
|
|
376
|
+
}
|
|
377
|
+
catch (_e) {
|
|
378
|
+
// ignore
|
|
379
|
+
}
|
|
380
|
+
this.proc = null;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
export default CliRunner;
|
|
384
|
+
//# sourceMappingURL=CliRunner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CliRunner.js","sourceRoot":"","sources":["../src/CliRunner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAatC;;;;;;GAMG;AACH,MAAM,OAAO,SAAU,SAAQ,YAAY;IACjC,IAAI,GAA0C,IAAI,CAAC;IACnD,YAAY,GAAG,EAAE,CAAC;IAClB,cAAc,GAAG,EAAE,CAAC;IACpB,WAAW,GAAa,EAAE,CAAC;IAC3B,YAAY,GAAG,EAAE,CAAC;IAClB,cAAc,GAA0B,IAAI,CAAC;IAErD;;;;;;OAMG;IACH;QACE,KAAK,EAAE,CAAC;IACV,CAAC;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AAC;YAC7C,CAAC;YAAC,OAAO,EAAW,EAAE,CAAC;gBACrB,SAAS;YACX,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,OAAO;QACL,IAAI,CAAC,IAAI,CAAC,IAAI;YAAE,OAAO;QACvB,IAAI,CAAC;YACH,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACnB,CAAC;QAAC,OAAO,EAAW,EAAE,CAAC;YACrB,SAAS;QACX,CAAC;QACD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CAEF;AAED,eAAe,SAAS,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,CAAC;AACrB,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAInD,QAAA,MAAM,aAAa,SAA4B,CAAC;AAEhD,eAAe,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import createJestRunner from 'create-jest-runner';
|
|
2
|
+
import { CliRunner } from './CliRunner.js';
|
|
3
|
+
export { CliRunner };
|
|
4
|
+
const runPath = new URL('./run.js', import.meta.url).pathname;
|
|
5
|
+
const JestRunnerCli = createJestRunner(runPath);
|
|
6
|
+
export default JestRunnerCli;
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,CAAC;AAGrB,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC;AAE9D,MAAM,aAAa,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;AAEhD,eAAe,aAAa,CAAC"}
|
package/dist/run.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Config } from '@jest/types';
|
|
2
|
+
import type { JestEnvironment } from '@jest/environment';
|
|
3
|
+
import type Runtime from 'jest-runtime';
|
|
4
|
+
/**
|
|
5
|
+
* Jest runner entry point that delegates to the core runTest helper.
|
|
6
|
+
* @param {Config.GlobalConfig} globalConfig - Jest global configuration.
|
|
7
|
+
* @param {Config.ProjectConfig} projectConfig - Project-specific configuration.
|
|
8
|
+
* @param {JestEnvironment} environment - Jest test environment instance.
|
|
9
|
+
* @param {Runtime} runtime - Jest runtime used to execute the test.
|
|
10
|
+
* @param {string} testPath - Path to the test file.
|
|
11
|
+
* @returns {Promise<unknown>} Execution result from runTest.
|
|
12
|
+
*/
|
|
13
|
+
export default function run(globalConfig: Config.GlobalConfig, projectConfig: Config.ProjectConfig, environment: JestEnvironment, runtime: Runtime, testPath: string): Promise<unknown>;
|
|
14
|
+
//# sourceMappingURL=run.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAGxC;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,GAAG,CACzB,YAAY,EAAE,MAAM,CAAC,YAAY,EACjC,aAAa,EAAE,MAAM,CAAC,aAAa,EACnC,WAAW,EAAE,eAAe,EAC5B,OAAO,EAAE,OAAO,EAChB,QAAQ,EAAE,MAAM,oBAGjB"}
|
package/dist/run.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import runTest from 'jest-runner/build/runTest.js';
|
|
2
|
+
/**
|
|
3
|
+
* Jest runner entry point that delegates to the core runTest helper.
|
|
4
|
+
* @param {Config.GlobalConfig} globalConfig - Jest global configuration.
|
|
5
|
+
* @param {Config.ProjectConfig} projectConfig - Project-specific configuration.
|
|
6
|
+
* @param {JestEnvironment} environment - Jest test environment instance.
|
|
7
|
+
* @param {Runtime} runtime - Jest runtime used to execute the test.
|
|
8
|
+
* @param {string} testPath - Path to the test file.
|
|
9
|
+
* @returns {Promise<unknown>} Execution result from runTest.
|
|
10
|
+
*/
|
|
11
|
+
export default function run(globalConfig, projectConfig, environment, runtime, testPath) {
|
|
12
|
+
return runTest(testPath, globalConfig, projectConfig, environment, runtime);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=run.js.map
|
package/dist/run.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run.js","sourceRoot":"","sources":["../src/run.ts"],"names":[],"mappings":"AAGA,OAAO,OAAO,MAAM,8BAA8B,CAAC;AAEnD;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,UAAU,GAAG,CACzB,YAAiC,EACjC,aAAmC,EACnC,WAA4B,EAC5B,OAAgB,EAChB,QAAgB;IAEhB,OAAO,OAAO,CAAC,QAAQ,EAAE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AAC9E,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "jest-runner-cli",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "Jest custom runner for CLI workflows with a minimal CliRunner helper",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./dist/index.js",
|
|
9
|
+
"./run": "./dist/run.js",
|
|
10
|
+
"./CliRunner": "./dist/CliRunner.js"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"package.json",
|
|
15
|
+
"README.md",
|
|
16
|
+
"LICENSE"
|
|
17
|
+
],
|
|
18
|
+
"type": "module",
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "tsc -p tsconfig.build.json",
|
|
21
|
+
"type-check": "tsc --noEmit",
|
|
22
|
+
"test": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js",
|
|
23
|
+
"test:ci": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --coverage",
|
|
24
|
+
"lint": "eslint . --ext .ts",
|
|
25
|
+
"depcruise": "depcruise --config .dependency-cruiser.cjs src",
|
|
26
|
+
"docs": "typedoc --options typedoc.json"
|
|
27
|
+
},
|
|
28
|
+
"keywords": ["cli", "runner", "test", "jest"],
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/gutyoh/jest-runner-cli.git"
|
|
32
|
+
},
|
|
33
|
+
"bugs": {
|
|
34
|
+
"url": "https://github.com/gutyoh/jest-runner-cli/issues"
|
|
35
|
+
},
|
|
36
|
+
"homepage": "https://github.com/gutyoh/jest-runner-cli#readme",
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"peerDependencies": {
|
|
39
|
+
"jest": "^29.6.1"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/jest": "^29.5.2",
|
|
43
|
+
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
44
|
+
"@typescript-eslint/parser": "^6.0.0",
|
|
45
|
+
"dependency-cruiser": "^17.3.5",
|
|
46
|
+
"eslint": "^8.45.0",
|
|
47
|
+
"eslint-plugin-jsdoc": "^46.0.0",
|
|
48
|
+
"eslint-plugin-sonarjs": "^0.19.0",
|
|
49
|
+
"jest": "^29.6.1",
|
|
50
|
+
"ts-jest": "^29.1.0",
|
|
51
|
+
"typedoc": "^0.28.0",
|
|
52
|
+
"typedoc-plugin-markdown": "^4.8.0",
|
|
53
|
+
"typescript": "5.3.3"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"create-jest-runner": "^1.0.0",
|
|
57
|
+
"jest-runner": "^29.6.1"
|
|
58
|
+
}
|
|
59
|
+
}
|