mirror of
https://github.com/mtan93/homebridge.git
synced 2026-04-12 06:13:11 +01:00
Merge pull request #491 from straccio/master
Added pluginPath based on npm
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -10,3 +10,5 @@ npm-debug.log
|
|||||||
# Ignore any extra plugins in the example directory that aren't in Git already
|
# Ignore any extra plugins in the example directory that aren't in Git already
|
||||||
# (this is a sandbox for the user)
|
# (this is a sandbox for the user)
|
||||||
example-plugins
|
example-plugins
|
||||||
|
|
||||||
|
.idea
|
||||||
@@ -67,7 +67,7 @@ Logger.prototype.log = function(level, msg) {
|
|||||||
|
|
||||||
// prepend timestamp
|
// prepend timestamp
|
||||||
var date = new Date();
|
var date = new Date();
|
||||||
msg = "[" + date.toLocaleString() + "]" + " " + msg;
|
msg = chalk.white("[" + date.toLocaleString() + "]") + " " + msg;
|
||||||
|
|
||||||
func(msg);
|
func(msg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,9 +119,10 @@ Plugin.getDefaultPaths = function() {
|
|||||||
} else {
|
} else {
|
||||||
paths.push('/usr/local/lib/node_modules');
|
paths.push('/usr/local/lib/node_modules');
|
||||||
paths.push('/usr/lib/node_modules');
|
paths.push('/usr/lib/node_modules');
|
||||||
|
const exec = require('child_process').execSync;
|
||||||
|
paths.push(exec('/bin/echo -n "$(npm -g prefix)/lib/node_modules"').toString('utf8'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return paths;
|
return paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,14 +166,12 @@ Plugin.installed = function() {
|
|||||||
|
|
||||||
// reconstruct full path
|
// reconstruct full path
|
||||||
var pluginPath = path.join(requirePath, name);
|
var pluginPath = path.join(requirePath, name);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// we only care about directories
|
// we only care about directories
|
||||||
if (!fs.statSync(pluginPath).isDirectory()) continue;
|
if (!fs.statSync(pluginPath).isDirectory()) continue;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// does this module contain a package.json?
|
// does this module contain a package.json?
|
||||||
var pjson;
|
var pjson;
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user