<commit_before>var compressor = require('node-minify');

// Validators for file extensions
function isJs(filename) { return filename.match(/.+\.js$/g); }
function isCss(filename) { return filename.match(/.+\.css$/g); }

// Grab a list of applicable filenames given a directory name
function ls(dirPath,filenameValidator,newPathPrefix) {
	var filenames = [];
	fs.readdirSync(dirPath).forEach(function(filename) {

		// TODO: Use conventions w/ filenames to improve everything
		// see https://github.com/balderdashdesign/mast/issues/5
	
		// Ignore files that start with an underscore
		if ((filename[0] === '_')) {
			return;
		}
	
		// Add this filename to the list
		if (filenameValidator && filenameValidator(filename)) {
			filenames.push(path.join(newPathPrefix || dirPath, filename));
		}
	});
	return filenames;
}

var isProduction = config.appEnvironment=="production",
	isDevelopment = config.appEnvironment=="development";
	
function decorateDependency(filename) {
	if (isDevelopment) {
		return "/_lib/dependencies/"+filename+".min.js"
	}
	else {
		return "lib/mast/_lib/dependencies/"+filename+".min.js"
	}
}



// TODO: Crawl components and determine dependencies

// Determine all of the files that should be compiled
var jsDependencies =	_.map(["jquery","jquery-ui","underscore","backbone"],decorateDependency);
var jsMastCoreFiles =	ls("lib/mast/_lib",isJs,(isDevelopment)?"/_lib":null);
var jsComponentFiles =	ls('mast/components',isJs,(isDevelopment)?"/components":null);
var jsRouteFiles =		ls('mast/routes',isJs,(isDevelopment)?"/routes":null);
var cssTemplateFiles =	ls('mast/templates',isCss,(isDevelopment)?"/templates":null);

// Define the global array of js filenames
// TODO: replace this w/ a dynamically generated view partial file in /public/_target
// to avoid cluttering the namespace
_mastJsFiles = _.union(jsDependencies,jsMastCoreFiles,jsComponentFiles,jsRouteFiles);
_mastCssFiles = cssTemplateFiles;
console.log("_mastJsFiles",_mastJsFiles);
console.log("_mastCssFiles",_mastCssFiles);

if (isProduction) {
	
	// Combine and minify css
	new compressor.minify({
		type: 'yui',
		fileIn: _mastCssFiles,
		fileOut: './public/_target/app.css'
	});
	
	
	
	// Combine and minify js
	new compressor.minify({
		type: 'gcc',
		fileIn: _mastJsFiles,
		fileOut: './public/_target/app.js'
	});
}
<commit_msg>Explicitly called out lib files in sails mast compiler<commit_after>var compressor = require('node-minify');

// Validators for file extensions
function isJs(filename) { return filename.match(/.+\.js$/g); }
function isCss(filename) { return filename.match(/.+\.css$/g); }

// Grab a list of applicable filenames given a directory name
function ls(dirPath,filenameValidator,newPathPrefix) {
	var filenames = [];
	fs.readdirSync(dirPath).forEach(function(filename) {

		// TODO: Use conventions w/ filenames to improve everything
		// see https://github.com/balderdashdesign/mast/issues/5
	
		// Ignore files that start with an underscore
		if ((filename[0] === '_')) {
			return;
		}
	
		// Add this filename to the list
		if (filenameValidator && filenameValidator(filename)) {
			filenames.push(path.join(newPathPrefix || dirPath, filename));
		}
	});
	return filenames;
}

var isProduction = config.appEnvironment=="production",
	isDevelopment = config.appEnvironment=="development";
	
function decorateDependency(filename) {
	if (isDevelopment) {
		return "/_lib/dependencies/"+filename+".min.js"
	}
	else {
		return "lib/mast/_lib/dependencies/"+filename+".min.js"
	}
}



// TODO: Crawl components and determine dependencies

// Determine all of the files that should be compiled
var jsDependencies =	_.map(["jquery","jquery-ui","underscore","backbone"],decorateDependency);
var jsMastCoreFiles =  ["logger.js","outside.js","mast.js"];
var jsComponentFiles =	ls('mast/components',isJs,(isDevelopment)?"/components":null);
var jsRouteFiles =		ls('mast/routes',isJs,(isDevelopment)?"/routes":null);
var cssTemplateFiles =	ls('mast/templates',isCss,(isDevelopment)?"/templates":null);

// Define the global array of js filenames
// TODO: replace this w/ a dynamically generated view partial file in /public/_target
// to avoid cluttering the namespace
_mastJsFiles = _.union(jsDependencies,jsMastCoreFiles,jsComponentFiles,jsRouteFiles);
_mastCssFiles = cssTemplateFiles;
console.log("_mastJsFiles",_mastJsFiles);
console.log("_mastCssFiles",_mastCssFiles);

if (isProduction) {
	
	// Combine and minify css
	new compressor.minify({
		type: 'yui',
		fileIn: _mastCssFiles,
		fileOut: './public/_target/app.css'
	});
	
	
	
	// Combine and minify js
	new compressor.minify({
		type: 'gcc',
		fileIn: _mastJsFiles,
		fileOut: './public/_target/app.js'
	});
}

{'fraction_non_alphanumeric': 0.14240034107866126, 'fraction_numerical': 0.0008526966531656363, 'mean_word_length': 5.0, 'pattern_counts': {'":': 7, '<': 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': 11, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1303459', 'n_tokens_mistral': 1619, 'n_tokens_neox': 1481, 'n_words': 336}