<commit_before>#!/usr/bin/env node
"use strict";
var program = require('commander');

/**
 * get command line params
 */

program.usage('[options]')
	.option('-n, --no-live-reload', 'Disable the use of live reload and just use a normal HTTP server');

/**
 * Gather local config, then spawn donejs development server
 */

const user = process.env.USER;

const userConfig = '../config/dev.' + user + '.json';
const defaultConfig = '../config/dev.default.json';

var config;

// load default dev config
try {
	config = require(defaultConfig);
} catch(e) {
	// ingored on purpose, we wanna check for both files
}

// load local dev config
try {
	config = require(userConfig);
} catch(e) {
	// ingored on purpose, we wanna check for both files
}

// config guard
if (!config) {
	console.error('Could not find a suitable config file.  ' +
		'Make sure either ' + userConfig + ' or ' + defaultConfig + ' are available'
	);
	process.exit();
}

// check for port
if (!config['port']) {
	console.error('Config error: could not find port setting');
	process.exit();
}

// check for live reload port
if (!config['live_reload_port'] && program.liveReload) {
	console.error('Config error: could not find live_reload_port setting');
	process.exit();
}

// run can server
const child_process = require("child_process");


console.log(program);
if (program.liveReload) {
	// set the live reload port for use in the UI
	process.env.live_reload_port = config['live_reload_port'];
	
	// set the config array
	let serverOptions = [
		"--develop", // done-ssr development mode

		"--port", config['port'],

		"--live-reload-port", config['live_reload_port']
	];

	if (config['proxy_host']) {
		serverOptions.concat([
			"--proxy", 'https://' + config['proxy_host'] + '/json',
			"--proxy-to", "/json",
			"--proxy-no-cert-check" //do not fail if cert is invalid
		]);
	}

	// spawn done-serve with configs as params
	child_process.spawn(
		"node_modules/.bin/done-serve", serverOptions,
		{stdio: 'inherit'}
	);
} else {
	let http = require('http');
	let devHTML = require('../development.html');
	const handleRequest = function(request, response) {
		response.end(devHTML);
	}
	let server = http.createServer(handleRequest);
	server.listen(config['port']);
}<commit_msg>got startup to work with simple HTTP server for no-live reload<commit_after>#!/usr/bin/env node
"use strict";
var program = require('commander');

/**
 * get command line params
 */

program.usage('[options]')
	.option('-n, --no-live-reload', 'Disable the use of live reload and just use a normal HTTP server')
	.parse(process.argv);

/**
 * Gather local config, then spawn donejs development server
 */

const user = process.env.USER;

const userConfig = '../config/dev.' + user + '.json';
const defaultConfig = '../config/dev.default.json';

var config;

// load default dev config
try {
	config = require(defaultConfig);
} catch(e) {
	// ingored on purpose, we wanna check for both files
}

// load local dev config
try {
	config = require(userConfig);
} catch(e) {
	// ingored on purpose, we wanna check for both files
}

// config guard
if (!config) {
	console.error('Could not find a suitable config file.  ' +
		'Make sure either ' + userConfig + ' or ' + defaultConfig + ' are available'
	);
	process.exit();
}

// check for port
if (!config['port']) {
	console.error('Config error: could not find port setting');
	process.exit();
}

// check for live reload port
if (!config['live_reload_port'] && program.liveReload) {
	console.error('Config error: could not find live_reload_port setting');
	process.exit();
}

// run can server
const child_process = require("child_process");


console.log(program);
if (program.liveReload) {
	// set the live reload port for use in the UI
	process.env.live_reload_port = config['live_reload_port'];
	
	// set the config array
	let serverOptions = [
		"--develop", // done-ssr development mode

		"--port", config['port'],

		"--live-reload-port", config['live_reload_port']
	];

	if (config['proxy_host']) {
		serverOptions.concat([
			"--proxy", 'https://' + config['proxy_host'] + '/json',
			"--proxy-to", "/json",
			"--proxy-no-cert-check" //do not fail if cert is invalid
		]);
	}

	// spawn done-serve with configs as params
	child_process.spawn(
		"node_modules/.bin/done-serve", serverOptions,
		{stdio: 'inherit'}
	);
} else {
	let http = require('http');
	let fs = require('fs');
	let devHTML = fs.readFileSync('development.html', 'utf8');
	const handleRequest = function(request, response) {
		response.end(devHTML);
	}
	let server = http.createServer(handleRequest);
	server.listen(config['port'], function() {
		console.log("Server listening on port: %s", config['port']);						 
	});
}
{'fraction_non_alphanumeric': 0.16098807495741055, 'fraction_numerical': 0.00021294718909710392, 'mean_word_length': 3.8422680412371135, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '3781428', 'n_tokens_mistral': 1545, 'n_tokens_neox': 1467, 'n_words': 446}