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

// General directives and requires

'use strict';

var fs = require('fs');
var path = require('path');
var argv = require('yargs').argv;
require('babel-core/register');

// TODO: These variable names are awful; decide on better vocabulary
var jenerateDirective = argv._[0];
var jenerateType = argv._[1];

console.log('directive: ', jenerateDirective);
console.log('type: ', jenerateType);

// jenerate jen build {name-of-build-task}
//  Functionality to modify 'scripts' section of package.json to add/remove build
//  tasks as a lightweight replacement for grunt/gulp

if (jenerateDirective && jenerateType === 'build') {
    // TODO: Move functionality to separate module(s)
    var copyFile = require('./utils/copy_file');
    var cwd = process.cwd();
    var packageJsonOriginal = path.join(cwd, 'package.json');
    var packageJsonCopy = path.join(cwd, 'package.old.json');

    fs.access(packageJsonOriginal, fs.R_OK && fs.W_OK, function(err) {
        // TODO: Recursively locate package.json, so you don't have to run jenerate
        //  from within root of project
        if (err) console.log('package.json not found! are you in the wrong directory?');

        // Copy package.json for backup before modifying new copy
        copyFile(packageJsonOriginal, packageJsonCopy).then(function() {
            // TODO: Add functionality to add/remove build tasks (from plugins?)
            console.log('package.json copied!');
        }, function() {
            console.log('package.json copy failed!');
        });
    });
}
else {
    console.log('no jenerate directive and/or type specified!');
}

// TODO: add build task to restore backup package.json?<commit_msg>convert to es6, remove babel hook<commit_after>#! /usr/bin/env node

// General directives and requires

'use strict';

import fs     from 'fs';
import path   from 'path';
import {argv} from 'yargs';

// TODO: These variable names are awful; decide on better vocabulary
const jenerateDirective = argv._[0];
const jenerateType = argv._[1];

console.log('directive: ', jenerateDirective);
console.log('type: ', jenerateType);

// jenerate jen build {name-of-build-task}
//  Functionality to modify 'scripts' section of package.json to add/remove build
//  tasks as a lightweight replacement for grunt/gulp

if (jenerateDirective && jenerateType === 'build') {
  // TODO: Move functionality to separate module(s)
  const copyFile = require('./utils/copy_file');
  const cwd = process.cwd();
  const packageJsonOriginal = path.join(cwd, 'package.json');
  const packageJsonCopy = path.join(cwd, 'package.old.json');

  fs.access(packageJsonOriginal, fs.R_OK && fs.W_OK, (err) => {
    // TODO: Recursively locate package.json, so you don't have to run jenerate
    //  from within root of project
    if (err) console.log('package.json not found! are you in the wrong directory?');

    // Copy package.json for backup before modifying new copy
    copyFile(packageJsonOriginal, packageJsonCopy).then(() => {
      // TODO: Add functionality to add/remove build tasks (from plugins?)
      console.log('package.json copied!');
    }, () => {
      console.log('package.json copy failed!');
    });
  });
} else {
  console.log('no jenerate directive and/or type specified!');
}

// TODO: add build task to restore backup package.json?
{'fraction_non_alphanumeric': 0.13161830690996112, 'fraction_numerical': 0.0014956625785222854, 'mean_word_length': 3.599724896836314, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '447448', 'n_tokens_mistral': 1000, 'n_tokens_neox': 982, 'n_words': 315}