Skip to content

Commit

Permalink
Release v1.2.2 (#73)
Browse files Browse the repository at this point in the history
- fix default path
- fix getDir result
  • Loading branch information
msimerson committed Apr 24, 2024
1 parent 35e1325 commit d49f50d
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 26 deletions.
10 changes: 3 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).

### Unreleased

### [1.2.1] - 2024-04-24

- config: guard against prototype pollution

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

- feat: getDir can parse different types of files in a dir
- feat: all file readers now have load and loadPromise, so that
Expand All @@ -29,6 +25,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
- lint: remove duplicate / stale rules from .eslintrc
- package.json: populate [files]
- deps: version bumps
- config: guard against prototype pollution

### [1.1.0] - 2022-05-27

Expand Down Expand Up @@ -128,5 +125,4 @@ 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.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
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">53</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">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>) |
| :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |

<sub>this file is maintained by [.release](https://github.com/msimerson/.release)</sub>
17 changes: 9 additions & 8 deletions lib/reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ class Reader {
return
}

// these work when this is loaded with require('haraka-config')
if (/node_modules[\\/]haraka-config$/.test(__dirname)) {
// when loaded with require('haraka-config')
if (/node_modules\/haraka-config\/lib$/.test(__dirname)) {
config_dir_candidates = [
path.join(__dirname, '..', '..', 'config'), // haraka/Haraka/*
path.join(__dirname, '..', '..'), // npm packaged modules
path.join(__dirname, '..', '..', '..', 'config'), // haraka/Haraka/*
path.join(__dirname, '..', '..', '..'), // npm packaged modules
]
}

Expand All @@ -50,7 +50,7 @@ class Reader {
return
}
} catch (ignore) {
console.error(ignore.message)
// console.error(ignore.message)
}
}
}
Expand Down Expand Up @@ -146,9 +146,10 @@ class Reader {
const contents = []
for (const file of fileList) {
const type = opts.type ?? this.getType(file)
contents.push(
this.load_config(path.resolve(name, file), type, opts),
)
contents.push({
path: file,
data: this.load_config(path.resolve(name, file), type, opts),
})
}
return contents
})
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.1",
"version": "1.2.2",
"homepage": "http://haraka.github.io",
"repository": {
"type": "git",
Expand Down
10 changes: 5 additions & 5 deletions test/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,8 +474,8 @@ describe('getDir', function () {
assert.ifError(err)
assert.equal(err, null)
assert.equal(files.length, 3)
assert.equal(files[0], `contents1${os.EOL}`)
assert.equal(files[2], `contents3${os.EOL}`)
assert.equal(files[0].data, `contents1${os.EOL}`)
assert.equal(files[2].data, `contents3${os.EOL}`)
done()
})
})
Expand Down Expand Up @@ -508,15 +508,15 @@ describe('getDir', function () {
// console.log(files);
assert.equal(err, null)
assert.equal(files.length, 3)
assert.equal(files[0], `contents1${os.EOL}`)
assert.equal(files[2], `contents3${os.EOL}`)
assert.equal(files[0].data, `contents1${os.EOL}`)
assert.equal(files[2].data, `contents3${os.EOL}`)
fs.writeFile(tmpFile, 'contents4\n', (err2) => {
assert.equal(err2, null)
// console.log('file touched, waiting for callback');
})
}
if (callCount === 2) {
assert.equal(files[3], 'contents4\n')
assert.equal(files[3].data, 'contents4\n')
fs.unlink(tmpFile, () => {})
done()
}
Expand Down
13 changes: 9 additions & 4 deletions test/configfile.js → test/reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,19 +169,23 @@ describe('reader', function () {
})

describe('read_dir', function () {
it.skip('returns dir contents', async function () {
it('returns dir contents', async function () {
// may have race collission with config.getDir test
const result = await this.cfreader.read_dir(
path.resolve('test/config/dir'),
)
assert.deepEqual(result, ['contents1', 'contents2', 'contents3'])
assert.deepEqual(result, [
{data: 'contents1', path: '1.ext' },
{data: 'contents2', path: '2.ext' },
{data: 'contents3', path: '3.ext' }
])
})

it('returns dir with mixed types', async function () {
const result = await this.cfreader.read_dir('test/config/mixed')
assert.deepEqual(result, [
{ main: {}, sect: { one: 'true' } },
{ main: { two: false } },
{ data: { main: {}, sect: { one: 'true' } }, path: '1.ini' },
{ data: { main: { two: false } }, path: '2.yml' },
])
})
})
Expand Down Expand Up @@ -340,6 +344,7 @@ describe('reader', function () {
})

it('NODE_ENV=test', function () {
delete process.env.HARAKA
process.env.NODE_ENV = 'test'
this.cfreader.get_path_to_config_dir()
assert.ok(
Expand Down

0 comments on commit d49f50d

Please sign in to comment.