Skip to content

Commit 84a7f25

Browse files
committed
modify cli options and API in README
1 parent a61ef39 commit 84a7f25

File tree

10 files changed

+522
-350
lines changed

10 files changed

+522
-350
lines changed

README.md

Lines changed: 345 additions & 230 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"scripts": {
2525
"build": "tsc --build",
2626
"postbuild": "chmod +x dist/bin/concurrently.js",
27+
"generate:doc:api": "ts-readme --header-depth 3 src/concurrently.ts ",
2728
"clean": "tsc --build --clean",
2829
"format": "prettier --check '**/*.{json,y?(a)ml,md}'",
2930
"format:fix": "pnpm run format --write",
@@ -88,6 +89,7 @@
8889
"prettier": "^3.0.3",
8990
"safe-publish-latest": "^2.0.0",
9091
"string-argv": "^0.3.2",
92+
"ts-readme": "^1.1.3",
9193
"typescript": "~5.2.2"
9294
},
9395
"files": [

pnpm-lock.yaml

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

src/command.ts

Lines changed: 16 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,39 @@ import { ChildProcess as BaseChildProcess, SpawnOptions } from 'child_process';
22
import * as Rx from 'rxjs';
33
import { EventEmitter, Writable } from 'stream';
44

5-
/**
6-
* Identifier for a command; if string, it's the command's name, if number, it's the index.
7-
*/
5+
/** Identifier for a command; if string, it's the command's name, if number, it's the index.*/
86
export type CommandIdentifier = string | number;
97

108
export interface CommandInfo {
11-
/**
12-
* Command's name.
13-
*/
9+
/** Command's name. */
1410
name: string;
1511

16-
/**
17-
* Which command line the command has.
18-
*/
12+
/** Which command line the command has. */
1913
command: string;
2014

21-
/**
22-
* Which environment variables should the spawned process have.
23-
*/
15+
/** Which environment variables should the spawned process have.*/
2416
env?: Record<string, unknown>;
2517

26-
/**
27-
* The current working directory of the process when spawned.
28-
*/
18+
/** The current working directory of the process when spawned.*/
2919
cwd?: string;
3020

31-
/**
32-
* Color to use on prefix of the command.
33-
*/
21+
/** Color to use on prefix of the command.*/
3422
prefixColor?: string;
3523

36-
/**
37-
* Output command in raw format.
38-
*/
24+
/** Output command in raw format.*/
3925
raw?: boolean;
4026
}
4127

4228
export interface CloseEvent {
4329
command: CommandInfo;
4430

45-
/**
46-
* The command's index among all commands ran.
47-
*/
31+
/** The command's index among all commands ran.*/
4832
index: number;
4933

50-
/**
51-
* Whether the command exited because it was killed.
52-
*/
34+
/** Whether the command exited because it was killed.*/
5335
killed: boolean;
5436

55-
/**
56-
* The exit code or signal for the command.
57-
*/
37+
/** The exit code or signal for the command.*/
5838
exitCode: string | number;
5939
timings: {
6040
startDate: Date;
@@ -68,20 +48,14 @@ export interface TimerEvent {
6848
endDate?: Date;
6949
}
7050

71-
/**
72-
* Subtype of NodeJS's child_process including only what's actually needed for a command to work.
73-
*/
51+
/** Subtype of NodeJS's child_process including only what's actually needed for a command to work. */
7452
export type ChildProcess = EventEmitter &
7553
Pick<BaseChildProcess, 'pid' | 'stdin' | 'stdout' | 'stderr'>;
7654

77-
/**
78-
* Interface for a function that must kill the process with `pid`, optionally sending `signal` to it.
79-
*/
55+
/** Interface for a function that must kill the process with `pid`, optionally sending `signal` to it. */
8056
export type KillProcess = (pid: number, signal?: string) => void;
8157

82-
/**
83-
* Interface for a function that spawns a command and returns its child process instance.
84-
*/
58+
/** Interface for a function that spawns a command and returns its child process instance. */
8559
export type SpawnCommand = (command: string, options: SpawnOptions) => ChildProcess;
8660

8761
export class Command implements CommandInfo {
@@ -139,9 +113,7 @@ export class Command implements CommandInfo {
139113
this.spawnOpts = spawnOpts;
140114
}
141115

142-
/**
143-
* Starts this command, piping output, error and close events onto the corresponding observables.
144-
*/
116+
/** Starts this command, piping output, error and close events onto the corresponding observables. */
145117
start() {
146118
const child = this.spawn(this.command, this.spawnOpts);
147119
this.process = child;
@@ -190,9 +162,7 @@ export class Command implements CommandInfo {
190162
this.stdin = child.stdin || undefined;
191163
}
192164

193-
/**
194-
* Kills this command, optionally specifying a signal to send to it.
195-
*/
165+
/** Kills this command, optionally specifying a signal to send to it. */
196166
kill(code?: string) {
197167
if (Command.canKill(this)) {
198168
this.killed = true;
@@ -210,9 +180,7 @@ export class Command implements CommandInfo {
210180
}
211181
}
212182

213-
/**
214-
* Pipes all events emitted by `stream` into `subject`.
215-
*/
183+
/** Pipes all events emitted by `stream` into `subject`.s */
216184
function pipeTo<T>(stream: Rx.Observable<T>, subject: Rx.Subject<T>) {
217185
stream.subscribe((event) => subject.next(event));
218186
}

0 commit comments

Comments
 (0)