1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Don't start if user has no home directory

If the user doesn't have a defined home dir (env var `HOME`,
`USERPROFILE` or `HOMEPATH`) and the `userDir` is not passed on the
command line then we shouldn't start as we don't know where to copy the
default `settings.js` file to or where to store flows

fixes #3539
This commit is contained in:
Ben Hardill 2022-04-21 11:40:12 +01:00
parent 3a26c5cd65
commit 889f0e1569
No known key found for this signature in database
GPG Key ID: 74DD076979ABB1E7

View File

@ -112,6 +112,10 @@ if (parsedArgs.settings) {
// Consider compatibility for older versions
settingsFile = path.join(process.env.HOMEPATH,".node-red","settings.js");
} else {
if (!parsedArgs.userDir && !(process.env.HOME || process.env.USERPROFILE || process.env.HOMEPATH)) {
console.log("User has no Home Directory and no userDir set")
process.exit()
}
var userDir = parsedArgs.userDir || path.join(process.env.HOME || process.env.USERPROFILE || process.env.HOMEPATH,".node-red");
var userSettingsFile = path.join(userDir,"settings.js");
if (fs.existsSync(userSettingsFile)) {