<commit_before>const upload = require('prebuild/upload');
const spawn = require('child_process').spawn;
const fs = require('fs');
const path = require('path');
const mkdirp = require('mkdirp');
const archiver = require('archiver');
const zlib = require('zlib');
const pkg = require('./package.json');

function mode(octal) {
  return parseInt(octal, 8)
}

let arch = process.env.ARCH
  ? process.env.ARCH
    .replace('i686', 'ia32')
    .replace('x86_64', 'x64')
  : process.arch;

let cmakeJsPath = path.join(
  __dirname,
  'node_modules',
  '.bin',
  process.platform === 'win32' ? 'cmake-js.cmd' : 'cmake-js'
);

let targets = require('./package.json').supportedTargets;
let files = [];

let chain = Promise.resolve();

targets.forEach(parts => {
  let runtime = parts[0];
  let version = parts[1];
  let abi = parts[2]
  chain = chain
    .then(function () {
      return build(runtime, version)
    })
    .then(function () {
      return tarGz(runtime, abi)
    })
    .catch(err => {
      console.error(err);
      process.exit(1);
    })
});

chain = chain.then(function () {
  return uploadFiles(files)
});

function build(runtime, version) {
  return new Promise(function (resolve, reject) {
    let args = [
      'rebuild',
      '--runtime-version=' + version,
      '--target_arch=' + arch,
      '--runtime=' + runtime
    ];
    console.log('Compiling iohook for ' + runtime + ' v' + version + '>>>>');
    if (version.split('.')[0] > 4) {
      process.env.msvs_toolset = 14
      process.env.msvs_version = 2015
    } else {
      process.env.msvs_toolset = 12
      process.env.msvs_version = 2013
    }
    let proc = spawn(cmakeJsPath, args, {<commit_msg>Update build.js from VS runtime 2015 to 2017<commit_after>const upload = require('prebuild/upload');
const spawn = require('child_process').spawn;
const fs = require('fs');
const path = require('path');
const mkdirp = require('mkdirp');
const archiver = require('archiver');
const zlib = require('zlib');
const pkg = require('./package.json');

function mode(octal) {
  return parseInt(octal, 8)
}

let arch = process.env.ARCH
  ? process.env.ARCH
    .replace('i686', 'ia32')
    .replace('x86_64', 'x64')
  : process.arch;

let cmakeJsPath = path.join(
  __dirname,
  'node_modules',
  '.bin',
  process.platform === 'win32' ? 'cmake-js.cmd' : 'cmake-js'
);

let targets = require('./package.json').supportedTargets;
let files = [];

let chain = Promise.resolve();

targets.forEach(parts => {
  let runtime = parts[0];
  let version = parts[1];
  let abi = parts[2]
  chain = chain
    .then(function () {
      return build(runtime, version)
    })
    .then(function () {
      return tarGz(runtime, abi)
    })
    .catch(err => {
      console.error(err);
      process.exit(1);
    })
});

chain = chain.then(function () {
  return uploadFiles(files)
});

function build(runtime, version) {
  return new Promise(function (resolve, reject) {
    let args = [
      'rebuild',
      '--runtime-version=' + version,
      '--target_arch=' + arch,
      '--runtime=' + runtime
    ];
    console.log('Compiling iohook for ' + runtime + ' v' + version + '>>>>');
    if (version.split('.')[0] > 4) {
      process.env.msvs_toolset = 14
      process.env.msvs_version = 2017
    } else {
      process.env.msvs_toolset = 12
      process.env.msvs_version = 2013
    }
    let proc = spawn(cmakeJsPath, args, {
{'fraction_non_alphanumeric': 0.17025671289465918, 'fraction_numerical': 0.021245205075243436, 'mean_word_length': 3.1595092024539877, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, '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': '1574623', 'n_tokens_mistral': 1195, 'n_tokens_neox': 1135, 'n_words': 251}