<commit_before>/* global Promise */
var nodefs = require('node-fs');
var path = require('path');
var sass = require('node-sass');
var postcss = require('postcss');
var chalk = require('chalk');

/**
 * @constructor
 */
function Processor(plugins) {
	this.plugins = plugins;
}


/**
 * Process single
 */
Processor.prototype.process = function (options) {
	var plugins = this.plugins;
	var toName = path.basename(options.to);
	var dirName = path.dirname(options.to);

	// Wrap node-sass in a promise
	var sassPromise = new Promise(function (resolve, reject) {
		sass.render({
			file: options.from,
			outFile: options.to,
			precision: 10,
			sourceMap: true,
			sourceMapEmbed: true
		}, function (err, result) {
			if (err) {
				reject(err);
			}
			else {
				resolve(result);
			}
		});
	});

	// PostCss already implements promises, so we just return it.
	var doPostCss = function (result) {
		return postcss(plugins).process(result.css, {
			from: toName,
			to: toName,
			map: { inline: false }
		});
	};

	var writeToDisk = function (result) {
		nodefs.mkdirSync(dirName, '0777', true);
		nodefs.writeFile(options.to, result.css);
		nodefs.writeFile(options.to + '.map', result.map);

		console.log(chalk.green('>>'), chalk.cyan(options.to), 'created.');
	};


	return sassPromise
		.then(doPostCss)
		.then(writeToDisk);
};


/**
 * Process many
 */
Processor.prototype.processMany = function (optionsArray) {<commit_msg>using write file sync to make sure file is available before returning.<commit_after>/* global Promise */
var nodefs = require('node-fs');
var path = require('path');
var sass = require('node-sass');
var postcss = require('postcss');
var chalk = require('chalk');

/**
 * @constructor
 */
function Processor(plugins) {
	this.plugins = plugins;
}


/**
 * Process single
 */
Processor.prototype.process = function (options) {
	var plugins = this.plugins;
	var toName = path.basename(options.to);
	var dirName = path.dirname(options.to);

	// Wrap node-sass in a promise
	var sassPromise = new Promise(function (resolve, reject) {
		sass.render({
			file: options.from,
			outFile: options.to,
			precision: 10,
			sourceMap: true,
			sourceMapEmbed: true
		}, function (err, result) {
			if (err) {
				reject(err);
			}
			else {
				resolve(result);
			}
		});
	});

	// PostCss already implements promises, so we just return it.
	var doPostCss = function (result) {
		return postcss(plugins).process(result.css, {
			from: toName,
			to: toName,
			map: { inline: false }
		});
	};

	var writeToDisk = function (result) {
		nodefs.mkdirSync(dirName, '0777', true);
		nodefs.writeFileSync(options.to, result.css);
		nodefs.writeFileSync(options.to + '.map', result.map);

		console.log(chalk.green('>>'), chalk.cyan(options.to), 'created.');
	};


	return sassPromise
		.then(doPostCss)
		.then(writeToDisk);
};


/**
 * Process many
 */
Processor.prototype.processMany = function (optionsArray) {
{'fraction_non_alphanumeric': 0.15602594742232845, 'fraction_numerical': 0.004096961420279959, 'mean_word_length': 3.7334410339256867, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '1099063', 'n_tokens_mistral': 1092, 'n_tokens_neox': 977, 'n_words': 237}