Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
engine = await createConnector(t, hintTest, connector);
const results = await engine.executeOn(new URL(target));
const sources = new Map();
for (const result of results) {
if (!sources.has(result.resource)) {
sources.set(result.resource, await requestSource(result.resource, connector));
}
}
await stopConnector(hintTest, engine);
await server.stop();
return validateResults(t, sources, results, Server.updateLocalhost(reports, server.port));
} catch (e) {
console.error(e);
if (server) {
await server.stop();
}
if (engine) {
await engine.close();
}
return t.fail(`${hintTest.name} throwed an exception:\n${e.message}\n${e.stack}`);
}
};
const runHint = async (t: ExecutionContext, hintTest: HintTest, connector: string) => {
let engine,
server;
try {
server = await Server.create({ configuration: hintTest.serverConfig, isHTTPS: configs.https });
const { serverUrl, reports } = hintTest;
const target = serverUrl ? serverUrl : `${configs.https ? 'https' : 'http'}://localhost:${server.port}/`;
engine = await createConnector(t, hintTest, connector);
const results = await engine.executeOn(new URL(target));
const sources = new Map();
for (const result of results) {
if (!sources.has(result.resource)) {
sources.set(result.resource, await requestSource(result.resource, connector));
}
}
await stopConnector(hintTest, engine);