Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(error-message): look for er.path not er.file #3661

Merged
merged 1 commit into from Aug 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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