<commit_before>const path = require('path');

const s = require('shelljs');

const BUILD = path.join(__dirname, 'build.js');
const WHITELIST = ['build', 'CNAME'];

// this builds the static file, and pushes it to a branch on github
// Usage: node ./scripts/deploy.js <branch-name>
// Example: node ./scripts/deploy.js gh-pages

var deployBranch = process.argv[2];
if (!deployBranch) {
  console.log('Usage: node ./scripts/deploy.js <branch-name>');
  process.exit(1);
}
console.log('Deploying ' + deployBranch + '...');

// get deploy version
var version = s.exec('git rev-parse HEAD', { silent: true }).output;

// run the build script
console.log('Building static site...');
s.exec('node ' + BUILD);

// checkout <branch-name>
var currentBranch = s.exec('git rev-parse --abbrev-ref HEAD', { silent: true }).output;
s.exec('git checkout ' + deployBranch);

// clean out all files not on whitelist
var files = s.ls('-A', './').filter(function(name) {
  return !WHITELIST.indexOf(name);
});

s.rm('-Rf', files);

// cp build/* to ./*
s.cp('-Rf', './build/*','./');

// remove build/*<commit_msg>copy to tmpdir before checkout other branch<commit_after>const os = require('os');
const path = require('path');

const s = require('shelljs');

const BUILD = path.join(__dirname, 'build.js');
const WHITELIST = ['CNAME'];

// this builds the static file, and pushes it to a branch on github
// Usage: node ./scripts/deploy.js <branch-name>
// Example: node ./scripts/deploy.js gh-pages

var deployBranch = process.argv[2];
if (!deployBranch) {
  console.log('Usage: node ./scripts/deploy.js <branch-name>');
  process.exit(1);
}
console.log('Deploying ' + deployBranch + '...');

// get deploy version
var version = s.exec('git rev-parse HEAD', { silent: true }).output;

// run the build script
console.log('Building static site...');
s.exec('node ' + BUILD);

// copy build directory to tmpdir
const TMP = path.join(os.tmpDir(), 'build-' + version);
s.cp('-Rf', './build', TMP);

// checkout <branch-name>
var currentBranch = s.exec('git rev-parse --abbrev-ref HEAD', { silent: true }).output;
s.exec('git checkout ' + deployBranch);

// clean out all files not on whitelist
var files = s.ls('-A', './').filter(function(name) {
  return !WHITELIST.indexOf(name);
});

s.rm('-Rf', files);

// cp build/* to ./*
s.cp('-Rf', path.join(TMP, '*'),'./');

// remove build/*
{'fraction_non_alphanumeric': 0.20059246720270843, 'fraction_numerical': 0.0016927634363097758, 'mean_word_length': 3.814663951120163, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '719669', 'n_tokens_mistral': 815, 'n_tokens_neox': 793, 'n_words': 226}