Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const configStreamRaw: Stream = createReadStream(configPath, { encoding: 'utf8' });
let exportVariableName: string = 'urn:comunica:sparqlinit';
if (args.length > 1) {
exportVariableName = args[1];
}
// Hack our require path so that compilation in a monorepo dev environment always works properly
// Otherwise, Components.js will think that we are running inside the 'runner' package,
// and it will use its node_modules.
require.main.paths = [];
const pathParts = mainModulePath.split(sep);
for (let i = pathParts.length; i > 0; i--) {
require.main.paths.push(pathParts.slice(0, i).join(sep) + sep + 'node_modules');
}
compileConfig({ mainModulePath }, configPath, configStreamRaw, configResourceUri, exportVariableName)
.then(console.log).catch((e) => {
console.error(e);
process.exit(1);
});
public static async instantiateComponent(configResourceUrl: string, instanceUri: string,
properties?: ISetupProperties): Promise {
if (!Setup.preparedPromises) {
Setup.preparedPromises = true;
Setup.preparePromises();
}
// Handle optional arguments
if (!properties) {
properties = {};
}
require('lodash.defaults')(properties, { mainModulePath: process.cwd() });
// Instantiate the given config file
const loader = new Loader(properties);
await loader.registerAvailableModuleResources();
return await loader.instantiateFromUrl(instanceUri, configResourceUrl);
}