<commit_before>"use strict";
const fs = require('fs');
const url = require('url');
const path = require('path');
const request = require('request');
const mkdirp = require('mkdirp');
const rimraf = require('rimraf');
const exec = require('child_process').exec;

const publicDir = process.env.GITLAB_CE_PAGES_PUBLIC_DIR;
const privateToken = process.env.PAGE_PRIVATE_TOKEN;
const projectRoot = process.env.PROJECT_ROOT;

let gitlabUrl = process.env.GITLAB_URL || 'localhost';
gitlabUrl = gitlabUrl.replace(/\/*$/, '/');

function extract(artifactName, artifactPath, destination) {
  exec('unzip ' + artifactPath + ' -d ' + destination, (err, stdout, stderr) => {
    if (err) {
      console.error('unzip', artifactName, 'failed');
      console.error(err);
    } else {
      console.log('unzipped', artifactName, 'into', destination);
      console.log('removing artifact', artifactPath);
      exec('rm ' + artifactPath,
        (err, stdout, stderr) => {
          if (err) {
            console.error('removing artifact', artifactPath, 'failed');
            console.error(err);
          } else {
            console.log('removing artifact', artifactPath, 'succeed');
          }
        }
      );
      if (projectRoot) {
        console.log('moving files out of', projectRoot);
        exec('cd ' + destination + ' && mv ' + projectRoot + ' PROJECT_ROOT && cd PROJECT_ROOT && mv ./* .. && cd .. && rm -rf PROJECT_ROOT',
          (err, stdout, stderr) => {
            if (err) {
              console.error('moving files out of', projectRoot, 'failed');
              console.error(err);
            } else {
              console.log('moving files out of', projectRoot, 'succeed');
            }
          }
        );
      }
    }
  });
}

function update(body, pageDir) {
  if (!privateToken) {
    console.log('missing private token');
    return;
  }
  mkdirp(pageDir, (err) => {
    if (err) {
      console.log('mkdir', pageDir, 'failed');
      return;
    }<commit_msg>refine log and comment<commit_after>"use strict";
const fs = require('fs');
const url = require('url');
const path = require('path');
const request = require('request');
const mkdirp = require('mkdirp');
const rimraf = require('rimraf');
const exec = require('child_process').exec;

const publicDir = process.env.GITLAB_CE_PAGES_PUBLIC_DIR;
const privateToken = process.env.PAGE_PRIVATE_TOKEN;
const projectRoot = process.env.PROJECT_ROOT;

let gitlabUrl = process.env.GITLAB_URL || 'localhost';
gitlabUrl = gitlabUrl.replace(/\/*$/, '/');

function extract(artifactName, artifactPath, destination) {
  exec('unzip ' + artifactPath + ' -d ' + destination, (err, stdout, stderr) => {
    if (err) {
      console.error('unzip', artifactName, 'failed');
      console.error(err);
    } else {
      console.log('unzipped', artifactName, 'into', destination);
      console.log('removing artifact', artifactPath);
      // Artifact is expected to run parallel with moving files down below
      exec('rm ' + artifactPath,
        (err, stdout, stderr) => {
          if (err) {
            console.error('artifact removal', artifactPath, 'failed');
            console.error(err);
          } else {
            console.log('artifact removal', artifactPath, 'succeed');
          }
        }
      );
      if (projectRoot) {
        console.log('moving files out of', projectRoot);
        exec('cd ' + destination + ' && mv ' + projectRoot + ' PROJECT_ROOT && cd PROJECT_ROOT && mv ./* .. && cd .. && rm -rf PROJECT_ROOT',
          (err, stdout, stderr) => {
            if (err) {
              console.error('files moving out of', projectRoot, 'failed');
              console.error(err);
            } else {
              console.log('files moving out of', projectRoot, 'succeed');
            }
          }
        );
      }
    }
  });
}

function update(body, pageDir) {
  if (!privateToken) {
    console.log('missing private token');
    return;
  }
  mkdirp(pageDir, (err) => {
    if (err) {
      console.log('mkdir', pageDir, 'failed');
      return;
    }
{'fraction_non_alphanumeric': 0.15426318383440119, 'fraction_numerical': 0.0, 'mean_word_length': 2.624107142857143, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '3776642', 'n_tokens_mistral': 1250, 'n_tokens_neox': 1208, 'n_words': 284}