<commit_before>#!/usr/bin/env node

/*
  When installing the NPM module, submodules are not initialized automatically.
 */

var runsync = require("runsync");

// TODO: Should be replaced with child_process.execFileSync once Meteor moves to node.js 0.12.
runsync.execFile('git', ['init'], {stdio: 'inherit'});
runsync.execFile('git', ['remote', 'add', 'origin', 'https://github.com/peerlibrary/node-meteor-package-builder.git'], {stdio: 'inherit'});
runsync.execFile('git', ['pull', 'origin', 'master'], {stdio: 'inherit'});
runsync.execFile('git', ['checkout', '-f', 'master'], {stdio: 'inherit'});
runsync.execFile('git', ['submodule', 'sync'], {stdio: 'inherit'});
runsync.execFile('git', ['submodule', 'update', '--init', '--recursive'], {stdio: 'inherit'});

/*
   package-version-parser tries to load packages from ../../dev_bundle/lib/node_modules
   so we have to prepare a symlink to real node_modules directory.
 */

var fs = require('fs');
var path = require('path');

var meteorPath = require.resolve('./meteor/tools/main.js').split(path.sep);
meteorPath.pop(); // Removing "main.js".
meteorPath.pop(); // Removing "tools".
meteorPath = meteorPath.join(path.sep);

var tempPath = path.join(meteorPath, 'dev_bundle');
if (!fs.existsSync(tempPath)) {
  fs.mkdirSync(tempPath);
}
tempPath = path.join(meteorPath, 'dev_bundle', 'lib');
if (!fs.existsSync(tempPath)) {
  fs.mkdirSync(tempPath);
}

var modulesPath = require.resolve('underscore').split(path.sep);
modulesPath.pop(); // Removing "underscore.js".
modulesPath.pop(); // Removing "underscore".
modulesPath = modulesPath.join(path.sep);

tempPath = path.join(meteorPath, 'dev_bundle', 'lib', 'node_modules');
if (!fs.existsSync(tempPath)) {
  fs.symlinkSync(modulesPath, tempPath);
}
<commit_msg>Pull will fail but that is OK.<commit_after>#!/usr/bin/env node

/*
  When installing the NPM module, submodules are not initialized automatically.
 */

var runsync = require("runsync");

// TODO: Should be replaced with child_process.execFileSync once Meteor moves to node.js 0.12.
runsync.execFile('git', ['init'], {stdio: 'inherit'});
runsync.execFile('git', ['remote', 'add', 'origin', 'https://github.com/peerlibrary/node-meteor-package-builder.git'], {stdio: 'inherit'});
try {
  // This commands fails because it cannot merge (there are files it would have to override),
  // but we still need it for checkout later on to work as expected.
  runsync.execFile('git', ['pull', 'origin', 'master'], {stdio: 'inherit'});
}
catch (e) {}
// Merge from the pull failed, but we do not really care, because we want fails to be overridden. Override now.
runsync.execFile('git', ['checkout', '-f', 'master'], {stdio: 'inherit'});
runsync.execFile('git', ['submodule', 'sync'], {stdio: 'inherit'});
runsync.execFile('git', ['submodule', 'update', '--init', '--recursive'], {stdio: 'inherit'});

/*
   package-version-parser tries to load packages from ../../dev_bundle/lib/node_modules
   so we have to prepare a symlink to real node_modules directory.
 */

var fs = require('fs');
var path = require('path');

var meteorPath = require.resolve('./meteor/tools/main.js').split(path.sep);
meteorPath.pop(); // Removing "main.js".
meteorPath.pop(); // Removing "tools".
meteorPath = meteorPath.join(path.sep);

var tempPath = path.join(meteorPath, 'dev_bundle');
if (!fs.existsSync(tempPath)) {
  fs.mkdirSync(tempPath);
}
tempPath = path.join(meteorPath, 'dev_bundle', 'lib');
if (!fs.existsSync(tempPath)) {
  fs.mkdirSync(tempPath);
}

var modulesPath = require.resolve('underscore').split(path.sep);
modulesPath.pop(); // Removing "underscore.js".
modulesPath.pop(); // Removing "underscore".
modulesPath = modulesPath.join(path.sep);

tempPath = path.join(meteorPath, 'dev_bundle', 'lib', 'node_modules');
if (!fs.existsSync(tempPath)) {
  fs.symlinkSync(modulesPath, tempPath);
}

{'fraction_non_alphanumeric': 0.18823223118979432, 'fraction_numerical': 0.0015620932048945586, 'mean_word_length': 5.237012987012987, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '567525', 'n_tokens_mistral': 1302, 'n_tokens_neox': 1254, 'n_words': 320}