Skip to content

Commit

Permalink
- vm_harness: add ability to find local files in root of plugin direc…
Browse files Browse the repository at this point in the history
…tory
  • Loading branch information
nickolson committed Sep 26, 2024
1 parent 37f19b4 commit ff472ea
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/vm_harness.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ const vm = require('vm')
const dir_paths = [
`${__dirname}/../../../`, // for Haraka/tests/plugins
`${__dirname}/`, // for haraka-test-fixtures/test
`${__dirname}/../../../../../`, // for files in Haraka/
]

function dot_files(element) {
return element.match(/^\./) == null
}

function find_haraka_lib(id) {
// For local files in the project root directory
// e.g. "require('./example.js')"
if (id.includes('./') && id.includes('.js')) {
id = id.substring(2, (id.length - 3))
}
for (let i = 0; i < dir_paths.length; i++) {
const dirPath = `${dir_paths[i]}${id}.js`
// console.log('dirPath: ' + dirPath);
Expand Down

0 comments on commit ff472ea

Please sign in to comment.