Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v1.2.4 #75

Merged
merged 2 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).

### Unreleased

### [1.2.3] - 2024-04-26
### [1.2.4] - 2024-04-26

- reader: use path.sep instead of [\\/] to be more obvious
- fix(watch): callback was losing context. Use explicit obj
- fix(reader): use path.sep instead of [\\/] to be more obvious

### [1.2.2] - 2024-04-24

Expand Down Expand Up @@ -129,7 +130,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
- reduce node required 4.3 -> 0.10.43

[1.1.0]: https://github.com/haraka/haraka-config/releases/tag/1.1.0
[1.2.2]: https://github.com/haraka/haraka-config/releases/tag/v1.2.2
[1.2.3]: https://github.com/haraka/haraka-config/releases/tag/v1.2.3
[1.2.0]: https://github.com/haraka/haraka-config/releases/tag/v1.2.0
[1.2.1]: https://github.com/haraka/haraka-config/releases/tag/v1.2.1
[1.2.2]: https://github.com/haraka/haraka-config/releases/tag/v1.2.2
[1.2.4]: https://github.com/haraka/haraka-config/releases/tag/v1.2.4
2 changes: 1 addition & 1 deletion 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">55</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">56</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>
24 changes: 14 additions & 10 deletions lib/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ const enoent = { timer: false, files: [] }
const watchers = {}
const sedation_timers = {}

module.exports.ensure_enoent_timer = (reader) => {
const Watch = {}

Watch.ensure_enoent_timer = (reader) => {
if (enoent.timer) return
// Create timer
enoent.timer = setInterval(() => {
Expand All @@ -19,15 +21,15 @@ module.exports.ensure_enoent_timer = (reader) => {
watchers[file] = fs.watch(
file,
{ persistent: false },
this.onEvent(reader, file, args),
Watch.onEvent(reader, file, args),
)
})
}
}, 60 * 1000)
enoent.timer.unref() // don't block process exit
}

module.exports.file = (reader, name, type, cb, options) => {
Watch.file = (reader, name, type, cb, options) => {
// This works on all OS's, but watch_dir() above is preferred for Linux and
// Windows as it is far more efficient.
// NOTE: we need a fs.watch per file. It's impossible to watch non-existent
Expand All @@ -39,21 +41,21 @@ module.exports.file = (reader, name, type, cb, options) => {
watchers[name] = fs.watch(
name,
{ persistent: false },
this.onEvent(reader, name, { type, options, cb }),
Watch.onEvent(reader, name, { type, options, cb }),
)
} catch (e) {
if (e.code === 'ENOENT') {
// ignore error when ENOENT
enoent.files[name] = true
this.ensure_enoent_timer(reader)
Watch.ensure_enoent_timer(reader)
} else {
console.error(`Error watching config file: ${name} : ${e}`)
}
}
}

// used to watch main haraka config dir
module.exports.dir = (reader) => {
Watch.dir = (reader) => {
// NOTE: Has OS platform limitations:
// https://nodejs.org/api/fs.html#fs_fs_watch_filename_options_listener
const cp = reader.config_path
Expand Down Expand Up @@ -82,7 +84,7 @@ module.exports.dir = (reader) => {
}

// used by getDir
module.exports.dir2 = (reader, dirPath) => {
Watch.dir2 = (reader, dirPath) => {
if (watchers[dirPath]) return
const watchOpts = { persistent: false, recursive: true }

Expand All @@ -105,7 +107,7 @@ module.exports.dir2 = (reader, dirPath) => {
})
}

module.exports.onEvent = (reader, name, args) => {
Watch.onEvent = (reader, name, args) => {
return (fse) => {
if (sedation_timers[name]) {
clearTimeout(sedation_timers[name])
Expand All @@ -126,15 +128,17 @@ module.exports.onEvent = (reader, name, args) => {
watchers[name] = fs.watch(
name,
{ persistent: false },
this.onEvent(...arguments),
Watch.onEvent(reader, name, args),
)
} catch (e) {
if (e.code === 'ENOENT') {
enoent.files[name] = true
this.ensure_enoent_timer(reader)
Watch.ensure_enoent_timer(reader)
} else {
console.error(`Error watching file: ${name} : ${e}`)
}
}
}
}

module.exports = Watch
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "haraka-config",
"license": "MIT",
"description": "Haraka's config file loader",
"version": "1.2.3",
"version": "1.2.4",
"homepage": "http://haraka.github.io",
"repository": {
"type": "git",
Expand Down
Loading