<commit_before>"use strict";

let path = require("path");
let shell = require("shelljs");
let fileUrl = require("file-url");
let Nightmare = require("nightmare");

// Get list of names to process
let names = [];
if (process.argv.length == 2) {
    // Default to all Elm files
    names = shell.ls("*.elm").map(function(filename) {
        return path.basename(filename, ".elm");
    });
} else {
    // Otherwise, use specified names
    names = process.argv.slice(2);
}

// Create output directory if necessary
if (!shell.test("-d", "output")) {
    shell.mkdir("output");
}

// Loop through each input
names.forEach(function(name) {
    let elmFilename = name + ".elm";
    let htmlFilename = "output/" + name + ".html";
    let elmMakeCommand = "elm make --yes --output " + htmlFilename + " " + elmFilename;
    // Compile Elm file to HTML
    if (shell.exec(elmMakeCommand).code == 0) {
        // Render HTML to PNG
        let nightmare = Nightmare({show: false}).viewport(1024, 768);
        let pngFilename = "output/" + name + ".png";
        let dimensions = {x: 0, y: 0, width: 240, height : 240};
        let url = fileUrl(htmlFilename);
        nightmare.goto(url).screenshot(pngFilename, dimensions).end().then(function (result) {
            console.log("Rendered " + pngFilename);<commit_msg>Add package installation to image script<commit_after>"use strict";

let path = require("path");
let shell = require("shelljs");
let fileUrl = require("file-url");
let Nightmare = require("nightmare");

// Get list of names to process
let names = [];
if (process.argv.length == 2) {
    // Default to all Elm files
    names = shell.ls("*.elm").map(function(filename) {
        return path.basename(filename, ".elm");
    });
} else {
    // Otherwise, use specified names
    names = process.argv.slice(2);
}

// Install any needed Elm packages
if (shell.exec("elm package install --yes").code != 0) {
    shell.echo("Elm package installation failed");
    process.exit(1);
}

// Create output directory if necessary
if (!shell.test("-d", "output")) {
    shell.mkdir("output");
}

// Loop through each input
names.forEach(function(name) {
    let elmFilename = name + ".elm";
    let htmlFilename = "output/" + name + ".html";
    let elmMakeCommand = "elm make --yes --output " + htmlFilename + " " + elmFilename;
    // Compile Elm file to HTML
    if (shell.exec(elmMakeCommand).code == 0) {
        // Render HTML to PNG
        let nightmare = Nightmare({show: false}).viewport(1024, 768);
        let pngFilename = "output/" + name + ".png";
        let dimensions = {x: 0, y: 0, width: 240, height : 240};
        let url = fileUrl(htmlFilename);
        nightmare.goto(url).screenshot(pngFilename, dimensions).end().then(function (result) {
            console.log("Rendered " + pngFilename);
{'fraction_non_alphanumeric': 0.1594306049822064, 'fraction_numerical': 0.013523131672597865, 'mean_word_length': 3.091703056768559, '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': '2426417', 'n_tokens_mistral': 872, 'n_tokens_neox': 834, 'n_words': 246}