From 4f1002c3df0537f96505a1ac9e1faa8f0f7b60bb Mon Sep 17 00:00:00 2001 From: Branch Vincent Date: Wed, 11 Aug 2021 17:45:12 -0400 Subject: [PATCH] add node item (#181) * add node * Use string trim instead Co-authored-by: Ilan Cosman --- functions/_tide_item_node.fish | 3 +++ functions/_tide_remove_unusable_items.fish | 2 +- functions/tide/configure/configs/classic.fish | 5 ++++- .../configure/configs/classic_16color.fish | 2 ++ functions/tide/configure/configs/lean.fish | 5 ++++- .../tide/configure/configs/lean_16color.fish | 2 ++ functions/tide/configure/configs/rainbow.fish | 5 ++++- .../configure/configs/rainbow_16color.fish | 2 ++ tests/_tide_item_node.test.fish | 18 ++++++++++++++++++ 9 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 functions/_tide_item_node.fish create mode 100644 tests/_tide_item_node.test.fish diff --git a/functions/_tide_item_node.fish b/functions/_tide_item_node.fish new file mode 100644 index 0000000..90a929b --- /dev/null +++ b/functions/_tide_item_node.fish @@ -0,0 +1,3 @@ +function _tide_item_node + test -e package.json && _tide_print_item node $tide_node_icon' ' (node --version | string trim --chars=v) +end diff --git a/functions/_tide_remove_unusable_items.fish b/functions/_tide_remove_unusable_items.fish index 68b3208..8c49cd0 100644 --- a/functions/_tide_remove_unusable_items.fish +++ b/functions/_tide_remove_unusable_items.fish @@ -1,6 +1,6 @@ function _tide_remove_unusable_items # Remove tool-specific items for tools the machine doesn't have installed - for item in chruby git go kubectl nvm php rustc virtual_env + for item in chruby git go kubectl node nvm php rustc virtual_env set -l cli_names $item switch $item case virtual_env diff --git a/functions/tide/configure/configs/classic.fish b/functions/tide/configure/configs/classic.fish index 8b09ba7..a0bfdbb 100644 --- a/functions/tide/configure/configs/classic.fish +++ b/functions/tide/configure/configs/classic.fish @@ -45,6 +45,9 @@ tide_left_prompt_prefix '' tide_left_prompt_separator_diff_color '' tide_left_prompt_separator_same_color '' tide_left_prompt_suffix '' +tide_node_bg_color 444444 +tide_node_color 44883E +tide_node_icon '⬢' tide_nvm_bg_color 444444 tide_nvm_color 44883E tide_nvm_icon '⬢' @@ -68,7 +71,7 @@ tide_pwd_icon_home tide_pwd_icon_unwritable '' tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform Cargo.toml composer.json CVS go.mod package.json tide_right_prompt_frame_enabled true -tide_right_prompt_items status cmd_duration context jobs nvm virtual_env rustc php chruby go kubectl vi_mode +tide_right_prompt_items status cmd_duration context jobs node nvm virtual_env rustc php chruby go kubectl vi_mode tide_right_prompt_prefix '' tide_right_prompt_separator_diff_color '' tide_right_prompt_separator_same_color '' diff --git a/functions/tide/configure/configs/classic_16color.fish b/functions/tide/configure/configs/classic_16color.fish index 80926db..8dc3405 100644 --- a/functions/tide/configure/configs/classic_16color.fish +++ b/functions/tide/configure/configs/classic_16color.fish @@ -26,6 +26,8 @@ tide_jobs_bg_color black tide_jobs_color green tide_kubectl_bg_color black tide_kubectl_color blue +tide_node_bg_color black +tide_node_color green tide_nvm_bg_color black tide_nvm_color green tide_os_bg_color black diff --git a/functions/tide/configure/configs/lean.fish b/functions/tide/configure/configs/lean.fish index 7e16468..9be9102 100644 --- a/functions/tide/configure/configs/lean.fish +++ b/functions/tide/configure/configs/lean.fish @@ -45,6 +45,9 @@ tide_left_prompt_prefix '' tide_left_prompt_separator_diff_color ' ' tide_left_prompt_separator_same_color ' ' tide_left_prompt_suffix ' ' +tide_node_bg_color normal +tide_node_color 44883E +tide_node_icon '⬢' tide_nvm_bg_color normal tide_nvm_color 44883E tide_nvm_icon '⬢' @@ -68,7 +71,7 @@ tide_pwd_icon_home tide_pwd_icon_unwritable '' tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform Cargo.toml composer.json CVS go.mod package.json tide_right_prompt_frame_enabled false -tide_right_prompt_items status cmd_duration context jobs nvm virtual_env rustc php chruby go kubectl +tide_right_prompt_items status cmd_duration context jobs node nvm virtual_env rustc php chruby go kubectl tide_right_prompt_prefix ' ' tide_right_prompt_separator_diff_color ' ' tide_right_prompt_separator_same_color ' ' diff --git a/functions/tide/configure/configs/lean_16color.fish b/functions/tide/configure/configs/lean_16color.fish index 8fc6d2c..64d3108 100644 --- a/functions/tide/configure/configs/lean_16color.fish +++ b/functions/tide/configure/configs/lean_16color.fish @@ -26,6 +26,8 @@ tide_jobs_bg_color normal tide_jobs_color green tide_kubectl_bg_color normal tide_kubectl_color blue +tide_node_bg_color normal +tide_node_color green tide_nvm_bg_color normal tide_nvm_color green tide_os_bg_color normal diff --git a/functions/tide/configure/configs/rainbow.fish b/functions/tide/configure/configs/rainbow.fish index 2dfaed0..fc7fee9 100644 --- a/functions/tide/configure/configs/rainbow.fish +++ b/functions/tide/configure/configs/rainbow.fish @@ -45,6 +45,9 @@ tide_left_prompt_prefix '' tide_left_prompt_separator_diff_color '' tide_left_prompt_separator_same_color '' tide_left_prompt_suffix '' +tide_node_bg_color 44883E +tide_node_color 000000 +tide_node_icon '⬢' tide_nvm_bg_color 44883E tide_nvm_color 000000 tide_nvm_icon '⬢' @@ -68,7 +71,7 @@ tide_pwd_icon_home tide_pwd_icon_unwritable '' tide_pwd_markers .bzr .citc .git .hg .node-version .python-version .ruby-version .shorten_folder_marker .svn .terraform Cargo.toml composer.json CVS go.mod package.json tide_right_prompt_frame_enabled true -tide_right_prompt_items status cmd_duration context jobs nvm virtual_env rustc php chruby go kubectl vi_mode +tide_right_prompt_items status cmd_duration context jobs node nvm virtual_env rustc php chruby go kubectl vi_mode tide_right_prompt_prefix '' tide_right_prompt_separator_diff_color '' tide_right_prompt_separator_same_color '' diff --git a/functions/tide/configure/configs/rainbow_16color.fish b/functions/tide/configure/configs/rainbow_16color.fish index 0b1941e..0564021 100644 --- a/functions/tide/configure/configs/rainbow_16color.fish +++ b/functions/tide/configure/configs/rainbow_16color.fish @@ -26,6 +26,8 @@ tide_jobs_bg_color brblack tide_jobs_color green tide_kubectl_bg_color blue tide_kubectl_color black +tide_node_bg_color green +tide_node_color black tide_nvm_bg_color green tide_nvm_color black tide_os_bg_color white diff --git a/tests/_tide_item_node.test.fish b/tests/_tide_item_node.test.fish new file mode 100644 index 0000000..de3552b --- /dev/null +++ b/tests/_tide_item_node.test.fish @@ -0,0 +1,18 @@ +# RUN: %fish %s + +function _node + _tide_decolor (_tide_item_node) +end + +set -l tmpdir (mktemp -d) +cd $tmpdir + +mock node --version "echo v16.5.0" +set -lx tide_node_icon ⬢ + +_node # CHECK: + +touch package.json +_node # CHECK: ⬢ 16.5.0 + +rm -r $tmpdir