diff --git a/lib/utils/exit-handler.js b/lib/utils/exit-handler.js index 5b4087e913254..ce1bfaa54a56a 100644 --- a/lib/utils/exit-handler.js +++ b/lib/utils/exit-handler.js @@ -62,6 +62,7 @@ process.on('exit', code => { const logMethod = showLogFileError ? 'error' : timing ? 'info' : null if (logMethod) { + // just a line break, will be ignored in silent mode output.error('') const message = [] diff --git a/test/lib/commands/publish.js b/test/lib/commands/publish.js index ed35bdeeedd05..85a66d88b8b34 100644 --- a/test/lib/commands/publish.js +++ b/test/lib/commands/publish.js @@ -83,6 +83,7 @@ t.test('re-loads publishConfig.registry if added during script process', async t const { joinedOutput, npm } = await loadMockNpm(t, { config: { [`${alternateRegistry.slice(6)}/:_authToken`]: 'test-other-token', + // Keep output from leaking into tap logs for readability 'foreground-scripts': false, }, prefixDir: { @@ -137,6 +138,7 @@ t.test('prioritize CLI flags over publishConfig', async t => { const { joinedOutput, npm } = await loadMockNpm(t, { config: { [`${alternateRegistry.slice(6)}/:_authToken`]: 'test-other-token', + // Keep output from leaking into tap logs for readability 'foreground-scripts': false, }, prefixDir: { diff --git a/test/lib/utils/exit-handler.js b/test/lib/utils/exit-handler.js index 2ac0c61ac0662..8af47d9abc26c 100644 --- a/test/lib/utils/exit-handler.js +++ b/test/lib/utils/exit-handler.js @@ -53,7 +53,7 @@ mockGlobals(t, { }, { replace: true }) const mockExitHandler = async (t, { config, mocks, files, ...opts } = {}) => { - const consoleErrors = [] + const errors = [] const { npm, logMocks, ...rest } = await loadMockNpm(t, { ...opts, @@ -68,7 +68,7 @@ const mockExitHandler = async (t, { config, mocks, files, ...opts } = {}) => { ...(typeof config === 'function' ? config(dirs) : config), }), globals: { - 'console.error': (err) => consoleErrors.push(err), + 'console.error': (err) => errors.push(err), }, }) @@ -105,7 +105,7 @@ const mockExitHandler = async (t, { config, mocks, files, ...opts } = {}) => { ...rest, errors: () => [ ...rest.outputErrors, - ...consoleErrors, + ...errors, ], npm, // Make it async to make testing ergonomics a little easier so we dont need @@ -601,9 +601,7 @@ t.test('call exitHandler with no error', async (t) => { }) t.test('defaults to log error msg if stack is missing when unloaded', async (t) => { - const { exitHandler, logs, errors } = await mockExitHandler(t, { - load: false, - }) + const { exitHandler, logs, errors } = await mockExitHandler(t, { load: false }) await exitHandler(err('Error with no stack', { code: 'ENOSTACK', errno: 127 }, true)) t.equal(process.exitCode, 127)