<commit_before>import Template from "./Template/Template";

import fs = require('fs');
import childProcess = require( 'child_process' );

export default class BuildTask
{
    private template: Template;
    private target: string;
    private command: string;

    private lastBuiltContent: string;

    constructor(template: Template, target: string, command: string)
    {
        this.template = template;
        this.target = target;
        this.command = command;

        this.lastBuiltContent = null;
    }

    build(data: any)
    {
        let newContent = this.template.render(data);
        if (newContent != this.lastBuiltContent) {

            this.lastBuiltContent = newContent;

            fs.writeFileSync(
                this.target,
                newContent,
                "utf8"
            );

            if (this.command !== null) {
                console.log("Running command: " + this.command);
                childProcess.execSync(this.command, {stdio:[0,1,2]});
                console.log("Finished command: " + this.command);
            }

            console.log("Target file " + this.target + " written");
        } else {
            console.log("Target file " + this.target + " untouched - same content");
        }
    }
}<commit_msg>don't save null content<commit_after>import Template from "./Template/Template";

import fs = require('fs');
import childProcess = require( 'child_process' );

export default class BuildTask
{
    private template: Template;
    private target: string;
    private command: string;

    private lastBuiltContent: string;

    constructor(template: Template, target: string, command: string)
    {
        this.template = template;
        this.target = target;
        this.command = command;

        this.lastBuiltContent = null;
    }

    build(data: any)
    {
        let newContent = this.template.render(data);
        if (newContent === null) {
            console.log("Target file " + this.target + " untouched - no new content");
        } else if (newContent == this.lastBuiltContent) {
            console.log("Target file " + this.target + " untouched - same content");
        } else {
            this.lastBuiltContent = newContent;

            fs.writeFileSync(
                this.target,
                newContent,
                "utf8"
            );

            if (this.command !== null) {
                console.log("Running command: " + this.command);
                childProcess.execSync(this.command, {stdio:[0,1,2]});
                console.log("Finished command: " + this.command);
            }

            console.log("Target file " + this.target + " written");
        }
    }
}
{'fraction_non_alphanumeric': 0.1156412157153447, 'fraction_numerical': 0.0029651593773165306, 'mean_word_length': 1.9691969196919692, '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': '1727695', 'n_tokens_mistral': 732, 'n_tokens_neox': 692, 'n_words': 168}