feat(core): minor cache improvements to improve dev ergonomics

This commit is contained in:
Victor Savkin 2020-02-04 14:04:56 -05:00 committed by Victor Savkin
parent 33107b050c
commit 04a9c5edbb
7 changed files with 41 additions and 3 deletions

View File

@ -30,6 +30,12 @@ Type: `string`
Command to run in child process
### outputPath
Type: `string`
Tells Nx where the files will be created
### parallel
Default: `true`

View File

@ -31,6 +31,12 @@ Type: `string`
Command to run in child process
### outputPath
Type: `string`
Tells Nx where the files will be created
### parallel
Default: `true`

View File

@ -31,6 +31,12 @@ Type: `string`
Command to run in child process
### outputPath
Type: `string`
Tells Nx where the files will be created
### parallel
Default: `true`

View File

@ -5,7 +5,7 @@ import { findWorkspaceRoot } from './find-workspace-root';
const workspace = findWorkspaceRoot(process.cwd());
if (process.env.NX_TERMINAL_OUTPUT_PATH) {
setUpOutputWatching();
setUpOutputWatching(process.env.NX_TERMINAL_CAPTURE_STDERR === 'true');
}
requireCli();
@ -40,7 +40,7 @@ function requireCli() {
* And the cached output should be correct unless the CLI bypasses process.stdout or console.log and uses some
* C-binary to write to stdout.
*/
function setUpOutputWatching() {
function setUpOutputWatching(captureStderr: boolean) {
const stdoutWrite = process.stdout._write;
const stderrWrite = process.stderr._write;
@ -60,7 +60,9 @@ function setUpOutputWatching() {
encoding: string,
callback: Function
) => {
out.push(chunk.toString());
if (captureStderr) {
out.push(chunk.toString());
}
stderrWrite.apply(process.stderr, [chunk, encoding, callback]);
};

View File

@ -34,6 +34,20 @@
"type": "boolean",
"description": "Use colors when showing output of command",
"default": false
},
"outputPath": {
"description": "Tells Nx where the files will be created",
"oneOf": [
{
"type": "string"
},
{
"type": "array",
"items": {
"type": "string"
}
}
]
}
},
"required": ["commands"]

View File

@ -117,6 +117,9 @@ export class TaskOrchestrator {
const env = { ...process.env };
if (outputPath) {
env.NX_TERMINAL_OUTPUT_PATH = outputPath;
if (this.options.captureStderr) {
env.NX_TERMINAL_CAPTURE_STDERR = 'true';
}
}
const p = fork(this.getCommand(), this.getCommandArgs(task), {
stdio: ['inherit', 'inherit', 'inherit', 'ipc'],

View File

@ -32,6 +32,7 @@ export interface DefaultTasksRunnerOptions {
cacheDirectory?: string;
remoteCache?: RemoteCache;
lifeCycle?: LifeCycle;
captureStderr?: boolean;
}
export const tasksRunnerV2: TasksRunner<DefaultTasksRunnerOptions> = (