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

vm_harness: access local files in plugin directory #68

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
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
Loading