<commit_before>import remote from 'remote';
import path from 'path';
import fs from 'fs';
import childProcess from 'child_process';

import i18n from './i18n';

const app = remote.require('app');
const dialog = remote.require('dialog');


function getResourceFolder() {
  // XXX: windows support
  return path.dirname(app.getAppPath());
}

function getBundleBase() {
  return path.dirname(getResourceFolder());
}

function findBundledLektorExecutable() {
  let res = getResourceFolder();
  try {
    if (process.platform === 'darwin') {
      let macExe = path.join(res, 'lektor');
      fs.accessSync(macExe, fs.X_OK);
      let stats = fs.lstatSync(macExe);
      if (stats.isFile()) {
        return macExe;
      }
    }
  } catch (e) {
  }
  return null;
}

function findGlobalLektorExecutable() {
  let rv;
  if (process.platform === 'win32') {
    // XXX: do something better for windows support
    return 'lektor';
  } else {
    rv = childProcess.spawnSync('which', ['lektor']);
  }

  if (rv.status === 0) {
    return (rv.output[1] + '').trim();
  }
  return null;
}<commit_msg>Find executable with where.exe for windows<commit_after>import remote from 'remote';
import path from 'path';
import fs from 'fs';
import childProcess from 'child_process';

import i18n from './i18n';

const app = remote.require('app');
const dialog = remote.require('dialog');


function getResourceFolder() {
  // XXX: windows support
  return path.dirname(app.getAppPath());
}

function getBundleBase() {
  return path.dirname(getResourceFolder());
}

function findBundledLektorExecutable() {
  let res = getResourceFolder();
  try {
    if (process.platform === 'darwin') {
      let macExe = path.join(res, 'lektor');
      fs.accessSync(macExe, fs.X_OK);
      let stats = fs.lstatSync(macExe);
      if (stats.isFile()) {
        return macExe;
      }
    }
  } catch (e) {
  }
  return null;
}

function findGlobalLektorExecutable() {
  let rv;
  if (process.platform === 'win32') {
    rv = childProcess.spawnSync('where.exe', ['lektor']);
  } else {
    rv = childProcess.spawnSync('which', ['lektor']);
  }
  if (rv.status === 0) {
    return (rv.output[1] + '').split('\n')[0].trim();
  }
  return null;
}
{'fraction_non_alphanumeric': 0.15760869565217392, 'fraction_numerical': 0.007699275362318841, 'mean_word_length': 3.5081632653061225, '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': '3844097', 'n_tokens_mistral': 752, 'n_tokens_neox': 743, 'n_words': 181}