Skip to content

Commit

Permalink
fixup! Revert "fix(usage): output usage normally"
Browse files Browse the repository at this point in the history
This reverts commit 7a6ae08.
  • Loading branch information
lukekarrys committed Nov 4, 2021
1 parent ab8cd12 commit bd8f91a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 21 deletions.
6 changes: 1 addition & 5 deletions lib/utils/exit-handler.js
Expand Up @@ -65,9 +65,8 @@ process.on('exit', code => {
writeLogFile()
}
// In timing mode we always write the log file
if (npm.config.loaded && npm.config.get('timing') && !wroteLogFile) {
if (npm.config.loaded && npm.config.get('timing') && !wroteLogFile)
writeLogFile()
}
if (wroteLogFile) {
// just a line break
if (npm.log.levels[npm.log.level] <= npm.log.levels.error)
Expand Down Expand Up @@ -124,9 +123,6 @@ const exitHandler = (err) => {
} else if (!(err instanceof Error)) {
noLog = true
npm.log.error('weird error', err)
} else if (err.code === 'EUSAGE') {
npm.output(err.message)
noLog = true
} else {
if (!err.code) {
const matchErrorCode = err.message.match(/^(?:Error: )?(E[A-Z]+)/)
Expand Down
17 changes: 1 addition & 16 deletions test/lib/utils/exit-handler.js
Expand Up @@ -26,7 +26,7 @@ const cacheFolder = t.testdir({})
const logFile = path.resolve(cacheFolder, '_logs', 'expecteddate-debug.log')
const timingFile = path.resolve(cacheFolder, '_timing.json')

const { Npm, outputs } = mockNpm(t, {
const { Npm } = mockNpm(t, {
'../../package.json': {
version: '1.0.0',
},
Expand Down Expand Up @@ -203,21 +203,6 @@ t.test('throw a non-error obj', (t) => {
)
})

t.test('EUSAGE', (t) => {
t.plan(2)

process.once('exit', code => {
t.equal(code, 1, 'exits with exitCode 1')
})
exitHandler(Object.assign(
new Error('this is the usage message'),
{
code: 'EUSAGE'
}
))
t.match(outputs, [['this is the usage message']])
})

t.test('throw a string error', (t) => {
t.plan(2)
const error = 'foo bar'
Expand Down

0 comments on commit bd8f91a

Please sign in to comment.