Skip to content

Commit

Permalink
fixup! feat: do all ouput over proc-log events
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed Apr 14, 2024
1 parent f2e0073 commit 61ea31c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/utils/exit-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
2 changes: 2 additions & 0 deletions test/lib/commands/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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: {
Expand Down
10 changes: 4 additions & 6 deletions test/lib/utils/exit-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
},
})

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 61ea31c

Please sign in to comment.