<commit_before>#!/usr/bin/env node
var fs = require('fs');
var path = require('path');
var parseArgs = require('minimist');
var findPort = require('../lib/findPort');
var compiler = require('../lib/compiler');
var uploader = require('../lib/uploader');

var args = (process.argv.slice(2));
var argv = parseArgs(args, {});
var userAction = argv._[0];

handleInput(userAction);

function showHelp() {
  console.log('usage:\njewelbots-autodev compile\njewelbots-autodev upload\njewelbots-autodev help');
};

function setup(callback) {
  var configPath = path.join(process.cwd(), '.jbauto');
  var config;

  fs.exists(configPath, function(exists) {
    if (exists) {
      fs.readFile(configPath, function(error, file) {
        if (error) return callback(error);
        config = JSON.parse(file);
        return callback(null, config);
      });
    } else {
      return callback(new Error('could not find .jbauto config file in this directory, please make one :)'));
    }
  });
} 

function compileSketch(config, callback) {
  compiler.build(config, function(error) {
    return callback(error);
  });
}

function uploadSketch(config, callback) {
  findPort(function(error, port) {
    if (error) return console.log(error);
    if (!port) return console.log(new Error('could not find a connected Jewelbot.'));
    console.log('found jewelbot on port ' + port);
    config.port = port;
    uploader.upload(config, function(error) {
      return callback(error);
    });
  });
}

function handleInput(action) {<commit_msg>Adds optional soure param which overrides sketch-file in the config<commit_after>#!/usr/bin/env node
var fs = require('fs');
var path = require('path');
var parseArgs = require('minimist');
var findPort = require('../lib/findPort');
var compiler = require('../lib/compiler');
var uploader = require('../lib/uploader');

var args = (process.argv.slice(2));
var argv = parseArgs(args, {});
var userAction = argv._[0];

handleInput(userAction);

function showHelp() {
  console.log('usage:\njewelbots-autodev compile [sketch]\njewelbots-autodev upload [sketch]\njewelbots-autodev help');
};

function setup(callback) {
  var configPath = path.join(process.cwd(), '.jbauto');
  var config;

  fs.exists(configPath, function(exists) {
    if (exists) {
      fs.readFile(configPath, function(error, file) {
        if (error) return callback(error);
        config = JSON.parse(file);
        var source = argv._[1];
        if (source != undefined) {
          config['sketch-file'] = source;
        }

        return callback(null, config);
      });
    } else {
      return callback(new Error('could not find .jbauto config file in this directory, please make one :)'));
    }
  });
} 

function compileSketch(config, callback) {
  compiler.build(config, function(error) {
    return callback(error);
  });
}

function uploadSketch(config, callback) {
  findPort(function(error, port) {
    if (error) return console.log(error);
    if (!port) return console.log(new Error('could not find a connected Jewelbot.'));
    console.log('found jewelbot on port ' + port);
    config.port = port;
    uploader.upload(config, function(error) {
      return callback(error);
    });
  });
}

function handleInput(action) {
{'fraction_non_alphanumeric': 0.15358467243510507, 'fraction_numerical': 0.0015451174289245982, 'mean_word_length': 3.7955555555555556, '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': '7602632', 'n_tokens_mistral': 1018, 'n_tokens_neox': 1000, 'n_words': 247}