Skip to content

Commit

Permalink
Finish #2201.
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk committed Oct 25, 2019
1 parent 505be31 commit 78531a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/util/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ function write() {

// Read settings to check if we have to split devices/groups into separate file.
const actual = yaml.read(file);
if (actual.mqtt && actual.mqtt.password && actual.mqtt.user) {
toWrite.mqtt.user = actual.mqtt.user;
toWrite.mqtt.password = actual.mqtt.password;
}

if (typeof actual.devices === 'string') {
yaml.writeIfChanged(data.joinPath(actual.devices), settings.devices);
toWrite.devices = actual.devices;
Expand Down Expand Up @@ -581,6 +586,7 @@ module.exports = {
changeFriendlyName,

// For tests only
_write: write,
_reRead: () => {
_settings = read();
_settingsWithDefaults = objectAssignDeep.noMutate(defaults, get());
Expand Down
3 changes: 3 additions & 0 deletions test/settings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ describe('Settings', () => {
};

expect(settings.get().mqtt).toStrictEqual(expected);

settings._write();
expect(read(configurationFile)).toStrictEqual(contentConfiguration);
});

it('Should read devices form a separate file', () => {
Expand Down

0 comments on commit 78531a0

Please sign in to comment.