pochade-node-red 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/template/package.json +3 -2
- package/template/watch.sh +55 -0
package/package.json
CHANGED
package/template/package.json
CHANGED
|
@@ -15,8 +15,9 @@
|
|
|
15
15
|
"scripts": {
|
|
16
16
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
17
17
|
"install-plugin": "SRC=$PWD && echo \"Installing from $SRC\" && test -d $HOME/.node-red && (cd $HOME/.node-red && npm install $SRC) || (echo 'Error: $HOME/.node-red not found. Please initialize Node-RED first.' && exit 1)",
|
|
18
|
-
"watch": "nodemon -e js,html --exec \"npm run install-plugin && npm run restart-node-red\"",
|
|
19
|
-
"
|
|
18
|
+
"watch": "nodemon --watch src -e js,html --exec \"npm run install-plugin && npm run restart-node-red\"",
|
|
19
|
+
"start-node-red": "node-red -u $HOME/.node-red",
|
|
20
|
+
"restart-node-red": "pkill -f 'node-red' || true && sleep 2 && node-red -u $HOME/.node-red"
|
|
20
21
|
},
|
|
21
22
|
"devDependencies": {
|
|
22
23
|
"nodemon": "^2.0.22"
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Function to cleanup on exit
|
|
4
|
+
cleanup() {
|
|
5
|
+
echo "Stopping Node-RED..."
|
|
6
|
+
pkill -f 'node-red' 2>/dev/null || true
|
|
7
|
+
exit 0
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
# Trap signals to cleanup
|
|
11
|
+
trap cleanup SIGINT SIGTERM
|
|
12
|
+
|
|
13
|
+
# Initial plugin install
|
|
14
|
+
echo "Installing plugin..."
|
|
15
|
+
npm run install-plugin
|
|
16
|
+
|
|
17
|
+
# Start Node-RED in background
|
|
18
|
+
echo "Starting Node-RED..."
|
|
19
|
+
node-red -u $HOME/.node-red &
|
|
20
|
+
NODE_RED_PID=$!
|
|
21
|
+
|
|
22
|
+
echo "Watching for changes... (Press Ctrl+C to stop)"
|
|
23
|
+
|
|
24
|
+
# Get initial checksum
|
|
25
|
+
get_checksum() {
|
|
26
|
+
find src/ -name "*.js" -o -name "*.html" | xargs md5sum 2>/dev/null | md5sum
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
LAST_CHECKSUM=$(get_checksum)
|
|
30
|
+
|
|
31
|
+
# Watch for changes
|
|
32
|
+
while true; do
|
|
33
|
+
sleep 2
|
|
34
|
+
CURRENT_CHECKSUM=$(get_checksum)
|
|
35
|
+
|
|
36
|
+
if [ "$CURRENT_CHECKSUM" != "$LAST_CHECKSUM" ]; then
|
|
37
|
+
echo "Changes detected, restarting..."
|
|
38
|
+
|
|
39
|
+
# Stop Node-RED
|
|
40
|
+
kill $NODE_RED_PID 2>/dev/null || true
|
|
41
|
+
wait $NODE_RED_PID 2>/dev/null || true
|
|
42
|
+
|
|
43
|
+
# Reinstall plugin
|
|
44
|
+
echo "Reinstalling plugin..."
|
|
45
|
+
npm run install-plugin
|
|
46
|
+
|
|
47
|
+
# Restart Node-RED
|
|
48
|
+
echo "Restarting Node-RED..."
|
|
49
|
+
node-red -u $HOME/.node-red &
|
|
50
|
+
NODE_RED_PID=$!
|
|
51
|
+
|
|
52
|
+
LAST_CHECKSUM=$CURRENT_CHECKSUM
|
|
53
|
+
echo "Node-RED restarted"
|
|
54
|
+
fi
|
|
55
|
+
done
|