Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function killServers(exitCode) {
logger.info('Cleaning up running servers');
if (seleniumServer) {
logger.info('Closing selenium server');
seleniumServer.kill();
seleniumServer = null;
}
// Catch protractor's "Kitchen Sink" error.
if (exitCode === 199) {
logger.warn('Supressing protractor\'s "kitchen sink" error 199');
exitCode = 0;
}
server.stop();
logger.info(`Execution Time: ${(new Date().getTime() - startTime) / 1000} seconds`);
logger.info(`Exiting process with ${exitCode}`);
process.exit(exitCode || 0);
}
logger.info('Cleaning up running servers');
if (seleniumServer) {
logger.info('Closing selenium server');
seleniumServer.kill();
seleniumServer = null;
}
// Catch protractor's "Kitchen Sink" error.
if (exitCode === 199) {
logger.warn('Supressing protractor\'s "kitchen sink" error 199');
exitCode = 0;
}
server.stop();
logger.info(`Execution Time: ${(new Date().getTime() - start) / 1000} seconds`);
logger.info(`Exiting process with ${exitCode}`);
process.exit(exitCode || 0);
}
logger.info('Cleaning up running servers');
if (seleniumServer) {
logger.info('Closing selenium server');
seleniumServer.kill();
seleniumServer = null;
}
// Catch protractor's "Kitchen Sink" error.
if (exitCode === 199) {
logger.warn('Supressing protractor\'s "kitchen sink" error 199');
exitCode = 0;
}
server.stop();
logger.info(`Execution Time: ${(new Date().getTime() - startTime) / 1000} seconds`);
logger.info(`Exiting process with ${exitCode}`);
process.exit(exitCode || 0);
}
function killServers(exitCode) {
logger.info('Cleaning up running servers');
if (seleniumServer) {
logger.info('Closing selenium server');
seleniumServer.kill();
seleniumServer = null;
}
// Catch protractor's "Kitchen Sink" error.
if (exitCode === 199) {
logger.warn('Supressing protractor\'s "kitchen sink" error 199');
exitCode = 0;
}
server.stop();
logger.info(`Execution Time: ${(new Date().getTime() - start) / 1000} seconds`);
logger.info(`Exiting process with ${exitCode}`);
process.exit(exitCode || 0);
}
const configResolver = require('./utils/config-resolver');
const tsLinter = require('./utils/ts-linter');
const skyPagesConfigUtil = require('../config/sky-pages/sky-pages.config');
const pactServers = require('../utils/pact-servers');
let skyPagesConfig = skyPagesConfigUtil.getSkyPagesConfig(command);
let http = require('http');
let httpProxy = require('http-proxy');
argv = argv || process.argv;
argv.command = command;
let pactPortSeries = [];
let consumedPorts = [];
// get a free port for every config entry, plus one for the proxy
if (!skyPagesConfig.skyux.pacts) {
logger.error('skyux pact failed! pacts does not exist on configuration file.');
process.exit();
}
let getAsyncFunction = (callback) => {
// ports are not consumed until karma starts, so need to keep track of future consumed ports
portfinder.getPortPromise(
{ port: consumedPorts.length === 0 ? 8000 : Math.max(consumedPorts) + 1 }
)
.then((port) => {
consumedPorts.push(port);
callback(null, port);
})
.catch((error) => {
callback(error, null);
});
function killServers(exitCode) {
logger.info('Cleaning up running servers');
if (seleniumServer) {
logger.info('Closing selenium server');
seleniumServer.kill();
seleniumServer = null;
}
// Catch protractor's "Kitchen Sink" error.
if (exitCode === 199) {
logger.warn('Supressing protractor\'s "kitchen sink" error 199');
exitCode = 0;
}
server.stop();
logger.info(`Execution Time: ${(new Date().getTime() - start) / 1000} seconds`);
logger.info(`Exiting process with ${exitCode}`);
process.exit(exitCode || 0);
}
function killServers(exitCode) {
logger.info('Cleaning up running servers');
if (seleniumServer) {
logger.info('Closing selenium server');
seleniumServer.kill();
seleniumServer = null;
}
// Catch protractor's "Kitchen Sink" error.
if (exitCode === 199) {
logger.warn('Supressing protractor\'s "kitchen sink" error 199');
exitCode = 0;
}
server.stop();
logger.info(`Execution Time: ${(new Date().getTime() - startTime) / 1000} seconds`);
logger.info(`Exiting process with ${exitCode}`);
process.exit(exitCode || 0);
}
platform,
skyPagesConfigUtil.outPath(),
''
);
// Using glob so we can find skyux-builder-config regardless of npm install location
let external = glob.sync(getPath(
command,
platform,
process.cwd(),
'node_modules/**/skyux-builder-config/'
));
let config;
if (external.length > 1) {
logger.warn(`Found multiple external config files.`);
external = external.slice(0, 1);
}
if (external.length === 1) {
logger.info(`Using external config ${external[0]}`);
config = external[0];
} else if (fs.existsSync(internal)) {
logger.info(`Using internal config ${internal}`);
config = internal;
} else {
logger.error('Error locating a config file.');
process.exit(1);
}
return config;
}
skyPagesConfig.runtime.pactConfig.pactProxyServer = pactServers.getPactProxyServer();
if (skyPagesConfig.skyux.pacts) {
var i = 0;
skyPagesConfig.skyux.pacts.forEach((pact) => {
// set pact settings not specified in config file
pact.log = pact.log || path.resolve(process.cwd(), 'logs', `pact-${pact.provider}.log`);
pact.dir = pact.dir || path.resolve(process.cwd(), 'pacts');
pact.host = pactServers.getPactServer(pact.provider).host;
pact.port = pactServers.getPactServer(pact.provider).port;
pact.pactFileWriteMode = pact.pactFileWriteMode || 'overwrite';
i++;
});
} else {
logger.error('No pact entry in configuration!');
}
config.set({
frameworks: config.frameworks.concat('pact'),
files: config.files.concat(path.resolve(process.cwd(), 'node_modules/@pact-foundation/pact-web',
`pact-web.js`)),
pact: skyPagesConfig.skyux.pacts,
plugins: config.plugins.concat('@pact-foundation/karma-pact'),
webpack: testWebpackConfig.getWebpackConfig(skyPagesConfig, argv)
});
}
compiler.run((err, stats) => {
if (err) {
return reject(err);
}
const jsonStats = stats.toJson();
if (jsonStats.errors.length) {
return reject(jsonStats.errors);
}
if (jsonStats.warnings.length) {
logger.warn(jsonStats.warnings);
}
// Normal logging is handled by SimpleProgressWebpackPlugin in common.webpack.config.js
resolve(stats);
});
});