From dd22111c479baf14e578cf9c85a8f60eec375f7f Mon Sep 17 00:00:00 2001 From: Thiago Mendonca Date: Sun, 19 Mar 2023 17:58:55 +0100 Subject: [PATCH] feat(symlinks,tools): add npmrc tool and config to change npmrc config base on env variable --- symlinks/.npmrc | 6 ------ symlinks/.zshrc | 18 ++++++++++++++++++ tools/npm-global-tools.sh | 6 +++--- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/symlinks/.npmrc b/symlinks/.npmrc index 97dad07..e69de29 100644 --- a/symlinks/.npmrc +++ b/symlinks/.npmrc @@ -1,6 +0,0 @@ -registry=${NPM_REGISTRY_URL} -always-auth=${NPM_ALWAYS_AUTH} -email=${NPM_EMAIL} -scripts-prepend-node-path=${NPM_SCRIPTS_PREPEND_NODE_PATH} -_auth=${NPM_AUTH} -audit=${NPM_AUDIT} \ No newline at end of file diff --git a/symlinks/.zshrc b/symlinks/.zshrc index 03290cf..627baf9 100644 --- a/symlinks/.zshrc +++ b/symlinks/.zshrc @@ -148,6 +148,24 @@ eval "$(mcfly init zsh)" source "${XDG_CONFIG_HOME:-$HOME/.config}/asdf-direnv/zshrc" +# Handle nppmrc config according to ENV variable +autoload -U add-zsh-hook + +set-npmrc-config-hook() { + + if ! type npmrc > /dev/null; then + return + fi + + if [ -z ${NPMRC_NAME+x} ]; then + npmrc default > /dev/null; + else + npmrc $NPMRC_NAME > /dev/null; + fi +} + +add-zsh-hook chpwd set-npmrc-config-hook + # Maybe this shoudl be necessary if it does not auto load in IDEs, for example #asdf exec direnv reload diff --git a/tools/npm-global-tools.sh b/tools/npm-global-tools.sh index b6c4143..2d631b7 100644 --- a/tools/npm-global-tools.sh +++ b/tools/npm-global-tools.sh @@ -16,12 +16,12 @@ install() { success "'fkill' installed." - info "Installing npm tool 'emoj'" + info "Installing npm tool 'npmrc'" # Install - npm install --global emoj + npm install --global npmrc - success "'emoj' installed." + success "'npmrc' installed." info "Installing npm tool 'qnm'"