/
node-package-management.zsh
71 lines (55 loc) · 2.41 KB
/
node-package-management.zsh
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
# -----------------------------------------------------------
# nvm (Node Version Manager)
# - https://github.com/creationix/nvm
#
# TODO: look at https://github.com/nodenv/nodenv/wiki/Alternatives
#
# Note that loading nvm makes starting new shell much slower!
if [ $DISABLE_NVM = "false" ] ; then
if [ -d "$HOME/.nvm" ]; then
# export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
export NVM_DIR="$HOME/.nvm"
# This loads nvm
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
# This loads nvm bash_completion
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
# npq CLI
# "safely* install packages with npm or yarn by auditing them as part of your install process"
# - https://www.npmjs.com/package/npq
# - https://github.com/lirantal/npq
# alias npm='npq-hero'
fi
fi
# -----------------------------------------------------------
# Disable npm package usage tracking
# - https://www.npmjs.com/package/@scarf/scarf
# -----------------------------------------------------------
export SCARF_ANALYTICS=false
# -----------------------------------------------------------
# Yarn
# -----------------------------------------------------------
# Check if `yarn` is available in the user's PATH
if type -p yarn &>/dev/null; then
# Add the install location of global binaries to your PATH
# More details: https://yarnpkg.com/en/docs/cli/global
export PATH="$(yarn global bin):$PATH"
# npq CLI
# "safely* install packages with npm or yarn
# by auditing them as part of your install process"
# - https://www.npmjs.com/package/npq
# - https://github.com/lirantal/npq
# alias yarn="NPQ_PKG_MGR=yarn npq-hero"
# List what (top level) packages are installed globally
alias list-installed-yarn-global-packages="yarn global list --depth=0"
# Update outdated globally installed npm packages
alias update-yarn-global-packages="yarn global upgrade-interactive"
fi
# -----------------------------------------------------------
# npm helpers
# -----------------------------------------------------------
# List what (top level) packages are installed globally
alias list-installed-npm-packages="npm ls -g --depth=0."
# List what globally installed packages are outdated
alias list-outdated-npm-packages="npm outdated -g --depth=0."
# Update outdated globally installed npm packages
alias update-npm-packages="npm update -g"