From 493957041b04d06888969b65946424ac2ed0f008 Mon Sep 17 00:00:00 2001 From: Matt Simerson Date: Wed, 24 Apr 2024 13:06:12 -0700 Subject: [PATCH] format --- .prettierignore | 1 + CONTRIBUTORS.md | 4 ++-- README.md | 1 + config.js | 2 +- lib/watch.js | 38 +++++++++++++++++--------------------- 5 files changed, 22 insertions(+), 24 deletions(-) create mode 100644 .prettierignore diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..db98bb1 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +test/config/bad.yaml diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 1773cb4..1f02864 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -2,7 +2,7 @@ This handcrafted artisinal software is brought to you by: -|
msimerson (53)|
PSSGCSim (7)|
baudehlo (1)|
Wesitos (1)|
oreoluwa (1)| -| :---: | :---: | :---: | :---: | :---: | +|
msimerson (53) |
PSSGCSim (7) |
baudehlo (1) |
Wesitos (1) |
oreoluwa (1) | +| :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | this file is maintained by [.release](https://github.com/msimerson/.release) diff --git a/README.md b/README.md index 7c6b61b..014514e 100644 --- a/README.md +++ b/README.md @@ -228,6 +228,7 @@ hosts[] = third_host which produces this javascript array: + ```js ['first_host', 'second_host', 'third_host'] ``` diff --git a/config.js b/config.js index 2c8e79d..f1e1fc8 100644 --- a/config.js +++ b/config.js @@ -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]) diff --git a/lib/watch.js b/lib/watch.js index 1277764..3029dd6 100644 --- a/lib/watch.js +++ b/lib/watch.js @@ -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})`) } @@ -141,4 +137,4 @@ module.exports.onEvent = (reader, name, args) => { } } } -} \ No newline at end of file +}