MCPcopy
hub / github.com/patriksimek/vm2 / customResolve

Method customResolve

lib/resolver-compat.js:183–197  ·  view source on GitHub ↗
(x, path, extList)

Source from the content-addressed store, hash-verified

181 }
182
183 customResolve(x, path, extList) {
184 if (this.customResolver === undefined) return undefined;
185 if (!(this.pathIsAbsolute(x) || this.pathIsRelative(x))) {
186 if (!this.externalCache.some(regex => regex.test(x))) return undefined;
187 }
188 const resolved = this.customResolver(x, path);
189 if (!resolved) return undefined;
190 if (typeof resolved === 'string') {
191 this.externals.push(new RegExp('^' + escapeRegExp(resolved)));
192 return this.loadAsFileOrDirectory(resolved, extList);
193 }
194 const {module=x, path: resolvedPath} = resolved;
195 this.externals.push(new RegExp('^' + escapeRegExp(resolvedPath)));
196 return this.loadNodeModules(module, [resolvedPath], extList);
197 }
198
199}
200

Callers

nothing calls this directly

Calls 5

escapeRegExpFunction · 0.85
pathIsAbsoluteMethod · 0.80
pathIsRelativeMethod · 0.80
loadAsFileOrDirectoryMethod · 0.80
loadNodeModulesMethod · 0.80

Tested by

no test coverage detected