<commit_before>module.exports = function (grunt) {
  var path = require('path');
  var which = require('which');
  var fs = require('fs');
  var semver = require('semver');

  var Api = require('crosswalk-apk-generator');

  var generate_apk = function(data,done) {
    var outDir = data.outDir || '.';
    var appConfig = {};
    var envConfig = {};

    // copy user-supplied parameters into envConfig or appConfig
    var envProperties = Object.keys(Api.Env.CONFIG_DEFAULTS);
    Object.keys(data).forEach(function(property){
      if (envProperties.indexOf(property)!=-1) {
        envConfig[property] = data[property];
      } else {
        appConfig[property] = data[property];
      }
    });

    // automatically find androidSDKDir from 'android' command in PATH
    if (!envConfig.androidSDKDir) {
      var androidPath = which.sync('android');
      // up two directories
      envConfig.androidSDKDir = path.dirname(path.dirname(androidPath));
    }

    if (!envConfig.xwalkAndroidDir) {
      var fromEnvVar = process.env.XWALK_APP_TEMPLATE;
      if (fromEnvVar) {
        envConfig.xwalkAndroidDir = fromEnvVar;
      }
    }

    // determine arch from xwalkAndroidDir name
    // eg $HOME/Downloads/crosswalk-4.32.69.0-x86/xwalk_app_template
    if (!envConfig.arch && envConfig.xwalkAndroidDir) {
      var xwalkAndroidRoot = path.dirname(envConfig.xwalkAndroidDir);
      var pathBits = xwalkAndroidRoot.split(path.sep);
      var sdkName = pathBits[pathBits.length-2];
      var sdkNameBits = sdkName.split('-');

      envConfig.arch = sdkNameBits[sdkNameBits-1];
    }

    if (!envConfig.androidAPIVersion) {
      // get the api latest version from androidSDK/build-tools
      var buildToolsDir = path.join(envConfig.androidSDKDir,"build-tools");
      var files = fs.readdirSync(buildToolsDir);
      var androidAPIVersions = files.sort(semver.compare);
      var length = androidAPIVersions.length;
      var latest = androidAPIVersions[length-1];
      envConfig.androidAPIVersion = latest;
    }

    var logger = grunt.log;
    console.log("MAXMAXMAX", data.verbose);<commit_msg>Fixes for Windows.<commit_after>module.exports = function (grunt) {
  var path = require('path');
  var which = require('which');
  var fs = require('fs');
  var semver = require('semver');

  var Api = require('crosswalk-apk-generator');

  var generate_apk = function(data,done) {
    var outDir = data.outDir || '.';
    var appConfig = {};
    var envConfig = {};

    // copy user-supplied parameters into envConfig or appConfig
    var envProperties = Object.keys(Api.Env.CONFIG_DEFAULTS);
    Object.keys(data).forEach(function(property){
      if (envProperties.indexOf(property)!=-1) {
        envConfig[property] = data[property];
      } else {
        appConfig[property] = data[property];
      }
    });

    // automatically find androidSDKDir from 'android' command in PATH
    if (!envConfig.androidSDKDir) {
      var androidPath = which.sync('android');
      // up two directories
      envConfig.androidSDKDir = path.dirname(path.dirname(androidPath));
    }

    if (!envConfig.xwalkAndroidDir) {
      var fromEnvVar = process.env.XWALK_APP_TEMPLATE;
      if (fromEnvVar) {
        envConfig.xwalkAndroidDir = fromEnvVar;
      }
    }

    // determine arch from xwalkAndroidDir name
    // eg $HOME/Downloads/crosswalk-4.32.69.0-x86/xwalk_app_template
    if (!envConfig.arch && envConfig.xwalkAndroidDir) {
      var xwalkAndroidRoot = path.dirname(envConfig.xwalkAndroidDir);
      var pathBits = xwalkAndroidRoot.split(path.sep);
      if (path.sep=='\\' && pathBits.length==1) {
        // path is something like c:/bla/bla/bla, ie not using \
        // split with '/' instead
        pathBits = xwalkAndroidRoot.split('/');
      }
      var sdkName = pathBits[pathBits.length-1];
      var sdkNameBits = sdkName.split('-');

      envConfig.arch = sdkNameBits[sdkNameBits.length-1];
    }

    if (!envConfig.androidAPIVersion) {
      // get the api latest version from androidSDK/build-tools
      var buildToolsDir = path.join(envConfig.androidSDKDir,"build-tools");
      var files = fs.readdirSync(buildToolsDir);
      var androidAPIVersions = files.sort(semver.compare);
      var length = androidAPIVersions.length;
      var latest = androidAPIVersions[length-1];
      envConfig.androidAPIVersion = latest;
    }

    var logger = grunt.log;
{'fraction_non_alphanumeric': 0.12445961319681456, 'fraction_numerical': 0.005688282138794084, 'mean_word_length': 3.0703703703703704, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6067337', 'n_tokens_mistral': 1381, 'n_tokens_neox': 1339, 'n_words': 271}