<commit_before>"use strict";

// REQUIREMENTS
var path       = require('path');
var http       = require('http');

var nodeStatic = require('node-static');
var colors     = require('colors');



module.exports = function (options) {
	options || (options = {});

	// DEFAULT OPTIONS
	var settings = {
		port: 9000,  // server port
		dir: './',   // static dir,
		cwd: process.cwd(), // root for static dir
		logs: true,  // log success
		loge: true,  // log errors,
		gzip: false, // gzip response
		cache: 3600  // cache time
	};



	// PREPARE SETTINGS
	// REPLACE SETTINGS FROM OPTIONS
	var key;
	for (key in options) {
		if (options.hasOwnProperty(key)) {
			settings[key] = options[key];
		}
	}
	// SET ABSOLUTE PATH OF STATIC DIR
	settings.dirAbs = path.normalize(path.join(options.cwd, settings.dir));



	// SERVER
	// INIT STATIC SERVER
	var fileServer = new nodeStatic.Server(settings.dirAbs, {
		gzip: settings.gzip,
		cache: settings.cache
	});



	// INIT HTTP SERVER
	var server = http.createServer(function (request, response) {
		request.addListener('end', function () {
			// SEND STATIC FILE
			fileServer.serve(request, response, function (err) {
				if (!err) {
					// CONSOLE LOG
					if (settings.logs) {
						console.log ((200 + '').green, request.url);
					}
				} else {
					// CONSOLE LOG
					if (settings.loge) {
						console.error((err.status + '').red, request.url)
					}
					response.end();
				}
			});
		}).resume();
	});


	// TRACE LISTENING
	server.on('listening', function () {
		console.log(
			'Static Server', 'Run'.red,
			'\nAt: ', 'http://localhost:'.blue, (settings.port + '').cyan,
			'\nStatic Dir:', settings.dirAbs.cyan,
			'\n________________'.red
		);
	});


	// LISTEN PORT, RUN HTTP SERVER
	server.listen(settings.port);
};


// IF COMMAND LINE - RUN
if (!module.parent) {
	module.exports(require('optimist').argv);
}<commit_msg>fix typo<commit_after>"use strict";

// REQUIREMENTS
var path       = require('path');
var http       = require('http');

var nodeStatic = require('node-static');
var colors     = require('colors');



module.exports = function (options) {
	options || (options = {});

	// DEFAULT OPTIONS
	var settings = {
		port: 9000,  // server port
		dir: './',   // static dir,
		cwd: process.cwd(), // root for static dir
		logs: true,  // log success
		loge: true,  // log errors,
		gzip: false, // gzip response
		cache: 3600  // cache time
	};



	// PREPARE SETTINGS
	// REPLACE SETTINGS FROM OPTIONS
	var key;
	for (key in options) {
		if (options.hasOwnProperty(key)) {
			settings[key] = options[key];
		}
	}
	// SET ABSOLUTE PATH OF STATIC DIR
	settings.dirAbs = path.normalize(path.join(settings.cwd, settings.dir));



	// SERVER
	// INIT STATIC SERVER
	var fileServer = new nodeStatic.Server(settings.dirAbs, {
		gzip: settings.gzip,
		cache: settings.cache
	});



	// INIT HTTP SERVER
	var server = http.createServer(function (request, response) {
		request.addListener('end', function () {
			// SEND STATIC FILE
			fileServer.serve(request, response, function (err) {
				if (!err) {
					// CONSOLE LOG
					if (settings.logs) {
						console.log ((200 + '').green, request.url);
					}
				} else {
					// CONSOLE LOG
					if (settings.loge) {
						console.error((err.status + '').red, request.url)
					}
					response.end();
				}
			});
		}).resume();
	});


	// TRACE LISTENING
	server.on('listening', function () {
		console.log(
			'Static Server', 'Run'.red,
			'\nAt: ', 'http://localhost:'.cyan, (settings.port + '').red,
			'\nStatic Dir:', settings.dirAbs.cyan,
			'\n________________'.red
		);
	});


	// LISTEN PORT, RUN HTTP SERVER
	server.listen(settings.port);
};


// IF COMMAND LINE - RUN
if (!module.parent) {
	module.exports(require('optimist').argv);
}
{'fraction_non_alphanumeric': 0.16662244627222075, 'fraction_numerical': 0.0058370920668612365, 'mean_word_length': 2.7927565392354126, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5595190', 'n_tokens_mistral': 1511, 'n_tokens_neox': 1283, 'n_words': 313}