diff --git a/packages/nx/src/command-line/add/add.ts b/packages/nx/src/command-line/add/add.ts index 9cf31c4d35ab1..9d766221f2804 100644 --- a/packages/nx/src/command-line/add/add.ts +++ b/packages/nx/src/command-line/add/add.ts @@ -135,7 +135,7 @@ async function initializePlugin( } catch (e) { spinner.fail(); output.addNewline(); - logger.error(e.message); + logger.error(e); output.error({ title: `Failed to initialize ${pkgName}. Please check the error above for more details.`, }); diff --git a/packages/nx/src/utils/child-process.ts b/packages/nx/src/utils/child-process.ts index 2f9ae1d4dbbe7..0f8b6e8901f73 100644 --- a/packages/nx/src/utils/child-process.ts +++ b/packages/nx/src/utils/child-process.ts @@ -36,7 +36,7 @@ export function runNxSync( export async function runNxAsync( cmd: string, options?: ExecOptions & { cwd?: string; silent?: boolean } -) { +): Promise { let baseCmd: string; if (existsSync(join(workspaceRoot, 'package.json'))) { baseCmd = `${getPackageManagerCommand().exec} nx`; @@ -57,15 +57,15 @@ export async function runNxAsync( if (options?.silent) { delete options.silent; } - await new Promise((resolve, reject) => { + return new Promise((resolve, reject) => { const child = exec( `${baseCmd} ${cmd}`, options, (error, stdout, stderr) => { if (error) { - reject(error); + reject(stderr || stdout || error.message); } else { - resolve(stdout); + resolve(); } } );