Skip to content

Commit 68a19bb

Browse files
wraithgarfritzy
authored andcommitted
fix(error-message): look for er.path not er.file
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
1 parent ff34d6c commit 68a19bb

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/utils/error-message.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ module.exports = (er, npm) => {
9999

100100
case 'EJSONPARSE':
101101
// Check whether we ran into a conflict in our own package.json
102-
if (er.file === resolve(npm.prefix, 'package.json')) {
102+
if (er.path === resolve(npm.prefix, 'package.json')) {
103103
const { isDiff } = require('parse-conflict-json')
104-
const txt = require('fs').readFileSync(er.file, 'utf8')
104+
const txt = require('fs').readFileSync(er.path, 'utf8')
105105
.replace(/\r\n/g, '\n')
106106
if (isDiff(txt)) {
107107
detail.push([

test/lib/utils/error-message.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ t.test('json parse', t => {
292292
process.argv = ['arg', 'v']
293293
t.matchSnapshot(errorMessage(Object.assign(new Error('conflicted'), {
294294
code: 'EJSONPARSE',
295-
file: resolve(dir, 'package.json'),
295+
path: resolve(dir, 'package.json'),
296296
}), npm))
297297
t.end()
298298
})
@@ -314,7 +314,7 @@ t.test('json parse', t => {
314314
process.argv = ['arg', 'v']
315315
t.matchSnapshot(errorMessage(Object.assign(new Error('not json'), {
316316
code: 'EJSONPARSE',
317-
file: resolve(dir, 'package.json'),
317+
path: resolve(dir, 'package.json'),
318318
}), npm))
319319
t.end()
320320
})
@@ -330,7 +330,7 @@ t.test('json parse', t => {
330330
process.argv = ['arg', 'v']
331331
t.matchSnapshot(errorMessage(Object.assign(new Error('not json'), {
332332
code: 'EJSONPARSE',
333-
file: `${dir}/blerg.json`,
333+
path: `${dir}/blerg.json`,
334334
}), npm))
335335
t.end()
336336
})

0 commit comments

Comments
 (0)