-
Notifications
You must be signed in to change notification settings - Fork 946
Option to Show Node Version Only In Project #760
Option to Show Node Version Only In Project #760
Conversation
If this option is set, the segment is only shown inside node projects. Such a project is identified by a package.json description. The search is reverse from the current working diretory to the root. The search stops if such a description has been found. Add condition to show the segment, depending on the option variable and the search result.
Write a simple single line description. Create a table for the `PROJECT_ONLY` option. Link the section in the list of all segments.
I've decided to implement such a search functionality, cause I'm not aware of any different option to determine a NodeJS project. Also a quick research do not offer such a possibility. As long as the current working directory is not that much nested, this search loop could be evaluated rly quick and should not represent an performance issue. |
powerlevel9k.zsh-theme
Outdated
@@ -1023,9 +1023,9 @@ prompt_load() { | |||
# Replace comma | |||
load_avg=${load_avg//,/.} | |||
|
|||
if [[ "$load_avg" -gt $(bc -l <<< "${cores} * 0.7") ]]; then |
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.
These are changes to prompt_load
so muddies your PR. Would it be possible to do this in a separate PR if you want to suggest these changes, and also document what the changes are and why?
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.
That have to be a slip. Wasn't my intention to touch this. I will revert this immediately.
Still left the question, if the test environment should been adjusted for this. |
Hey @weilbith - this looks great! I apologize for the long delay in responding to this PR. It's a great enhancement to the NodeJS segment, and I'm excited about getting it merged. I think the point you raised in your initial post is a good one - this segment really needs its own tests, and we currently lack that. Are you willing to implement some test cases as part of this PR, @weilbith? It would be a great improvement for P9k :) |
@bhilburn sure, it's my implementation so should provide the tests for it too. :) |
@weilbith - Yup! I would make a new |
@bhilburn Sry for beeing idle so long here. |
Yes. The test VMs are for manual tests if someone with BSD has a problem.
No. The tests are also executed on every push by Travis-CI. Have a look at |
@dritter |
That was more "am I allowed to" and not how can I..m |
@weilbith - Yes! You may add Node to travis for your testing =) |
Hmm. I am opposed to installing node on travis. This would be an integration test. For a proper integration test we need to test different node versions (the node output could change between versions). This would lead to quite some complexity and make the tests more fragile (install X packages in Y different versions on Travis). |
@dritter @bhilburn |
@weilbith You are right. This is the downside of this approach. But if NodeJS chooses a different file name it would be a major BC break for them. I count on the community that would bring that change to us and change the P9K accordingly. And, as said, we would have to support two versions of NodeJS, which would then need a special setup (if we test against real installations).
Yes, you have to fake the node output and the node project ( |
Obsolete by more recent PR #1219 since I never made it extend the tests. 💀 |
As the
vcs
segment only appears in directories which are part of such a repository, it should be possible to set the segmentnode_version
to appear only in NodeJS projects.Functionality
By using a new variable called
POWERLEVEL9K_NODE_VERSION_PROJECT_ONLY
(which is set tofalse
per default), the user can enable the described option. If so, the segment search for a project description filepackage.json
from the current working directory upwards to the root. The search stops if a project root has been found. Afterwards the NodeJS version is just requested if this option is disabled or a project is detected.Using this new variable and set it to
false
per default, the segment stay compatible to older configurations by the user.Documenation
The documentation has been already adjusted in the
README
, where a new section for this segment has been opened, the option explained and linked in the list of all segments at the top of the document.Testing
It is open to define tests. So far it has been practically tested on Ubuntu 16.4 with oh-my-zsh. It is not expected, that different OS and/or frameworks affect this behaviour.
This segments has no own test cases yet. To do so, an adjustment of the environment is required, to initialize a plain NodeJS project and check the behaviour in- and outside of this directory.