Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let result;
// TODO: Check if there's a better way to check if resolved path is a module
const isModule = request.descriptionFileRoot !== this.localDescriptionFileRoot;
// Array.from(resolveContext.stack).some(x => x.startsWith('module: '));
if (isModule) {
const relative = path.relative(path.dirname(request.descriptionFileRoot), request.path);
result = `node_modules/${relative}`;
} else {
result = path.relative(this.luaRoot, request.path);
if (result.startsWith('..') || path.isAbsolute(result)) {
throw new Error(`Couldn't resolve path "${request.path}" within luaRoot`);
}
}
result = path.toUnix(path.trimExt(result));
if (result.includes('.')) {
throw new Error(`Resolved path shouldn't contain dots`);
}
result = result.replace(/\//g, '.');
request.path = result;
return request;
});
}
function getPathWithoutExtension(input) {
return path.trimExt(input);
}
function getPathWithoutExtension(input) {
return path.trimExt(input);
}