forked from mathiasbynens/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.node
119 lines (104 loc) · 3.61 KB
/
.node
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# export NVM_DIR="$HOME/.nvm"
# # [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
# # [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# n_echo() {
# command printf %s\\n "$*" 2>/dev/null
# }
# n_find_up() {
# local path_
# path_="${PWD}"
# while [ "${path_}" != "" ] && [ ! -f "${path_}/${1-}" ]; do
# path_=${path_%/*}
# done
# n_echo "${path_}"
# }
# n_find_nvmrc() {
# local dir
# dir="$(n_find_up '.nvmrc')"
# if [ -e "${dir}/.nvmrc" ]; then
# n_echo "${dir}/.nvmrc"
# fi
# }
# __init-n-autoload() {
# autoload -U add-zsh-hook
# load-n() {
# local node_version="$(node -v)"
# local nvmrc_path="$(n_find_nvmrc)"
# if [ -n "$nvmrc_path" ]; then
# sudo n "$(cat "${nvmrc_path}")")
# elif [ "$node_version" != "$(nvm version default)" ]; then
# echo "Reverting to n default version"
# nvm use default
# fi
# }
# add-zsh-hook chpwd load-n
# }
# __init-n-autoload
# # alias loadrvm='[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"'
# # Defer initialization of nvm until nvm, node or a node-dependent command is
# # run. Ensure this block is only run once if .bashrc gets sourced multiple times
# # by checking whether __init_nvm is a function.
# if [ -s "$HOME/.nvm/nvm.sh" ] && [ ! "$(type __init_nvm)" = function ]; then
# export NVM_DIR="$HOME/.nvm"
# [ -s "$NVM_DIR/bash_completion" ] && . "$NVM_DIR/bash_completion"
# # declare -a __node_commands=('nvm' 'node' 'npm' 'yarn' 'gulp' 'grunt' 'webpack')
# function __init_nvm() {
# echo "Loading NVM..."
# # for i in "${__node_commands[@]}"; do unalias $i; done
# . "$NVM_DIR"/nvm.sh
# # __init-nvm-autoload
# # unset __node_commands
# unset -f __init_nvm
# unalias loadnvm
# }
# alias loadnvm='__init_nvm'
# # for i in "${__node_commands[@]}"; do alias $i='__init_nvm && '$i; done
# fi
# __init-nvm-autoload() {
# autoload -U add-zsh-hook
# load-nvmrc() {
# local node_version="$(nvm version)"
# local nvmrc_path="$(nvm_find_nvmrc)"
# if [ -n "$nvmrc_path" ]; then
# local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
# if [ "$nvmrc_node_version" = "N/A" ]; then
# nvm install
# elif [ "$nvmrc_node_version" != "$node_version" ]; then
# nvm use
# fi
# elif [ "$node_version" != "$(nvm version default)" ]; then
# echo "Reverting to nvm default version"
# nvm use default
# fi
# }
# add-zsh-hook chpwd load-nvmrc
# load-nvmrc
# }
# # Load nvm if present
# export NVM_DIR="$HOME/.nvm"
# if [ -s "$NVM_DIR/nvm.sh" ]; then
# # Load nvm but don't use it yet: we need to do some other hacks first.
# # See https://github.com/creationix/nvm/issues/1261#issuecomment-366879288
# . "$NVM_DIR/nvm.sh" --no-use
# # I don't need this check, and it's slow (loads npm).
# # Do not use the npm `prefix` config; do not report related bugs to nvm ;)
# nvm_die_on_prefix() {
# return 0
# }
# # This also loads npm; let's just skip it.
# nvm_print_npm_version() {
# return 0
# }
# # nvm_resolve_local_alias can also be slow; cache it.
# if [ -f "$NVM_DIR/_default_version" ]; then
# NVM_AUTO_LOAD_VERSION=$(cat "$NVM_DIR/_default_version")
# fi
# if [ -z "$NVM_AUTO_LOAD_VERSION" ]; then
# NVM_AUTO_LOAD_VERSION=$(nvm_resolve_local_alias default)
# fi
# if [ -n "$NVM_AUTO_LOAD_VERSION" ]; then
# echo "$NVM_AUTO_LOAD_VERSION" > "$NVM_DIR/_default_version"
# nvm use --silent "$NVM_AUTO_LOAD_VERSION"
# fi
# __init-nvm-autoload
# fi