traxxx/src/utils/virtual-console.js

19 lines
576 B
JavaScript
Raw Normal View History

'use strict';
const { VirtualConsole } = require('jsdom');
const path = require('path');
const logger = require('../logger')(__filename);
function getVirtualConsole(filepath) {
const virtualConsole = new VirtualConsole();
const context = path.basename(filepath).replace(path.extname(filepath), '');
2021-11-20 22:59:15 +00:00
virtualConsole.on('error', (message) => logger.warn(`Error from JSDOM in ${context}: ${message}`));
virtualConsole.on('jsdomError', (message) => logger.warn(`Error from JSDOM in ${context}: ${message}`));
return virtualConsole;
}
module.exports = getVirtualConsole;