Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rush] enabling ipc in order to let watch builders continue running #1152

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions apps/rush-lib/src/logic/taskRunner/ProjectTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface IProjectTaskOptions {
commandToRun: string;
customParameterValues: string[];
isIncrementalBuildAllowed: boolean;
enableIPC: boolean;
ignoreMissingScript: boolean;
packageChangeAnalyzer: PackageChangeAnalyzer;
}
Expand Down Expand Up @@ -57,6 +58,7 @@ export class ProjectTask implements ITaskDefinition {
this._commandToRun = options.commandToRun;
this._customParameterValues = options.customParameterValues;
this.isIncrementalBuildAllowed = options.isIncrementalBuildAllowed;
this.enableIPC = options.enableIPC;
this._ignoreMissingScript = options.ignoreMissingScript;
this._packageChangeAnalyzer = options.packageChangeAnalyzer;
}
Expand Down Expand Up @@ -144,17 +146,38 @@ export class ProjectTask implements ITaskDefinition {
Utilities.executeLifecycleCommandAsync(normalizedTaskCommand, projectFolder,
this._rushConfiguration.commonTempFolder, true);

let inBackground: boolean = false;

// Hook into events, in order to get live streaming of build log
task.stdout.on('data', (data: string) => {
writer.write(data);
if (!inBackground) {
writer.write(data);
}
});

task.stderr.on('data', (data: string) => {
writer.writeError(data);
this._hasWarningOrError = true;
if (!inBackground) {
writer.writeError(data);
this._hasWarningOrError = true;
}
});

return new Promise((resolve: (status: TaskStatus) => void, reject: (error: TaskError) => void) => {
const successHandler: Function = () => {
// Write deps on success.
if (currentPackageDeps) {
JsonFile.save(currentPackageDeps, currentDepsPath);
}
resolve(TaskStatus.Success);
};

task.on('message', (msg) => {
if (!inBackground && msg === 'rush-continue') {
inBackground = true;
successHandler();
}
});

task.on('close', (code: number) => {
this._writeLogsToDisk(writer);

Expand All @@ -163,11 +186,7 @@ export class ProjectTask implements ITaskDefinition {
} else if (this._hasWarningOrError) {
resolve(TaskStatus.SuccessWithWarning);
} else {
// Write deps on success.
if (currentPackageDeps) {
JsonFile.save(currentPackageDeps, currentDepsPath);
}
resolve(TaskStatus.Success);
successHandler();
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion apps/rush-lib/src/utilities/Utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ export class Utilities {
cwd: workingDirectory,
shell: useShell,
env: environment,
stdio: captureOutput ? ['pipe', 'pipe', 'pipe'] : [0, 1, 2]
stdio: captureOutput ? ['pipe', 'pipe', 'pipe', 'ipc'] : [0, 1, 2, 'ipc']
});
}

Expand Down