Skip to content
This repository was archived by the owner on Jan 12, 2025. It is now read-only.

Commit 258f6c6

Browse files
committed
Debugging
1 parent b58c22f commit 258f6c6

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/prettier/install.sh

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,30 @@ $nanolayer_location \
2121

2222
PRETTIER_PLUGINS=${PLUGINS:-""}
2323

24+
setup_npm() {
25+
export NVM_DIR=/usr/local/share/nvm
26+
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
27+
}
28+
29+
install_prettier_plugin() {
30+
echo "Installing prettier plugin - $1"
31+
if ! npm list $1 >/dev/null; then
32+
npm install --save-dev prettier $1
33+
fi
34+
}
35+
2436
# Prettier plugins are expected to be installed locally, not globally
2537
# In particular, VSCode + extensions tend to have issues with this
2638
if [ -n "${PRETTIER_PLUGINS}" ]; then
39+
if ! type npm >/dev/null 2>&1; then
40+
setup_npm
41+
fi
42+
2743
OIFS=$IFS
2844
IFS=','
29-
3045
for plugin in $PRETTIER_PLUGINS; do
31-
echo "Installing ${plugin}"
32-
echo "DEBUG: whoami - $(whoami)"
33-
echo "DEBUG: npm - $(ls /usr/local/share/nvm)"
34-
if ! npm list ${plugin} > /dev/null; then
35-
npm install --save-dev prettier ${plugin}
36-
fi
46+
install_prettier_plugin $plugin
3747
done
38-
3948
IFS=$OIFS
4049
fi
4150

0 commit comments

Comments
 (0)