funzioni *_feat_ensure con sourcing bashrc.before e validazione pyenv global
- pip_feat_ensure: ricarica .bashrc.before, verifica che pyenv global sia valido (non system, non vuoto, non versione rimossa), fallback a ultima installata - npm_feat_ensure: ricarica .bashrc.before prima di verificare npm - poetry: sourcing .bashrc.before in poetry_feat_missing e poetry_feat_neededmaster
parent
ebe1748dd6
commit
296b354422
|
|
@ -70,8 +70,23 @@ function npm_feat_add() {
|
||||||
npm install "$1"
|
npm install "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
function npm_feat_needed() {
|
function npm_feat_ensure() {
|
||||||
|
# Ricarica .bashrc.before per eventuali modifiche al PATH
|
||||||
|
if [ -f "$HOME/.bashrc.before" ]; then
|
||||||
|
source "$HOME/.bashrc.before"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Se npm funziona, ok
|
||||||
|
if npm --version >/dev/null 2>&1; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Altrimenti installiamo tutto
|
||||||
feat_needed "npm"
|
feat_needed "npm"
|
||||||
|
}
|
||||||
|
|
||||||
|
function npm_feat_needed() {
|
||||||
|
npm_feat_ensure
|
||||||
FEAT="$1"
|
FEAT="$1"
|
||||||
npm_feat_ensure_ncu
|
npm_feat_ensure_ncu
|
||||||
if ! npm_initialized; then
|
if ! npm_initialized; then
|
||||||
|
|
@ -88,7 +103,7 @@ function npm_feat_needed() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function npm-g_feat_needed() {
|
function npm-g_feat_needed() {
|
||||||
feat_needed "npm"
|
npm_feat_ensure
|
||||||
FEAT="$1"
|
FEAT="$1"
|
||||||
if ! npm-g_feat_added "$FEAT"; then
|
if ! npm-g_feat_added "$FEAT"; then
|
||||||
if type "npm-g_feat_add_$FEAT" > /dev/null 2>&1 ; then
|
if type "npm-g_feat_add_$FEAT" > /dev/null 2>&1 ; then
|
||||||
|
|
|
||||||
|
|
@ -46,9 +46,40 @@ function feat_add_pip() {
|
||||||
pip install --upgrade pip
|
pip install --upgrade pip
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pip_feat_ensure() {
|
||||||
|
# Ricarica .bashrc.before per eventuali modifiche al PATH
|
||||||
|
if [ -f "$HOME/.bashrc.before" ]; then
|
||||||
|
source "$HOME/.bashrc.before"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Se abbiamo pyenv, assicuriamoci che il global sia valido
|
||||||
|
if ! feat_missing "pyenv"; then
|
||||||
|
local current latest installed
|
||||||
|
current="$(pyenv global 2>/dev/null)"
|
||||||
|
installed="$(pyenv versions --bare 2>/dev/null | grep -v '^system$')"
|
||||||
|
|
||||||
|
# Cambia global se: vuoto, system, o versione non più installata
|
||||||
|
if [ -z "$current" ] || [ "$current" = "system" ] || ! echo "$installed" | grep -qxF "$current"; then
|
||||||
|
latest="$(echo "$installed" | tail -1)"
|
||||||
|
if [ -n "$latest" ]; then
|
||||||
|
pyenv global "$latest"
|
||||||
|
pyenv rehash >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Se pip funziona, ok
|
||||||
|
if pip --version >/dev/null 2>&1; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Altrimenti installiamo tutto
|
||||||
|
feat_needed "pip"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function pip_feat_missing() {
|
function pip_feat_missing() {
|
||||||
if feat_missing "pip"; then
|
if ! pip --version >/dev/null 2>&1; then
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
! ( pip freeze | grep -q "$1=" )
|
! ( pip freeze | grep -q "$1=" )
|
||||||
|
|
@ -60,7 +91,7 @@ function pip_feat_add() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function pip_feat_needed() {
|
function pip_feat_needed() {
|
||||||
feat_needed "pip"
|
pip_feat_ensure
|
||||||
FEAT="$1"
|
FEAT="$1"
|
||||||
if pip_feat_missing "$FEAT"; then
|
if pip_feat_missing "$FEAT"; then
|
||||||
if type "pip_feat_add_$FEAT" > /dev/null 2>&1 ; then
|
if type "pip_feat_add_$FEAT" > /dev/null 2>&1 ; then
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,11 @@ function poetry_feat_added() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function poetry_feat_missing() {
|
function poetry_feat_missing() {
|
||||||
|
# Ricarica .bashrc.before per eventuali modifiche al PATH
|
||||||
|
if [ -f "$HOME/.bashrc.before" ]; then
|
||||||
|
source "$HOME/.bashrc.before"
|
||||||
|
fi
|
||||||
|
|
||||||
if feat_missing "pip"; then
|
if feat_missing "pip"; then
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
|
|
@ -39,6 +44,11 @@ function poetry_feat_missing() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function poetry_feat_needed() {
|
function poetry_feat_needed() {
|
||||||
|
# Ricarica .bashrc.before per eventuali modifiche al PATH
|
||||||
|
if [ -f "$HOME/.bashrc.before" ]; then
|
||||||
|
source "$HOME/.bashrc.before"
|
||||||
|
fi
|
||||||
|
|
||||||
feat_needed "poetry"
|
feat_needed "poetry"
|
||||||
FEAT="$1"
|
FEAT="$1"
|
||||||
if ! poetry_initialized; then
|
if ! poetry_initialized; then
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue