mirror of
https://github.com/mtan93/homebridge.git
synced 2026-03-08 05:31:55 +00:00
Better handling of custom plugin paths
This commit is contained in:
@@ -12,7 +12,7 @@ module.exports = function() {
|
|||||||
|
|
||||||
program
|
program
|
||||||
.version(version)
|
.version(version)
|
||||||
.option('-P, --plugin-path [path]', 'look for plugins installed at [path] as well as node_modules', function(p) { Plugin.addPluginPath(p); })
|
.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('-D, --debug', 'turn on debug level logging', function() { logger.setDebugEnabled(true) })
|
.option('-D, --debug', 'turn on debug level logging', function() { logger.setDebugEnabled(true) })
|
||||||
.parse(process.argv);
|
.parse(process.argv);
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ var fs = require('fs');
|
|||||||
var semver = require('semver');
|
var semver = require('semver');
|
||||||
var User = require('./user').User;
|
var User = require('./user').User;
|
||||||
var version = require('./version');
|
var version = require('./version');
|
||||||
|
var log = require("./logger")._system;
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
@@ -162,20 +163,27 @@ Plugin.installed = function() {
|
|||||||
if (!fs.statSync(pluginPath).isDirectory()) continue;
|
if (!fs.statSync(pluginPath).isDirectory()) continue;
|
||||||
|
|
||||||
// does this module contain a package.json?
|
// does this module contain a package.json?
|
||||||
|
var pjson;
|
||||||
try {
|
try {
|
||||||
// throws an Error if this isn't a homebridge plugin
|
// throws an Error if this isn't a homebridge plugin
|
||||||
Plugin.loadPackageJSON(pluginPath);
|
pjson = Plugin.loadPackageJSON(pluginPath);
|
||||||
}
|
}
|
||||||
catch (err) {
|
catch (err) {
|
||||||
// swallow error and skip this module
|
// swallow error and skip this module
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get actual name if this path points inside a single plugin
|
||||||
|
if (!name) name = pjson.name;
|
||||||
|
|
||||||
// add it to the return list
|
// add it to the return list
|
||||||
if (!pluginsByName[name]) {
|
if (!pluginsByName[name]) {
|
||||||
pluginsByName[name] = true;
|
pluginsByName[name] = pluginPath;
|
||||||
plugins.push(new Plugin(pluginPath));
|
plugins.push(new Plugin(pluginPath));
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
log.warn("Warning: skipping plugin found at '" + pluginPath + "' since we already loaded the same plugin from '" + pluginsByName[name] + "'.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "homebridge",
|
"name": "homebridge",
|
||||||
"description": "HomeKit support for the impatient",
|
"description": "HomeKit support for the impatient",
|
||||||
"version": "0.2.0",
|
"version": "0.2.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "DEBUG=* ./bin/homebridge -P example-plugins/ || true"
|
"dev": "DEBUG=* ./bin/homebridge -P example-plugins/ || true"
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user