feat(core): minor cache improvements to improve dev ergonomics
This commit is contained in:
parent
33107b050c
commit
04a9c5edbb
@ -30,6 +30,12 @@ Type: `string`
|
|||||||
|
|
||||||
Command to run in child process
|
Command to run in child process
|
||||||
|
|
||||||
|
### outputPath
|
||||||
|
|
||||||
|
Type: `string`
|
||||||
|
|
||||||
|
Tells Nx where the files will be created
|
||||||
|
|
||||||
### parallel
|
### parallel
|
||||||
|
|
||||||
Default: `true`
|
Default: `true`
|
||||||
|
|||||||
@ -31,6 +31,12 @@ Type: `string`
|
|||||||
|
|
||||||
Command to run in child process
|
Command to run in child process
|
||||||
|
|
||||||
|
### outputPath
|
||||||
|
|
||||||
|
Type: `string`
|
||||||
|
|
||||||
|
Tells Nx where the files will be created
|
||||||
|
|
||||||
### parallel
|
### parallel
|
||||||
|
|
||||||
Default: `true`
|
Default: `true`
|
||||||
|
|||||||
@ -31,6 +31,12 @@ Type: `string`
|
|||||||
|
|
||||||
Command to run in child process
|
Command to run in child process
|
||||||
|
|
||||||
|
### outputPath
|
||||||
|
|
||||||
|
Type: `string`
|
||||||
|
|
||||||
|
Tells Nx where the files will be created
|
||||||
|
|
||||||
### parallel
|
### parallel
|
||||||
|
|
||||||
Default: `true`
|
Default: `true`
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import { findWorkspaceRoot } from './find-workspace-root';
|
|||||||
const workspace = findWorkspaceRoot(process.cwd());
|
const workspace = findWorkspaceRoot(process.cwd());
|
||||||
|
|
||||||
if (process.env.NX_TERMINAL_OUTPUT_PATH) {
|
if (process.env.NX_TERMINAL_OUTPUT_PATH) {
|
||||||
setUpOutputWatching();
|
setUpOutputWatching(process.env.NX_TERMINAL_CAPTURE_STDERR === 'true');
|
||||||
}
|
}
|
||||||
requireCli();
|
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
|
* 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.
|
* C-binary to write to stdout.
|
||||||
*/
|
*/
|
||||||
function setUpOutputWatching() {
|
function setUpOutputWatching(captureStderr: boolean) {
|
||||||
const stdoutWrite = process.stdout._write;
|
const stdoutWrite = process.stdout._write;
|
||||||
const stderrWrite = process.stderr._write;
|
const stderrWrite = process.stderr._write;
|
||||||
|
|
||||||
@ -60,7 +60,9 @@ function setUpOutputWatching() {
|
|||||||
encoding: string,
|
encoding: string,
|
||||||
callback: Function
|
callback: Function
|
||||||
) => {
|
) => {
|
||||||
out.push(chunk.toString());
|
if (captureStderr) {
|
||||||
|
out.push(chunk.toString());
|
||||||
|
}
|
||||||
stderrWrite.apply(process.stderr, [chunk, encoding, callback]);
|
stderrWrite.apply(process.stderr, [chunk, encoding, callback]);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -34,6 +34,20 @@
|
|||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"description": "Use colors when showing output of command",
|
"description": "Use colors when showing output of command",
|
||||||
"default": false
|
"default": false
|
||||||
|
},
|
||||||
|
"outputPath": {
|
||||||
|
"description": "Tells Nx where the files will be created",
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["commands"]
|
"required": ["commands"]
|
||||||
|
|||||||
@ -117,6 +117,9 @@ export class TaskOrchestrator {
|
|||||||
const env = { ...process.env };
|
const env = { ...process.env };
|
||||||
if (outputPath) {
|
if (outputPath) {
|
||||||
env.NX_TERMINAL_OUTPUT_PATH = 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), {
|
const p = fork(this.getCommand(), this.getCommandArgs(task), {
|
||||||
stdio: ['inherit', 'inherit', 'inherit', 'ipc'],
|
stdio: ['inherit', 'inherit', 'inherit', 'ipc'],
|
||||||
|
|||||||
@ -32,6 +32,7 @@ export interface DefaultTasksRunnerOptions {
|
|||||||
cacheDirectory?: string;
|
cacheDirectory?: string;
|
||||||
remoteCache?: RemoteCache;
|
remoteCache?: RemoteCache;
|
||||||
lifeCycle?: LifeCycle;
|
lifeCycle?: LifeCycle;
|
||||||
|
captureStderr?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const tasksRunnerV2: TasksRunner<DefaultTasksRunnerOptions> = (
|
export const tasksRunnerV2: TasksRunner<DefaultTasksRunnerOptions> = (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user