<commit_before>'use strict';

var async = require('async')
	, chalk = require('chalk')
	, clearIDCache = require('identify-resource').clearCache
	, clearTemplateCache = require('transfigure').clearCache
	, cnsl = require('./utils/cnsl')
	, compact = require('lodash/array/compact')
	, difference = require('lodash/array/difference')
	, distinct = require('lodash/array/unique')
	, extend = require('lodash/object/extend')
	, fileFactory = require('./file')
	, flatten = require('lodash/array/flatten')
	, fs = require('fs')
	, path = require('path')
	, pathname = require('./utils/pathname')
	, recurfs = require('recur-fs')
	, unique = require('./utils/unique')

	, debug = cnsl.debug
	, indir = recurfs.indir
	, parallel = async.parallel
	, print = cnsl.print
	, readdir = recurfs.readdir.sync
	, series = async.series
	, strong = cnsl.strong
	, warn = cnsl.warn
	, waterfall = async.waterfall;

/**
 * Target instance factory
 * @param {Object} data
 * @returns {Target}
 */
module.exports = function (data) {
	var instance = new Target(data);

	return instance;
};

/**
 * Constructor
 * @param {Object} props
 */
function Target (props) {
/* Decorated properties
	this.bootstrap = false;
	this.boilerplate = false;
	this.fileExtensions = null;
	this.hasChildren = false;
	this.hasParent = false;
	this.input = '';
	this.isRoot = false;
	this.inputpath = '';
	this.appServer = false;
	this.batch = false;
	this.modular = false;
	this.output = '';
	this.outputpath = '';
	this.parent = null;
	this.runtimeOptions = null;
	this.sources = null;
	this.targets = null;
	this.workflows = null;
*/
	extend(this, props);
	this.referencedFiles = [];
	this.fileFactoryOptions = {
		fileExtensions: this.fileExtensions,
		sources: this.sources,
		runtimeOptions: this.runtimeOptions
	};

	// Prepare file filter
	if (this.fileExtensions) {
		var exts = [];

		for (var type in this.fileExtensions) {
			exts = exts.concat(this.fileExtensions[type]);
		}
		this.fileFilter = new RegExp(exts.join('$|') + '$');
	}

	// Print
	if (this.isRoot) {
		debug('created root Target instance');
	} else {
		// Handle printing long input arrays
		if (Array.isArray(this.inputpath)) {
			this.inputString = this.inputpath.map(function (input) {
				return pathname(input);
			});
			// Trim long lists
			if (this.inputString.length > 3) {
				this.inputString = this.inputString.slice(0, 3).join(', ')
					+ '...and '
					+ (this.inputString.length - 3)
					+ ' others';
			} else {
				this.inputString = this.inputString.join(', ');
			}
		} else {
			this.inputString = pathname(this.inputpath);
		}

		debug('created Target instance with input: '
			+ strong(this.inputString)
			+ ' and output: '
			+ strong(this.output), 2);
	}
}

/**
 * Run build
 * @param {Function} fn(err, filepaths)
 */
