Skip to content

Commit 96414ff

Browse files
committed
Add init method for storage options
1 parent b1d5257 commit 96414ff

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

index.js

+10
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,25 @@ var Service = require('./lib/Service.js').Service;
44
var Characteristic = require('./lib/Characteristic.js').Characteristic;
55
var uuid = require('./lib/util/uuid');
66
var AccessoryLoader = require('./lib/AccessoryLoader.js');
7+
var storage = require('node-persist');
78

89
// ensure Characteristic subclasses are defined
910
var HomeKitTypes = require('./lib/gen/HomeKitTypes');
1011

1112
module.exports = {
13+
init: init,
1214
Accessory: Accessory,
1315
Bridge: Bridge,
1416
Service: Service,
1517
Characteristic: Characteristic,
1618
uuid: uuid,
1719
AccessoryLoader: AccessoryLoader
20+
}
21+
22+
function init(storagePath) {
23+
// initialize our underlying storage system, passing on the directory if needed
24+
if (typeof storagePath !== 'undefined')
25+
storage.initSync({ dir: storagePath });
26+
else
27+
storage.initSync(); // use whatever is default
1828
}

0 commit comments

Comments
 (0)