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.3 #74

Merged
merged 3 commits into from
Apr 26, 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
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).

### Unreleased

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

- reader: use path.sep instead of [\\/] to be more obvious

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

- feat: getDir can parse different types of files in a dir
Expand Down Expand Up @@ -126,3 +130,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).

[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
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">54</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">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>) |
| :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |

<sub>this file is maintained by [.release](https://github.com/msimerson/.release)</sub>
5 changes: 4 additions & 1 deletion lib/reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ class Reader {
}

// when loaded with require('haraka-config')
if (/node_modules\/haraka-config\/lib$/.test(__dirname)) {
if (
__dirname.split(path.sep).slice(-3).toString() ===
'node_modules,haraka-config,lib'
) {
config_dir_candidates = [
path.join(__dirname, '..', '..', '..', 'config'), // haraka/Haraka/*
path.join(__dirname, '..', '..', '..'), // npm packaged modules
Expand Down
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.2",
"version": "1.2.3",
"homepage": "http://haraka.github.io",
"repository": {
"type": "git",
Expand Down
31 changes: 11 additions & 20 deletions test/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,10 @@ describe('get', function () {
_test_get('test', null, null, null, null)
})

it('test (non-existing, cached)', function (done) {
it('test (non-existing, cached)', function () {
process.env.WITHOUT_CONFIG_CACHE = ''
const cfg = this.config.get('test', null, null)
assert.deepEqual(cfg, null)
done()
})

it('test.ini, no opts', function () {
Expand Down Expand Up @@ -309,13 +308,14 @@ describe('get', function () {
_test_get('test.txt', null, null, null, null)
})

it('test.int', function () {
_test_get('test.int', null, null, null, 6)
})

it('test.flat, type=', function () {
_test_get('test.flat', null, null, null, 'line1')
})

// NOTE: the test.flat file had to be duplicated for these tests, to avoid
// the config cache from returning invalid results.

it('test.flat, type=value', function () {
_test_get('test.value', 'value', null, null, 'line1')
})
Expand Down Expand Up @@ -452,20 +452,14 @@ describe('getInt', function () {

const tmpFile = path.resolve('test', 'config', 'dir', '4.ext')

function cleanup(done) {
fs.unlink(tmpFile, () => {
done()
})
}

describe('getDir', function () {
beforeEach(function (done) {
process.env.NODE_ENV = 'test'
process.env.HARAKA = ''
process.env.WITHOUT_CONFIG_CACHE = '1'
clearRequireCache()
this.config = require('../config')
cleanup(done)
fs.unlink(tmpFile, () => done())
})

it('loads all files in dir', function (done) {
Expand All @@ -489,18 +483,15 @@ describe('getDir', function () {

it('reloads when file in dir is touched', function (done) {
this.timeout(3500)
if (/darwin/.test(process.platform)) {
// due to differences in fs.watch, this test is not reliable on Mac OS X
done()
return
}

const self = this
// due to differences in fs.watch, this test is not reliable on Mac OS X
if (/darwin/.test(process.platform)) return done()

let callCount = 0

function getDir() {
const getDir = () => {
const opts2 = { type: 'binary', watchCb: getDir }
self.config.getDir('dir', opts2, (err, files) => {
this.config.getDir('dir', opts2, (err, files) => {
// console.log('Loading: test/config/dir');
if (err) console.error(err)
callCount++
Expand Down
6 changes: 3 additions & 3 deletions test/reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ describe('reader', function () {
path.resolve('test/config/dir'),
)
assert.deepEqual(result, [
{data: 'contents1', path: '1.ext' },
{data: 'contents2', path: '2.ext' },
{data: 'contents3', path: '3.ext' }
{ data: 'contents1', path: '1.ext' },
{ data: 'contents2', path: '2.ext' },
{ data: 'contents3', path: '3.ext' },
])
})

Expand Down
Loading