<commit_before>'use strict';

var BASE_URL = 'http://w3c.github.io/microdata-rdf/tests';

var request = require('request');
var fs = require('fs');
var path = require('path');
var OUTPUT = path.resolve(__dirname, '../test/suite');
var registry = null;

function fetchManifestEntry (manifest) {
  if (!fs.existsSync(OUTPUT)) fs.mkdirSync(OUTPUT);
  var folderPath = OUTPUT + '/' + manifest.name;
  if (!fs.existsSync(folderPath)) fs.mkdirSync(folderPath);
  fs.writeFileSync(folderPath + '/manifest.json', JSON.stringify(manifest, null, 2));
  request.get({
    url: BASE_URL + '/' + manifest.action
  }).pipe(fs.createWriteStream(folderPath + '/action.html'));
  if (manifest.result) {
    request.get({
      url: BASE_URL + '/' + manifest.result
    }).pipe(fs.createWriteStream(folderPath + '/result.ttl'));
  }
  if (manifest.registry) {
    request.get({
      url: manifest.registry
    }).pipe(fs.createWriteStream(folderPath + '/registry.json'));
  } else {
    fs.writeFile(folderPath + '/registry.json', JSON.stringify(registry, null, 2));
  }
}

function fetchTests (callback) {
  request.get({
    url: BASE_URL + '/manifest.jsonld',
    json: true
  }, function (err, response, manifest) {
    if (err) return callback(err);
    if (response.statusCode !== 200) {
      return callback(new Error('Bad response while fetching manifest'));
    }
    var entries = manifest['@graph'][0].entries;
    request.get({
      url: BASE_URL + '/test-registry.json',
      json: true
    }, function (err, response, _registry) {
      if (err) return callback(err);
      if (response.statusCode !== 200) {
        return callback(new Error('Bad response while fetching manifest'));
      }
      registry = _registry;
      entries.forEach(fetchManifestEntry);
    });
  });
}

fetchTests(function (err) {<commit_msg>fix node warning about missing callback<commit_after>'use strict';

var BASE_URL = 'http://w3c.github.io/microdata-rdf/tests';

var request = require('request');
var fs = require('fs');
var path = require('path');
var OUTPUT = path.resolve(__dirname, '../test/suite');
var registry = null;

function fetchManifestEntry (manifest) {
  if (!fs.existsSync(OUTPUT)) fs.mkdirSync(OUTPUT);
  var folderPath = OUTPUT + '/' + manifest.name;
  if (!fs.existsSync(folderPath)) fs.mkdirSync(folderPath);
  fs.writeFileSync(folderPath + '/manifest.json', JSON.stringify(manifest, null, 2));
  request.get({
    url: BASE_URL + '/' + manifest.action
  }).pipe(fs.createWriteStream(folderPath + '/action.html'));
  if (manifest.result) {
    request.get({
      url: BASE_URL + '/' + manifest.result
    }).pipe(fs.createWriteStream(folderPath + '/result.ttl'));
  }
  if (manifest.registry) {
    request.get({
      url: manifest.registry
    }).pipe(fs.createWriteStream(folderPath + '/registry.json'));
  } else {
    fs.writeFile(folderPath + '/registry.json', JSON.stringify(registry, null, 2), function () {
      return null;
    });
  }
}

function fetchTests (callback) {
  request.get({
    url: BASE_URL + '/manifest.jsonld',
    json: true
  }, function (err, response, manifest) {
    if (err) return callback(err);
    if (response.statusCode !== 200) {
      return callback(new Error('Bad response while fetching manifest'));
    }
    var entries = manifest['@graph'][0].entries;
    request.get({
      url: BASE_URL + '/test-registry.json',
      json: true
    }, function (err, response, _registry) {
      if (err) return callback(err);
      if (response.statusCode !== 200) {
        return callback(new Error('Bad response while fetching manifest'));
      }
      registry = _registry;
      entries.forEach(fetchManifestEntry);
    });
  });
}

fetchTests(function (err) {
{'fraction_non_alphanumeric': 0.16243928764166216, 'fraction_numerical': 0.005396654074473826, 'mean_word_length': 3.599255583126551, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6580695', 'n_tokens_mistral': 1175, 'n_tokens_neox': 1146, 'n_words': 258}