Skip to content
Merged
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
11 changes: 11 additions & 0 deletions d2bs/kolbot/libs/require.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,24 @@ global.require = (function (include, isIncluded, print, notify) {
directory = "../" + directory; // Add a extra recursive path, as we start out of the lib directory
}

// remove the / from it, in case it was libs/ (rather than lib/) and we now have a leading slash
if (directory.startsWith("/")) {
directory = directory.substr(1);
}

path = path || directory;

let fullpath = removeRelativePath((path + field).replace(/\\/, "/")).toLowerCase();
// remove lib again, if required in e.g. kolbot\tools but wants modules\whatever
if (fullpath.startsWith("lib")) {
fullpath = fullpath.substr(4);
}

// remove the / from it, in case it was libs/ (rather than lib/) and we now have a leading slash
if (fullpath.startsWith("/")) {
fullpath = fullpath.substr(1);
}

const packageName = fullpath;

const asNew = this.__proto__.constructor === require && ((...args) => new (Function.prototype.bind.apply(modules[packageName].exports, args)));
Expand Down
Loading