<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> The `withVerbose` util is only used in a few places. ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> The `withVerbose` util is used throughout and also contains middleware to default to the value in `process.env.NX_VERBOSE_LOGGING === 'true'` ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
33 lines
890 B
TypeScript
33 lines
890 B
TypeScript
export class CreateNxWorkspaceError extends Error {
|
|
constructor(
|
|
public logMessage: string,
|
|
public code: number | null | undefined,
|
|
public logFile: string
|
|
) {
|
|
super(logMessage);
|
|
this.name = 'CreateNxWorkspaceError';
|
|
}
|
|
}
|
|
|
|
export function mapErrorToBodyLines(error: Error): string[] {
|
|
const errorLines = error.message?.split('\n').filter((line) => !!line.trim());
|
|
if (errorLines.length < 3) {
|
|
const lines = [`Error: ${error.message}`];
|
|
if (process.env.NX_VERBOSE_LOGGING === 'true') {
|
|
lines.push(`Stack: ${error.stack}`);
|
|
}
|
|
return lines;
|
|
}
|
|
|
|
const lines =
|
|
error instanceof CreateNxWorkspaceError
|
|
? [`Exit code: ${error.code}`, `Log file: ${error.logFile}`]
|
|
: [];
|
|
|
|
if (process.env.NX_VERBOSE_LOGGING === 'true') {
|
|
lines.push(`Error: ${error.message}`);
|
|
lines.push(`Stack: ${error.stack}`);
|
|
}
|
|
return lines;
|
|
}
|