<commit_before>'use strict';

/**
 * run backstop tests and generate report
 */

const backstop = require('backstopjs');
const getPort = require('get-port');
const projectPath = require('../lib/utils').getProjectPath();
const serverPath = require('@nitro/app/app/lib/utils').getServerPath();
let isRunning = false;

module.exports = (gulp, plugins) => {
	return () => {
		return getPort()
			.then((port) => {
				const server = plugins.liveServer(serverPath, {
					env: {
						PORT: port,
						NODE_ENV: 'production',
					},
				}, false);

				return server.start()
					.then(() => {}, () => {}, () => {
						if (!isRunning) {
							isRunning = true;
							return backstop('test', {
								config: require(`${projectPath}tests/backstop/backstop.config.js`)({
									port,
								}),
							})
								.then(() => {
									server.stop();
								}).catch(() => {
									server.stop();
									process.exit(1);
								});
						}
					});
			});
	};
};<commit_msg>fix(gulp): Opens compare view in browser also after failed visual-test<commit_after>'use strict';

/**
 * run backstop tests and generate report
 */

const backstop = require('backstopjs');
const getPort = require('get-port');
const projectPath = require('../lib/utils').getProjectPath();
const serverPath = require('@nitro/app/app/lib/utils').getServerPath();
let isRunning = false;

module.exports = (gulp, plugins) => {
	return () => {
		return getPort()
			.then((port) => {
				const server = plugins.liveServer(serverPath, {
					env: {
						PORT: port,
						NODE_ENV: 'production',
					},
				}, false);

				return server.start()
					.then(() => {}, () => {}, () => {
						if (!isRunning) {
							isRunning = true;
							return backstop('test', {
								config: require(`${projectPath}tests/backstop/backstop.config.js`)({
									port,
								}),
							})
								.then(() => {
									server.stop();
									return true;
								}).catch(() => {
									server.stop();
									return false;
								});
						}
					});
			});
	};
};
{'fraction_non_alphanumeric': 0.1892156862745098, 'fraction_numerical': 0.0004901960784313725, 'mean_word_length': 2.334967320261438, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3420072', 'n_tokens_mistral': 897, 'n_tokens_neox': 618, 'n_words': 124}