Skip to content

Commit d1194a9

Browse files
authored
fix(core): nx add should show errors (nrwl#28079)
`nx add` errors should be surfaced to users. <!-- 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 Users do not see errors from init generator. ## Expected Behavior Users see errors from init generator. ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
1 parent 5afece0 commit d1194a9

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

packages/nx/src/command-line/add/add.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ async function initializePlugin(
141141
} catch (e) {
142142
spinner.fail();
143143
output.addNewline();
144-
logger.error(e.message);
144+
logger.error(e);
145145
output.error({
146146
title: `Failed to initialize ${pkgName}. Please check the error above for more details.`,
147147
});

packages/nx/src/utils/child-process.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function runNxSync(
3737
export async function runNxAsync(
3838
cmd: string,
3939
options?: ExecOptions & { cwd?: string; silent?: boolean }
40-
) {
40+
): Promise<void> {
4141
let baseCmd: string;
4242
if (existsSync(join(workspaceRoot, 'package.json'))) {
4343
baseCmd = `${getPackageManagerCommand().exec} nx`;
@@ -59,15 +59,15 @@ export async function runNxAsync(
5959
if (options?.silent) {
6060
delete options.silent;
6161
}
62-
await new Promise((resolve, reject) => {
62+
return new Promise<void>((resolve, reject) => {
6363
const child = exec(
6464
`${baseCmd} ${cmd}`,
6565
options,
6666
(error, stdout, stderr) => {
6767
if (error) {
68-
reject(error);
68+
reject(stderr || stdout || error.message);
6969
} else {
70-
resolve(stdout);
70+
resolve();
7171
}
7272
}
7373
);

0 commit comments

Comments
 (0)