Skip to content

Commit 1bffa0c

Browse files
authored
Release v1.2.3 (#74)
- reader: use path.sep instead of [\\/] to be more obvious - for windows compat
1 parent d49f50d commit 1bffa0c

File tree

6 files changed

+27
-26
lines changed

6 files changed

+27
-26
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
44

55
### Unreleased
66

7+
### [1.2.3] - 2024-04-26
8+
9+
- reader: use path.sep instead of [\\/] to be more obvious
10+
711
### [1.2.2] - 2024-04-24
812

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

127131
[1.1.0]: https://github.com/haraka/haraka-config/releases/tag/1.1.0
128132
[1.2.2]: https://github.com/haraka/haraka-config/releases/tag/v1.2.2
133+
[1.2.3]: https://github.com/haraka/haraka-config/releases/tag/v1.2.3
134+
[1.2.0]: https://github.com/haraka/haraka-config/releases/tag/v1.2.0
135+
[1.2.1]: https://github.com/haraka/haraka-config/releases/tag/v1.2.1

CONTRIBUTORS.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This handcrafted artisinal software is brought to you by:
44

5-
| <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>) |
5+
| <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>) |
66
| :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
77

88
<sub>this file is maintained by [.release](https://github.com/msimerson/.release)</sub>

lib/reader.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ class Reader {
3535
}
3636

3737
// when loaded with require('haraka-config')
38-
if (/node_modules\/haraka-config\/lib$/.test(__dirname)) {
38+
if (
39+
__dirname.split(path.sep).slice(-3).toString() ===
40+
'node_modules,haraka-config,lib'
41+
) {
3942
config_dir_candidates = [
4043
path.join(__dirname, '..', '..', '..', 'config'), // haraka/Haraka/*
4144
path.join(__dirname, '..', '..', '..'), // npm packaged modules

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"name": "haraka-config",
44
"license": "MIT",
55
"description": "Haraka's config file loader",
6-
"version": "1.2.2",
6+
"version": "1.2.3",
77
"homepage": "http://haraka.github.io",
88
"repository": {
99
"type": "git",

test/config.js

+11-20
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,10 @@ describe('get', function () {
234234
_test_get('test', null, null, null, null)
235235
})
236236

237-
it('test (non-existing, cached)', function (done) {
237+
it('test (non-existing, cached)', function () {
238238
process.env.WITHOUT_CONFIG_CACHE = ''
239239
const cfg = this.config.get('test', null, null)
240240
assert.deepEqual(cfg, null)
241-
done()
242241
})
243242

244243
it('test.ini, no opts', function () {
@@ -309,13 +308,14 @@ describe('get', function () {
309308
_test_get('test.txt', null, null, null, null)
310309
})
311310

311+
it('test.int', function () {
312+
_test_get('test.int', null, null, null, 6)
313+
})
314+
312315
it('test.flat, type=', function () {
313316
_test_get('test.flat', null, null, null, 'line1')
314317
})
315318

316-
// NOTE: the test.flat file had to be duplicated for these tests, to avoid
317-
// the config cache from returning invalid results.
318-
319319
it('test.flat, type=value', function () {
320320
_test_get('test.value', 'value', null, null, 'line1')
321321
})
@@ -452,20 +452,14 @@ describe('getInt', function () {
452452

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

455-
function cleanup(done) {
456-
fs.unlink(tmpFile, () => {
457-
done()
458-
})
459-
}
460-
461455
describe('getDir', function () {
462456
beforeEach(function (done) {
463457
process.env.NODE_ENV = 'test'
464458
process.env.HARAKA = ''
465459
process.env.WITHOUT_CONFIG_CACHE = '1'
466460
clearRequireCache()
467461
this.config = require('../config')
468-
cleanup(done)
462+
fs.unlink(tmpFile, () => done())
469463
})
470464

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

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

498-
const self = this
487+
// due to differences in fs.watch, this test is not reliable on Mac OS X
488+
if (/darwin/.test(process.platform)) return done()
489+
499490
let callCount = 0
500491

501-
function getDir() {
492+
const getDir = () => {
502493
const opts2 = { type: 'binary', watchCb: getDir }
503-
self.config.getDir('dir', opts2, (err, files) => {
494+
this.config.getDir('dir', opts2, (err, files) => {
504495
// console.log('Loading: test/config/dir');
505496
if (err) console.error(err)
506497
callCount++

test/reader.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,9 @@ describe('reader', function () {
175175
path.resolve('test/config/dir'),
176176
)
177177
assert.deepEqual(result, [
178-
{data: 'contents1', path: '1.ext' },
179-
{data: 'contents2', path: '2.ext' },
180-
{data: 'contents3', path: '3.ext' }
178+
{ data: 'contents1', path: '1.ext' },
179+
{ data: 'contents2', path: '2.ext' },
180+
{ data: 'contents3', path: '3.ext' },
181181
])
182182
})
183183

0 commit comments

Comments
 (0)