Skip to content

Commit

Permalink
restore block scope
Browse files Browse the repository at this point in the history
  • Loading branch information
msimerson committed Apr 15, 2024
1 parent 4648566 commit 5cb9c10
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions configfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,19 +272,22 @@ class cfreader {
if (this._enoent_timer) return
// Create timer
this._enoent_timer = setInterval(() => {
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),
)
})
for (const fileOuter of Object.keys(this._enoent_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
}
}, 60 * 1000)
this._enoent_timer.unref() // This shouldn't block exit
Expand Down

0 comments on commit 5cb9c10

Please sign in to comment.