Skip to content

Instantly share code, notes, and snippets.

@sammachin
Created December 17, 2021 12:27
Show Gist options
  • Save sammachin/2e42b880d94dbb3f9c6eeae334f890b8 to your computer and use it in GitHub Desktop.
Save sammachin/2e42b880d94dbb3f9c6eeae334f890b8 to your computer and use it in GitHub Desktop.
# Launches a Node-RED Instance using the current path as users and nodes dir but using the global settings.js in ~/.node-red
location=$PWD
echo $location
openBrowser() {
sleep 2
open http://127.0.0.1:1880$1
}
if [[ -f $location"/settings.js" ]]
then
settingsFile=$location"/settings.js"
editorPath=`echo "var settings=require('./settings.js'); console.log(settings.httpAdminRoot||'/')" | node`
else
settingsFile=~/.node-red/settings.js
editorPath=`echo "var settings=require('/Users/smachin/.node-red/settings.js'); console.log(settings.httpAdminRoot||'/')" | node`
fi
openBrowser $editorPath &
node-red --userDir $location --nodesDir $location"/nodes" --settings $settingsFile $*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment