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.

PR-URL: #3661
Credit: @wraithgar
Close: #3661
Reviewed-by: @fritzy
  • Loading branch information
wraithgar authored and fritzy committed Aug 18, 2021
1 parent ff34d6c commit 68a19bb
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 68a19bb

Please sign in to comment.