Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const runHint = async (t: ExecutionContext, hintTest: HintLocalTest) => {
try {
if (hintTest.before) {
await hintTest.before(t);
}
const hintConfig = createConfig(hintId, connector, configs);
const resources = resourceLoader.loadResources(hintConfig);
const engine = new Engine(hintConfig, resources);
// Can assume `getAsUri(hintTest.path)` is not `null` since these are controlled test inputs.
const target = getAsUri(hintTest.path)!;
const results = await engine.executeOn(target);
await engine.close();
if (hintTest.after) {
await hintTest.after(t);
}
const sources = new Map();
for (const result of results) {
if (!sources.has(result.resource)) {
sources.set(result.resource, await requestSource(result.resource, connector));
const createConnector = async (t: ExecutionContext, hintTest: HintTest, connector: string): Promise => {
if (hintTest.before) {
await hintTest.before();
}
const config = createConfig(hintId, connector, configs);
const resources = resourceLoader.loadResources(config);
const engine: Engine = new Engine(config, resources);
return engine;
};