<commit_before>#!/usr/bin/env node
'use strict';

const fetch = require('node-fetch'),
    FormData = require('form-data'),
    fs = require('fs'),
    child_process = require('child_process'),
    winston = require('winston'),
    program = require('commander'),

    slack = require('./lib/slack');

program
    .version(require('./package.json').version)
    .option('-p, --project-id <id>', 'Project Id', process.env.PROJECT_ID)
    .option('--server <name>', 'Alternative server address', 'https://testbuild.rocks')
    .option('--ipa <name>', 'Ipa file to upload', `${process.cwd()}/build/Release-iphoneos/` + (process.env.APP_NAME ? `${process.env.APP_NAME}.ipa` : 'app.ipa'))
    .option('--key <key>', 'Test build rocks key', process.env.TEST_BUILD_ROCKS_KEY)
    .option('-s, --slack-hook <hook>', 'Slack Hook', process.env.SLACK_HOOK)
    .option('-c, --slack-channel <channel>', 'Slack Channel', process.env.SLACK_CHANNEL)
    .option('-m, --message <message>', 'Test build rocks message', child_process.execSync('git log --format=%B -n 1 || echo "No comment"'))
    .parse(process.argv);

winston.info('Uploading build');

let data = new FormData();
data.append('app', fs.createReadStream(program.ipa));
data.append('comment', program.message);
data.append('ci', 'true');

var result = fetch(`${program.server}/api/builds/upload/${program.projectId}/ios`, {
    method: 'POST',
    body: data,
    headers: {
        'X-API-Key': program.key,
        'content-length': null //Work around until https://github.com/bitinn/node-fetch/issues/102
    }
})
    .then(res => {
        if (res.status == 200) {
            return res;
        }
        return res.text().then((body) => {
            throw new Error(`Failed to upload build to testbuild.rocks [${body}]`);
        });
    });
if (program.slackHook) {
    result = result.then(slack(program.slackHook, program.slackChannel));
}
result.catch(err => {
    winston.error('Error uploading ipa', err);
    process.exit(1);
});
<commit_msg>Correct work around for uploading<commit_after>#!/usr/bin/env node
'use strict';

const fetch = require('node-fetch'),
    FormData = require('form-data'),
    fs = require('fs'),
    child_process = require('child_process'),
    winston = require('winston'),
    program = require('commander'),

    slack = require('./lib/slack');

program
    .version(require('./package.json').version)
    .option('-p, --project-id <id>', 'Project Id', process.env.PROJECT_ID)
    .option('--server <name>', 'Alternative server address', 'https://testbuild.rocks')
    .option('--ipa <name>', 'Ipa file to upload', `${process.cwd()}/build/Release-iphoneos/` + (process.env.APP_NAME ? `${process.env.APP_NAME}.ipa` : 'app.ipa'))
    .option('--key <key>', 'Test build rocks key', process.env.TEST_BUILD_ROCKS_KEY)
    .option('-s, --slack-hook <hook>', 'Slack Hook', process.env.SLACK_HOOK)
    .option('-c, --slack-channel <channel>', 'Slack Channel', process.env.SLACK_CHANNEL)
    .option('-m, --message <message>', 'Test build rocks message', child_process.execSync('git log --format=%B -n 1 || echo "No comment"'))
    .parse(process.argv);

winston.info('Uploading build');

let data = new FormData();
data.append('app', fs.createReadStream(program.ipa));
data.append('comment', program.message);
data.append('ci', 'true');

data.getLengthSync = null; //Work around until https://github.com/bitinn/node-fetch/issues/102

var result = fetch(`${program.server}/api/builds/upload/${program.projectId}/ios`, {
    method: 'POST',
    body: data,
    headers: {
        'X-API-Key': program.key
    }
})
    .then(res => {
        if (res.status == 200) {
            return res;
        }
        return res.text().then((body) => {
            throw new Error(`Failed to upload build to testbuild.rocks [${body}]`);
        });
    });
if (program.slackHook) {
    result = result.then(slack(program.slackHook, program.slackChannel));
}
result.catch(err => {
    winston.error('Error uploading ipa', err);
    process.exit(1);
});

{'fraction_non_alphanumeric': 0.19731610337972166, 'fraction_numerical': 0.003976143141153081, 'mean_word_length': 3.4871794871794872, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 23, 'https://': 4, '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': '3339356', 'n_tokens_mistral': 1330, 'n_tokens_neox': 1333, 'n_words': 272}