SamVerschueren/mongoose-seeder

Dependencies are added to the global scope

Closed this issue · 1 comments

The code to require the dependencies looks like this

_.forEach(data._dependencies || {}, function(value, key) {
    if(global[key] !== undefined) {
        console.error('The variable \'' + key + '\' already exists.');
        return;
    }

    global[key] = require(value);
});

As you can see, they are attached to the global scope which might interfere with others. Any ideas on how the scope of the variables could be limited to the _seed function?

It is possible by using the vm package of NodeJS. https://nodejs.org/api/vm.html