<commit_before>#!/usr/bin/env node

'use strict';

var When = require('when');
var fs = require('fs');
var path = require('path');
var gitUtils = require('./modules/gitUtils.js');
var filters = require('./modules/filters.js');
var pullpush = require('./modules/pullpush.js');
var constants = require('./modules/constants.json');
var iConfig = require("./modules/interactive-configuration.js");
var spawn = require('child_process').spawn;

var usage = 'Usage : git-jam (init|filter <extension>|push|pull|config [-g] <property> [<value>]|restore|setup-hooks)';

function main(args){
	if(args.length === 0){
		console.log(usage);
		return ;
	}
	var remainingArgs = args.slice(1);
	return gitUtils.getJamPath()
	.then(function(jamPath){
		if((jamPath == "" || !fs.existsSync(jamPath)) && args[0] != "init"){
			console.error("You are not in a jam repository.");
			return 1;
		}
		switch(args[0]){
			case 'filter-smudge':
				return jamFilterSmudge();
			case 'filter-clean':
				return jamFilterClean();
			case 'init':
				return jamInit(remainingArgs);
			case 'push':
				return jamPush();
			case 'pull':
				return jamPull();
			case 'restore':
				return jamRestore();
			case 'filter':
				return addFilters(remainingArgs);
			case 'config':
				if(remainingArgs.length > 0){
					return jamConfig(remainingArgs);
				}
			case 'setup-hooks':
				return gitUtils.setUpHooks();
			default :
				console.log(usage);
		}
	})
	.then(function(){
		process.stdin.destroy();
	})
	.catch(function(err){
		console.error("The operation failed. Here is the stack trace of the error : ");
		console.error(err.stack);
	});
<commit_msg>Free stdin even in case of error<commit_after>#!/usr/bin/env node

'use strict';

var When = require('when');
var fs = require('fs');
var path = require('path');
var gitUtils = require('./modules/gitUtils.js');
var filters = require('./modules/filters.js');
var pullpush = require('./modules/pullpush.js');
var constants = require('./modules/constants.json');
var iConfig = require("./modules/interactive-configuration.js");
var spawn = require('child_process').spawn;

var usage = 'Usage : git-jam (init|filter <extension>|push|pull|config [-g] <property> [<value>]|restore|setup-hooks)';

function main(args){
	if(args.length === 0){
		console.log(usage);
		return ;
	}
	var remainingArgs = args.slice(1);
	return gitUtils.getJamPath()
	.then(function(jamPath){
		if((jamPath == "" || !fs.existsSync(jamPath)) && args[0] != "init"){
			console.error("You are not in a jam repository.");
			return 1;
		}
		switch(args[0]){
			case 'filter-smudge':
				return jamFilterSmudge();
			case 'filter-clean':
				return jamFilterClean();
			case 'init':
				return jamInit(remainingArgs);
			case 'push':
				return jamPush();
			case 'pull':
				return jamPull();
			case 'restore':
				return jamRestore();
			case 'filter':
				return addFilters(remainingArgs);
			case 'config':
				if(remainingArgs.length > 0){
					return jamConfig(remainingArgs);
				}
			case 'setup-hooks':
				return gitUtils.setUpHooks();
			default :
				console.log(usage);
		}
	})
	.then(function(){
		process.stdin.destroy();
	})
	.catch(function(err){
		console.error("The operation failed. Here is the stack trace of the error : ");
		console.error(err.stack);
		process.stdin.destroy();
	});

{'fraction_non_alphanumeric': 0.17363636363636364, 'fraction_numerical': 0.0036363636363636364, 'mean_word_length': 4.094135802469136, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '4766469', 'n_tokens_mistral': 1230, 'n_tokens_neox': 1070, 'n_words': 249}