-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Version warning when local version is behind #1407
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for opening the PR @tdeschryver. There's some subtle logic issues. Might be worth stubbing the update-notifier
module in lib/cli.js
to verify the isGlobal
value.
We've been having some trouble with the CI so I don't think those failures are due to this PR.
cli.js
Outdated
@@ -11,7 +11,8 @@ const localCLI = resolveCwd('ava/cli'); | |||
// Use `path.relative()` to detect local AVA installation, | |||
// because __filename's case is inconsistent on Windows | |||
// see https://github.com/nodejs/node/issues/6624 | |||
if (localCLI && path.relative(localCLI, __filename) !== '') { | |||
process.env.AVA_LOCAL_CLI = process.env.AVA_LOCAL_CLI || (localCLI && path.relative(localCLI, __filename) !== ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This bit (localCLI && path.relative(localCLI, __filename) !== '')
needs to be cast to a string: String(localCLI && path.relative(localCLI, __filename) !== '')
. Otherwise the comparison on the next line won't be true.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I didn't know that. When I was debugging it, it was a automatically converted to a string.
Its changed now.
lib/cli.js
Outdated
@@ -100,7 +100,7 @@ exports.run = () => { | |||
} | |||
}); | |||
|
|||
updateNotifier({pkg: cli.pkg}).notify(); | |||
updateNotifier({pkg: cli.pkg}).notify({isGlobal: process.env.AVA_LOCAL_CLI === 'true'}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be !== 'true'
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, you're right. My bad!
@novemberborn I was trying to figure out how I could test the |
@tdeschryver in your current test, try this: const notifySpy = sinon.spy()
proxyquire('../cli', {
debug: debugStub,
'resolve-cwd': resolveCwdStub,
'./lib/cli': proxyquire('../lib/cli', {
'update-notifier' () {
return {notify: notifySpy}
}
})
}); You should then be able to assert on the |
@novemberborn I don't think that will work (or I am missing something), the problem is we are stubbing EDIT: just tried this and the notify function isn't being called as far as I can see. |
@tdeschryver could you push your attempt? I'll try on my end. |
@novemberborn I discarded my changes, would it help you if I rewrite it? |
@tdeschryver yea I'll try and give this a go. #1376 landing also threw a wrench into the works. |
@sindresorhus |
I think we're trying to solve this problem in the wrong place. Better to fix it in |
@sindresorhus is it OK if I'm going to take a look at it? |
@tdeschryver Go ahead 😃 |
cc98135
to
cbb0393
Compare
Bumped |
Thanks @tdeschryver :) |
Fixes #1336
Added variable
process.env.AVA_LOCAL_CLI
to show the correct message.