Skip to content

Commit

Permalink
fix(error-message): look for er.path not er.file
Browse files Browse the repository at this point in the history
The attribute is here, er.file was used in error on another lib, the lib
got changed, and this code wasn't fixed.
  • Loading branch information
wraithgar committed Aug 18, 2021
1 parent 8183976 commit 7cb6441
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/utils/error-message.js
Expand Up @@ -99,9 +99,9 @@ module.exports = (er, npm) => {

case 'EJSONPARSE':
// Check whether we ran into a conflict in our own package.json
if (er.file === resolve(npm.prefix, 'package.json')) {
if (er.path === resolve(npm.prefix, 'package.json')) {
const { isDiff } = require('parse-conflict-json')
const txt = require('fs').readFileSync(er.file, 'utf8')
const txt = require('fs').readFileSync(er.path, 'utf8')
.replace(/\r\n/g, '\n')
if (isDiff(txt)) {
detail.push([
Expand Down
6 changes: 3 additions & 3 deletions test/lib/utils/error-message.js
Expand Up @@ -292,7 +292,7 @@ t.test('json parse', t => {
process.argv = ['arg', 'v']
t.matchSnapshot(errorMessage(Object.assign(new Error('conflicted'), {
code: 'EJSONPARSE',
file: resolve(dir, 'package.json'),
path: resolve(dir, 'package.json'),
}), npm))
t.end()
})
Expand All @@ -314,7 +314,7 @@ t.test('json parse', t => {
process.argv = ['arg', 'v']
t.matchSnapshot(errorMessage(Object.assign(new Error('not json'), {
code: 'EJSONPARSE',
file: resolve(dir, 'package.json'),
path: resolve(dir, 'package.json'),
}), npm))
t.end()
})
Expand All @@ -330,7 +330,7 @@ t.test('json parse', t => {
process.argv = ['arg', 'v']
t.matchSnapshot(errorMessage(Object.assign(new Error('not json'), {
code: 'EJSONPARSE',
file: `${dir}/blerg.json`,
path: `${dir}/blerg.json`,
}), npm))
t.end()
})
Expand Down

0 comments on commit 7cb6441

Please sign in to comment.