<commit_before>var sys = require('sys')
var exec = require('child_process').exec;
function puts(error, stdout, stderr) { console.log(stdout) }
exec("(basename $(git rev-parse --show-toplevel))", puts);<commit_msg>[MICHAL] - generate package.json file<commit_after>'use strict';

var exec = require('child_process').exec;
var async = require('async');
var fs = require('fs');

var packageJsonStructure = {
  name: "",
  version: "0.0.1",
  author: "",
  repository: ''
}


var parseGitCommand = function(instruction, cb) {
  var key = Object.keys(instruction)[0];
  var command = instruction[key];

  exec(command, function(error, stdout, stderr) {
    packageJsonStructure[key] = stdout.trim();
    cb();
  });
}

var gitConfigCommands = [
  { name: "(basename $(git rev-parse --show-toplevel))" },
  { author: "git log --all --format='%aN <%cE>' | sort -u | head -1" },
  { repository: "git config --get remote.origin.url" }
];

async.each(gitConfigCommands, parseGitCommand, function() {
  fs.writeFile("package.json", JSON.stringify(packageJsonStructure, null, 2), function(err) {
    if(err) {
        console.log(err);
    } else {
        console.log("package.json file saved...");
    }
  });
});
{'fraction_non_alphanumeric': 0.18453865336658354, 'fraction_numerical': 0.004987531172069825, 'mean_word_length': 4.101694915254237, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '3977472', 'n_tokens_mistral': 404, 'n_tokens_neox': 397, 'n_words': 89}