mirror of
https://github.com/mtan93/homebridge.git
synced 2026-03-17 13:20:57 +00:00
Convert to ES5, add web server
* No compilation step * Beginnings of web interface * Simple express server; React-based frontend * CommonJS style across codebase; auto-converts to RequireJS for browser * Using diffsync for realtime UI * "Provider" -> "Plugin" * Plugins expose one or more Providers
This commit is contained in:
55
lib/user.js
55
lib/user.js
@@ -1,31 +1,32 @@
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import { Config } from './config';
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
var Config = require('./Config').Config;
|
||||
|
||||
//
|
||||
// Manages user settings and storage locations.
|
||||
//
|
||||
'use strict';
|
||||
|
||||
// global cached config
|
||||
let config;
|
||||
|
||||
export class User {
|
||||
|
||||
static get config() {
|
||||
return config || (config = Config.load(User.configPath));
|
||||
}
|
||||
|
||||
static get storagePath() {
|
||||
let home = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE;
|
||||
return path.join(home, ".homebridge");
|
||||
}
|
||||
|
||||
static get configPath() {
|
||||
return path.join(User.storagePath, "config.json");
|
||||
}
|
||||
|
||||
static get providersPath() {
|
||||
return path.join(User.storagePath, "providers");
|
||||
}
|
||||
module.exports = {
|
||||
User: User
|
||||
}
|
||||
|
||||
/**
|
||||
* Manages user settings and storage locations.
|
||||
*/
|
||||
|
||||
// global cached config
|
||||
var config;
|
||||
|
||||
function User() {
|
||||
}
|
||||
|
||||
User.config = function() {
|
||||
return config || (config = Config.load(User.configPath()));
|
||||
}
|
||||
|
||||
User.storagePath = function() {
|
||||
var home = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE;
|
||||
return path.join(home, ".homebridge");
|
||||
}
|
||||
|
||||
User.configPath = function() {
|
||||
return path.join(User.storagePath(), "config.json");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user