<commit_before>
var system = require('system');
var fs = require('file');

module.shared = true;

export('load', 'normalize', 'catalog');

var catalog;

function load() {
    if (catalog) {
        return;
    }

    catalog = {};
    // loop through packages and configure resources
    var packages = fs.join(system.prefix, 'packages');

    for each (var pkg in fs.list(packages)) {

        var directory = fs.join(packages, pkg);
        if (!fs.isDirectory(directory)) {
            continue;
        }

        try {
            var jsonPath = fs.join(directory, "package.json");
            var package = JSON.parse(fs.read(jsonPath).trim());
            package.directory = directory;

            // check engine specific libs
            handleResource(package.engines || "engines", function(engines) {
                var dir = fs.join(directory, engines);
                for each (var engine in system.engines) {<commit_msg>Don't fail on missing packages directory, no more need to trim json before parsing.<commit_after>
var system = require('system');
var fs = require('file');

module.shared = true;

export('load', 'normalize', 'catalog');

var catalog;

function load() {
    if (catalog) {
        return;
    }

    catalog = {};
    // loop through packages and configure resources
    var packages = fs.join(system.prefix, 'packages');

    if (!fs.isDirectory(packages)) {
        print("No packages directory, skipping package setup");
        return;
    }

    for each (var pkg in fs.list(packages)) {

        var directory = fs.join(packages, pkg);
        if (!fs.isDirectory(directory)) {
            continue;
        }

        try {
            var jsonPath = fs.join(directory, "package.json");
            var package = JSON.parse(fs.read(jsonPath));
            package.directory = directory;

            // check engine specific libs
            handleResource(package.engines || "engines", function(engines) {
                var dir = fs.join(directory, engines);
                for each (var engine in system.engines) {
{'fraction_non_alphanumeric': 0.12360639844886089, 'fraction_numerical': 0.0, 'mean_word_length': 2.291866028708134, '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': '7015664', 'n_tokens_mistral': 565, 'n_tokens_neox': 542, 'n_words': 162}