From f2ad339a1381fddc1deed411fb499ff8a7655309 Mon Sep 17 00:00:00 2001 From: Nick Farina Date: Wed, 4 Nov 2015 09:47:48 -0800 Subject: [PATCH] CLI setting for custom homebridge "home" path Fixes #378 --- lib/cli.js | 1 + lib/user.js | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib/cli.js b/lib/cli.js index cd75276..2d90e89 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -13,6 +13,7 @@ module.exports = function() { program .version(version) .option('-P, --plugin-path [path]', 'look for plugins installed at [path] as well as the default locations ([path] can also point to a single plugin)', function(p) { Plugin.addPluginPath(p); }) + .option('-H, --homebridge-home [path]', 'look for homebridge user files at [path] instead of the default location (~/.homebridge)', function(p) { User.setStoragePath(p); }) .option('-D, --debug', 'turn on debug level logging', function() { require('./logger').setDebugEnabled(true) }) .parse(process.argv); diff --git a/lib/user.js b/lib/user.js index 8927b45..45679b8 100644 --- a/lib/user.js +++ b/lib/user.js @@ -14,6 +14,9 @@ module.exports = { // global cached config var config; +// optional custom storage path +var customStoragePath; + function User() { } @@ -22,6 +25,7 @@ User.config = function() { } User.storagePath = function() { + if (customStoragePath) return customStoragePath; var home = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE; return path.join(home, ".homebridge"); } @@ -33,3 +37,7 @@ User.configPath = function() { User.persistPath = function() { return path.join(User.storagePath(), "persist"); } + +User.setStoragePath = function(path) { + customStoragePath = path; +} \ No newline at end of file