Skip to content

Commit

Permalink
revert modified comments in codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarektouati committed Oct 21, 2023
1 parent c594afa commit af9993f
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 40 deletions.
64 changes: 48 additions & 16 deletions src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,59 @@ import { ChildProcess as BaseChildProcess, SpawnOptions } from 'child_process';
import * as Rx from 'rxjs';
import { EventEmitter, Writable } from 'stream';

/** Identifier for a command; if string, it's the command's name, if number, it's the index.*/
/**
* Identifier for a command; if string, it's the command's name, if number, it's the index.
*/
export type CommandIdentifier = string | number;

export interface CommandInfo {
/** Command's name. */
/**
* Command's name.
*/
name: string;

/** Which command line the command has. */
/**
* Which command line the command has.
*/
command: string;

/** Which environment variables should the spawned process have.*/
/**
* Which environment variables should the spawned process have.
*/
env?: Record<string, unknown>;

/** The current working directory of the process when spawned.*/
/**
* The current working directory of the process when spawned.
*/
cwd?: string;

/** Color to use on prefix of the command.*/
/**
* Color to use on prefix of the command.
*/
prefixColor?: string;

/** Output command in raw format.*/
/**
* Output command in raw format.
*/
raw?: boolean;
}

export interface CloseEvent {
command: CommandInfo;

/** The command's index among all commands ran.*/
/**
* The command's index among all commands ran.
*/
index: number;

/** Whether the command exited because it was killed.*/
/**
* Whether the command exited because it was killed.
*/
killed: boolean;

/** The exit code or signal for the command.*/
/**
* The exit code or signal for the command.
*/
exitCode: string | number;
timings: {
startDate: Date;
Expand All @@ -48,14 +68,20 @@ export interface TimerEvent {
endDate?: Date;
}

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

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

/** Interface for a function that spawns a command and returns its child process instance. */
/**
* Interface for a function that spawns a command and returns its child process instance.
*/
export type SpawnCommand = (command: string, options: SpawnOptions) => ChildProcess;

export class Command implements CommandInfo {
Expand Down Expand Up @@ -113,7 +139,9 @@ export class Command implements CommandInfo {
this.spawnOpts = spawnOpts;
}

/** Starts this command, piping output, error and close events onto the corresponding observables. */
/**
* Starts this command, piping output, error and close events onto the corresponding observables.
*/
start() {
const child = this.spawn(this.command, this.spawnOpts);
this.process = child;
Expand Down Expand Up @@ -162,7 +190,9 @@ export class Command implements CommandInfo {
this.stdin = child.stdin || undefined;
}

/** Kills this command, optionally specifying a signal to send to it. */
/**
* Kills this command, optionally specifying a signal to send to it.
*/
kill(code?: string) {
if (Command.canKill(this)) {
this.killed = true;
Expand All @@ -180,7 +210,9 @@ export class Command implements CommandInfo {
}
}

/** Pipes all events emitted by `stream` into `subject`.s */
/**
* Pipes all events emitted by `stream` into `subject`.
*/
function pipeTo<T>(stream: Rx.Observable<T>, subject: Rx.Subject<T>) {
stream.subscribe((event) => subject.next(event));
}
8 changes: 6 additions & 2 deletions src/completion-listener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ export type SuccessCondition =
| `command-${string | number}`
| `!command-${string | number}`;

/** Provides logic to determine whether lists of commands ran successfully. */
/**
* Provides logic to determine whether lists of commands ran successfully.
*/
export class CompletionListener {
private readonly successCondition: SuccessCondition;
private readonly scheduler?: Rx.SchedulerLike;
Expand All @@ -36,7 +38,9 @@ export class CompletionListener {
*/
successCondition?: SuccessCondition;

/** For testing only.*/
/**
* For testing only.
*/
scheduler?: Rx.SchedulerLike;
}) {
this.successCondition = successCondition;
Expand Down
12 changes: 9 additions & 3 deletions src/concurrently.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ const defaults: ConcurrentlyOptions = {
export type ConcurrentlyCommandInput = string | ({ command: string } & Partial<CommandInfo>);

export type ConcurrentlyResult = {
/** All commands created and ran by concurrently.*/
/**
* All commands created and ran by concurrently.
*/
commands: Command[];

/**
Expand All @@ -49,10 +51,14 @@ export type ConcurrentlyResult = {
export type ConcurrentlyOptions = {
logger?: Logger;

/** Which stream should the commands output be written to. */
/**
* Which stream should the commands output be written to.
*/
outputStream?: Writable;

/** Whether the output should be ordered as if the commands were run sequentially.*/
/**
* Whether the output should be ordered as if the commands were run sequentially.
*/
group?: boolean;

/**
Expand Down
44 changes: 33 additions & 11 deletions src/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,29 @@ import { SuccessCondition } from './completion-listener';

export const defaultInputTarget = 0;

/** Whether process.stdin should be forwarded to child processes. */
/**
* Whether process.stdin should be forwarded to child processes.
*/
export const handleInput = false;

/** How many processes to run at once. */
/**
* How many processes to run at once.
*/
export const maxProcesses = 0;

/** Indices and names of commands whose output are not to be logged. */
/**
* Indices and names of commands whose output are not to be logged.
*/
export const hide = '';

/** The character to split <names> on.*/
/**
* The character to split <names> on.
*/
export const nameSeparator = ',';

/** Which prefix style to use when logging processes output.*/
/**
* Which prefix style to use when logging processes output.
*/
export const prefix = '';

/**
Expand All @@ -27,18 +37,26 @@ export const prefix = '';
*/
export const prefixColors = 'reset';

/** How many bytes we'll show on the command prefix.*/
/**
* How many bytes we'll show on the command prefix.
*/
export const prefixLength = 10;

export const raw = false;

/** Number of attempts of restarting a process, if it exits with non-0 code. */
/**
* Number of attempts of restarting a process, if it exits with non-0 code.
*/
export const restartTries = 0;

/** How many milliseconds concurrently should wait before restarting a process. */
/**
* How many milliseconds concurrently should wait before restarting a process.
*/
export const restartDelay = 0;

/** Condition of success for concurrently itself. */
/**
* Condition of success for concurrently itself.
*/
export const success = 'all' as SuccessCondition;

/**
Expand All @@ -53,10 +71,14 @@ export const timestampFormat = 'yyyy-MM-dd HH:mm:ss.SSS';
*/
export const cwd: string | undefined = undefined;

/** Whether to show timing information for processes in console output. */
/**
* Whether to show timing information for processes in console output.
*/
export const timings = false;

/** Passthrough additional arguments to commands (accessible via placeholders) instead of treating them as commands. */
/**
* Passthrough additional arguments to commands (accessible via placeholders) instead of treating them as commands.
*/
export const passthroughArguments = false;

/**
Expand Down
8 changes: 6 additions & 2 deletions src/get-spawn-opts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ export const getSpawnOpts = ({
*/
colorSupport?: Pick<supportsColor.supportsColor.Level, 'level'> | false;

/** The NodeJS process. */
/**
* The NodeJS process.
*/
process?: Pick<NodeJS.Process, 'cwd' | 'platform' | 'env'>;

/**
Expand All @@ -31,7 +33,9 @@ export const getSpawnOpts = ({
*/
raw?: boolean;

/** Map of custom environment variables to include in the spawn options. */
/**
* Map of custom environment variables to include in the spawn options.
*/
env?: Record<string, unknown>;
}): SpawnOptions => ({
cwd: cwd || process.cwd(),
Expand Down
14 changes: 10 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ import { LogTimings } from './flow-control/log-timings';
import { RestartProcess } from './flow-control/restart-process';
import { Logger } from './logger';

/** Logger options */
export type ConcurrentlyOptions = BaseConcurrentlyOptions & {
/** Which command(s) should have their output hidden. */
// Logger options
/**
* Which command(s) should have their output hidden.
*/
hide?: CommandIdentifier | CommandIdentifier[];

/**
Expand All @@ -29,10 +31,14 @@ export type ConcurrentlyOptions = BaseConcurrentlyOptions & {
*/
prefix?: string;

/** How many characters should a prefix have at most, used when the prefix format is `command`. */
/**
* How many characters should a prefix have at most, used when the prefix format is `command`.
*/
prefixLength?: number;

/** Whether output should be formatted to include prefixes and whether "event" logs will be logged. */
/**
* Whether output should be formatted to include prefixes and whether "event" logs will be logged.
*/
raw?: boolean;

/**
Expand Down
8 changes: 6 additions & 2 deletions src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ export class Logger {
raw = false,
timestampFormat,
}: {
/** Which command(s) should have their output hidden. */
/**
* Which command(s) should have their output hidden.
*/
hide?: CommandIdentifier | CommandIdentifier[];

/**
Expand All @@ -47,7 +49,9 @@ export class Logger {
*/
prefixFormat?: string;

/** How many characters should a prefix have at most, used when the prefix format is `command`. */
/**
* How many characters should a prefix have at most, used when the prefix format is `command`.
*/
prefixLength?: number;

/**
Expand Down

0 comments on commit af9993f

Please sign in to comment.