Target.prototype.build = function (fn) {
	var self = this;

	if (this.isRoot) {
		// Execute 'before' hook
		waterfall([function (done) {
			self.executeHook('before', self, done);
		},

		// Build targets
		function (done) {
			series(self.targets.map(function (target) {
				return target.build.bind(target);
			}), function (err, results) {
				done(err, flatten(results));
			});
		},

		// Execute 'after' hook
		function (filepaths, done) {
			self.executeHook('after', self, function (err) {
				done(err, filepaths);
			});
		}], fn);

	// Skip if watch only and not watch build
	} else if (this.outputpath || !this.outputpath && this.runtimeOptions.watch) {
		var watching = this.runtimeOptions.watch ? 1 : 0
			, timerID = Array.isArray(this.input)
				? this.input[0]
				: this.input;

		if (watching && !this.outputpath) watching++;

		this.referencedFiles = [];

		cnsl.start(timerID);

		print((watching ? 'watching ' : 'building ')
			+ strong(this.inputString)
			+ (this.outputpath ? ' to ' + strong(path.basename(this.outputpath)) : ''), 1);

		// Execute 'before' hook
		waterfall([function (done) {
			self.executeHook('before', self, done);
		},

		// Parse source files
		function (done) {
			done(null, self.parse(self.batch, self.inputpath, self.fileFilter, self.fileFactoryOptions));
		},

		// Process files
		function (files, done) {
			self.process(files, self.workflows, watching, done);
		},

		// Execute 'afterEach' hooks
		function (files, done) {
			parallel(files.map(function (file) {
				// Memoize
				return self.executeHook.bind(self, 'afterEach', file);
			}), function (err) {<commit_msg>fix printed log message for build tasks<commit_after>'use strict';

var async = require('async')
	, chalk = require('chalk')
	, clearIDCache = require('identify-resource').clearCache
	, clearTemplateCache = require('transfigure').clearCache
	, cnsl = require('./utils/cnsl')
	, compact = require('lodash/array/compact')
	, difference = require('lodash/array/difference')
	, distinct = require('lodash/array/unique')
	, extend = require('lodash/object/extend')
	, fileFactory = require('./file')
	, flatten = require('lodash/array/flatten')
	, fs = require('fs')
	, path = require('path')
	, pathname = require('./utils/pathname')
	, recurfs = require('recur-fs')
	, unique = require('./utils/unique')

	, debug = cnsl.debug
	, indir = recurfs.indir
	, parallel = async.parallel
	, print = cnsl.print
	, readdir = recurfs.readdir.sync
	, series = async.series
	, strong = cnsl.strong
	, warn = cnsl.warn
	, waterfall = async.waterfall;

/**
 * Target instance factory
 * @param {Object} data
 * @returns {Target}
 */
module.exports = function (data) {
	var instance = new Target(data);

	return instance;
};

/**
 * Constructor
 * @param {Object} props
 */
function Target (props) {
/* Decorated properties
	this.bootstrap = false;
	this.boilerplate = false;
	this.fileExtensions = null;
	this.hasChildren = false;
	this.hasParent = false;
	this.input = '';
	this.isRoot = false;
	this.inputpath = '';
	this.appServer = false;
	this.batch = false;
	this.modular = false;
	this.output = '';
	this.outputpath = '';
	this.parent = null;
	this.runtimeOptions = null;
	this.sources = null;
	this.targets = null;
	this.workflows = null;
*/
	extend(this, props);
	this.referencedFiles = [];
	this.fileFactoryOptions = {
		fileExtensions: this.fileExtensions,
		sources: this.sources,
		runtimeOptions: this.runtimeOptions
	};

	// Prepare file filter
	if (this.fileExtensions) {
		var exts = [];

		for (var type in this.fileExtensions) {
			exts = exts.concat(this.fileExtensions[type]);
		}
		this.fileFilter = new RegExp(exts.join('$|') + '$');
	}

	// Print
	if (this.isRoot) {
		debug('created root Target instance');
	} else {
		// Handle printing long input arrays
		if (Array.isArray(this.inputpath)) {
			this.inputString = this.inputpath.map(function (input) {
				return pathname(input);
			});
			// Trim long lists
			if (this.inputString.length > 3) {
				this.inputString = this.inputString.slice(0, 3).join(', ')
					+ '...and '
					+ (this.inputString.length - 3)
					+ ' others';
			} else {
				this.inputString = this.inputString.join(', ');
			}
		} else {
			this.inputString = pathname(this.inputpath);
		}

		debug('created Target instance with input: '
			+ strong(this.inputString)
			+ ' and output: '
			+ strong(this.output), 2);
	}
}

/**
 * Run build
 * @param {Function} fn(err, filepaths)
 */
Target.prototype.build = function (fn) {
	var self = this;

	if (this.isRoot) {
		// Execute 'before' hook
		waterfall([function (done) {
			self.executeHook('before', self, done);
		},

		// Build targets
		function (done) {
			series(self.targets.map(function (target) {
				return target.build.bind(target);
			}), function (err, results) {
				done(err, flatten(results));
			});
		},

		// Execute 'after' hook
		function (filepaths, done) {
			self.executeHook('after', self, function (err) {
				done(err, filepaths);
			});
		}], fn);

	// Skip if watch only and not watch build
	} else if (this.outputpath || !this.outputpath && this.runtimeOptions.watch) {
		var watching = this.runtimeOptions.watch ? 1 : 0
			, timerID = Array.isArray(this.input)
				? this.input[0]
				: this.input;

		if (watching && !this.outputpath) watching++;

		this.referencedFiles = [];

		cnsl.start(timerID);

		print((watching == 2 ? 'watching ' : 'building ')
			+ strong(this.inputString)
			+ (this.outputpath ? ' to ' + strong(path.basename(this.outputpath)) : ''), 1);

		// Execute 'before' hook
		waterfall([function (done) {
			self.executeHook('before', self, done);
		},

		// Parse source files
		function (done) {
			done(null, self.parse(self.batch, self.inputpath, self.fileFilter, self.fileFactoryOptions));
		},

		// Process files
		function (files, done) {
			self.process(files, self.workflows, watching, done);
		},

		// Execute 'afterEach' hooks
		function (files, done) {
			parallel(files.map(function (file) {
				// Memoize
				return self.executeHook.bind(self, 'afterEach', file);
			}), function (err) {
{'fraction_non_alphanumeric': 0.1620950445874252, 'fraction_numerical': 0.0021447115927305566, 'mean_word_length': 3.522715671260847, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2073935', 'n_tokens_mistral': 3292, 'n_tokens_neox': 2964, 'n_words': 633}