Skip to content

Commit

Permalink
remove block scoping
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson committed Apr 15, 2024
1 parent aa1c079 commit f575840
Showing 1 changed file with 13 additions and 17 deletions.
30 changes: 13 additions & 17 deletions configfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,23 +251,19 @@ class cfreader {
if (this._enoent_timer) return
// Create timer
this._enoent_timer = setInterval(() => {
const files = Object.keys(this._enoent_files)
for (const fileOuter of files) {
/* BLOCK SCOPE */
;((file) => {
fs.stat(file, (err) => {
if (err) return
// File now exists
delete this._enoent_files[file]
const args = this._read_args[file]
this.load_config(file, args.type, args.options, args.cb)
this._watchers[file] = fs.watch(
file,
{ persistent: false },
this.on_watch_event(file, args.type, args.options, args.cb),
)
})
})(fileOuter) // END BLOCK SCOPE
for (const file of Object.keys(this._enoent_files)) {
fs.stat(file, (err) => {
if (err) return
// File now exists
delete this._enoent_files[file]
const args = this._read_args[file]
this.load_config(file, args.type, args.options, args.cb)
this._watchers[file] = fs.watch(
file,
{ persistent: false },
this.on_watch_event(file, args.type, args.options, args.cb),
)
})
}
}, 60 * 1000)
this._enoent_timer.unref() // This shouldn't block exit
Expand Down

0 comments on commit f575840

Please sign in to comment.