Skip to content

Commit 5483ef6

Browse files
committed
tweaks to script to list installed nodes
1. `npm list --depth=0 --parseable` was displaying an alert that the user really can do nothing about: ``` npm ERR! extraneous: [email protected] /usr/src/node-red/node_modules/node-red-node-email/node_modules/libmime ``` Suppress by redirecting stderr to null. 2. Construct command needed to remove blocking nodes and output it as a hint at the end of the run. Signed-off-by: Phill Kelley <[email protected]>
1 parent 0e537cc commit 5483ef6

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

scripts/nodered_list_installed_nodes.sh

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,15 @@ PERSISTENT_EXTERNAL="$HOME/IOTstack/volumes/nodered/data"
1010
# the folder in each case containing node modules
1111
MODULES="node_modules"
1212

13+
# assume no modules are blocked
14+
unset BLOCKED
15+
16+
# start the command hint
17+
UNBLOCK="docker exec -w /data nodered npm uninstall"
18+
1319
# fetch what npm knows about components that form part of the image
1420
echo -e "\nFetching list of candidates installed via Dockerfile"
15-
CANDIDATES=$(docker exec nodered bash -c "cd \"$DOCKERFILE\" ; npm list --depth=0 --parseable")
21+
CANDIDATES=$(docker exec nodered bash -c "cd \"$DOCKERFILE\" ; npm list --depth=0 --parseable 2>/dev/null")
1622

1723
# report
1824
echo -e "\nComponents built into the image (via Dockerfile)"
@@ -23,6 +29,8 @@ for CANDIDATE in $CANDIDATES; do
2329
if [ -d "$PERSISTENT_EXTERNAL/$MODULES/$COMPONENT" ] ; then
2430
# yes! the internal node is blocked by the external node
2531
echo " BLOCKED: $COMPONENT"
32+
BLOCKED=true
33+
UNBLOCK="$UNBLOCK $COMPONENT"
2634
else
2735
# no! so that means it's active
2836
echo " ACTIVE: $COMPONENT"
@@ -45,3 +53,9 @@ for CANDIDATE in $CANDIDATES; do
4553
done
4654

4755
echo ""
56+
57+
if [ -n "$BLOCKED" ] ; then
58+
echo "Blocking nodes can be removed by running the following commands"
59+
echo "\$ $UNBLOCK"
60+
echo "\$ docker-compose -f ~/IOTstack/docker-compose.yml restart nodered"
61+
fi

0 commit comments

Comments
 (0)