<commit_before>var path = require('path');
var browserify = require('browserify');
var fs = require('fs');

module.exports = function(practiceOrSolution, lesson, s) {

	console.log('created lesson');

	return function(req, res) {
		var file = req.params[0] == '' ? 'index.html' : req.params[0];
		var userFilePath; // path to file we're requesting maybe anything on local system
		var pathSolutionPractice; // this is a path to a solution or practice file which will require users index.js
		var b;

		userFilePath = path.resolve(path.join(s.out, lesson, practiceOrSolution, file));

		// send all files regularly but js files we want to browserify
		if(file != 'index.js') {

			res.sendFile(userFilePath);	
		// this is a index.js file so we should browserify
		} else {

			// set mimetype for what will be exported
			res.type('js');

			b = browserify();

			// check
			pathSolutionPractice = path.join(s.pathLessons, lesson, practiceOrSolution + '.js');

			// if there's a practice or solution file then this will be the index
			if(fs.existsSync(pathSolutionPractice)) {

				b.add(userFilePath, { expose: 'usersExport'});
				b.add(pathSolutionPractice);

			// if there was no practice or solution file then will just serve the users index.js browserified
			} else {

				b.add(userFilePath);
			}

			
			
			b.bundle().pipe(res);
		}
	};
};<commit_msg>Added lesson modules path to practice and solution files<commit_after>var path = require('path');
var browserify = require('browserify');
var fs = require('fs');

module.exports = function(practiceOrSolution, lesson, s) {

	return function(req, res) {
		var file = req.params[0] == '' ? 'index.html' : req.params[0];
		var userFilePath; // path to file we're requesting maybe anything on local system
		var pathSolutionPractice; // this is a path to a solution or practice file which will require users index.js
		var b;

		userFilePath = path.resolve(path.join(s.out, lesson, practiceOrSolution, file));

		// send all files regularly but js files we want to browserify
		if(file != 'index.js') {

			res.sendFile(userFilePath);	
		// this is a index.js file so we should browserify
		} else {

			// set mimetype for what will be exported
			res.type('js');

			b = browserify( {
				paths: [
					path.join(path.dirname(process.mainModule.filename), 'node_modules')
				]
			});

			// check
			pathSolutionPractice = path.join(s.pathLessons, lesson, practiceOrSolution + '.js');

			// if there's a practice or solution file then this will be the index
			if(fs.existsSync(pathSolutionPractice)) {

				b.add(userFilePath, { expose: 'usersExport' });
				b.add(pathSolutionPractice);

			// if there was no practice or solution file then will just serve the users index.js browserified
			} else {

				b.add(userFilePath);
			}

			
			
			b.bundle().pipe(res);
		}
	};
};
{'fraction_non_alphanumeric': 0.12029546253957088, 'fraction_numerical': 0.0014069644741470278, 'mean_word_length': 3.457680250783699, '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': '6944131', 'n_tokens_mistral': 1009, 'n_tokens_neox': 837, 'n_words': 281}