mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-25 23:42:23 -05:00
21 lines
688 B
JavaScript
21 lines
688 B
JavaScript
const Module = require('module');
|
|
|
|
const callsite = require('callsite');
|
|
const path = require('path');
|
|
|
|
const oldRequire = Module.prototype.require;
|
|
Module.prototype.require = function (target) {
|
|
if (target.indexOf('/') === -1) {
|
|
// we really do just want to forward the arguments here
|
|
// eslint-disable-next-line prefer-rest-params
|
|
return oldRequire.apply(this, arguments);
|
|
}
|
|
|
|
const stack = callsite();
|
|
const callerFile = stack[2].getFileName();
|
|
const callerDir = path.dirname(callerFile);
|
|
target = path.resolve(callerDir, target);
|
|
return oldRequire.call(this, target);
|
|
};
|
|
|
|
oldRequire(path.resolve(__dirname, 'dispatch-test-worker'));
|