Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson committed Apr 24, 2024
1 parent c597600 commit 4939570
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 24 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
test/config/bad.yaml
4 changes: 2 additions & 2 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This handcrafted artisinal software is brought to you by:

| <img height="80" src="https://avatars.githubusercontent.com/u/261635?v=4"><br><a href="https://github.com/msimerson">msimerson</a> (<a href="https://github.com/haraka/haraka-config/commits?author=msimerson">53</a>)| <img height="80" src="https://avatars.githubusercontent.com/u/42121756?v=4"><br><a href="https://github.com/PSSGCSim">PSSGCSim</a> (<a href="https://github.com/haraka/haraka-config/commits?author=PSSGCSim">7</a>)| <img height="80" src="https://avatars.githubusercontent.com/u/662371?v=4"><br><a href="https://github.com/baudehlo">baudehlo</a> (<a href="https://github.com/haraka/haraka-config/commits?author=baudehlo">1</a>)| <img height="80" src="https://avatars.githubusercontent.com/u/651048?v=4"><br><a href="https://github.com/Wesitos">Wesitos</a> (<a href="https://github.com/haraka/haraka-config/commits?author=Wesitos">1</a>)| <img height="80" src="https://avatars.githubusercontent.com/u/2270015?v=4"><br><a href="https://github.com/oreoluwa">oreoluwa</a> (<a href="https://github.com/haraka/haraka-config/commits?author=oreoluwa">1</a>)|
| :---: | :---: | :---: | :---: | :---: |
| <img height="80" src="https://avatars.githubusercontent.com/u/261635?v=4"><br><a href="https://github.com/msimerson">msimerson</a> (<a href="https://github.com/haraka/haraka-config/commits?author=msimerson">53</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/42121756?v=4"><br><a href="https://github.com/PSSGCSim">PSSGCSim</a> (<a href="https://github.com/haraka/haraka-config/commits?author=PSSGCSim">7</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/662371?v=4"><br><a href="https://github.com/baudehlo">baudehlo</a> (<a href="https://github.com/haraka/haraka-config/commits?author=baudehlo">1</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/651048?v=4"><br><a href="https://github.com/Wesitos">Wesitos</a> (<a href="https://github.com/haraka/haraka-config/commits?author=Wesitos">1</a>) | <img height="80" src="https://avatars.githubusercontent.com/u/2270015?v=4"><br><a href="https://github.com/oreoluwa">oreoluwa</a> (<a href="https://github.com/haraka/haraka-config/commits?author=oreoluwa">1</a>) |
| :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |

<sub>this file is maintained by [.release](https://github.com/msimerson/.release)</sub>
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ hosts[] = third_host

which produces this javascript array:

<!-- prettier-ignore -->
```js
['first_host', 'second_host', 'third_host']
```
Expand Down
2 changes: 1 addition & 1 deletion config.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function merge_config(defaults, overrides, type) {

function merge_struct(defaults, overrides) {
for (const k in overrides) {
if (['__proto__', 'constructor'].includes(k)) continue;
if (['__proto__', 'constructor'].includes(k)) continue
if (k in defaults) {
if (typeof overrides[k] === 'object' && typeof defaults[k] === 'object') {
defaults[k] = merge_struct(defaults[k], overrides[k])
Expand Down
38 changes: 17 additions & 21 deletions lib/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,26 +60,22 @@ module.exports.dir = (reader) => {
if (watchers[cp]) return

try {
watchers[cp] = fs.watch(
cp,
{ persistent: false },
(fse, filename) => {
if (!filename) return
const full_path = path.join(cp, filename)
const args = reader._read_args[full_path]
if (!args) return
if (args.options?.no_watch) return
if (sedation_timers[filename]) {
clearTimeout(sedation_timers[filename])
}
sedation_timers[filename] = setTimeout(() => {
console.log(`Reloading file: ${full_path}`)
reader.load_config(full_path, args.type, args.options)
delete sedation_timers[filename]
if (typeof args.cb === 'function') args.cb()
}, 5 * 1000)
},
)
watchers[cp] = fs.watch(cp, { persistent: false }, (fse, filename) => {
if (!filename) return
const full_path = path.join(cp, filename)
const args = reader._read_args[full_path]
if (!args) return
if (args.options?.no_watch) return
if (sedation_timers[filename]) {
clearTimeout(sedation_timers[filename])
}
sedation_timers[filename] = setTimeout(() => {
console.log(`Reloading file: ${full_path}`)
reader.load_config(full_path, args.type, args.options)
delete sedation_timers[filename]
if (typeof args.cb === 'function') args.cb()
}, 5 * 1000)
})
} catch (e) {
console.error(`Error watching directory ${cp}(${e})`)
}
Expand Down Expand Up @@ -141,4 +137,4 @@ module.exports.onEvent = (reader, name, args) => {
}
}
}
}
}

0 comments on commit 4939570

Please sign in to comment.