<commit_before>const https = require("https");
const fs = require("fs");

module.exports = class Artist {
    constructor(artistObject) {
        this.id = artistObject.id;
        this.name = artistObject.name;
        this.tracks = [];
        this.artistObject = artistObject;
        this.artId = artistObject.picture;
    }

    async updateTracks(tidalApi) {
        this.tracks = await tidalApi.getArtistTopTracks(this);
    }

    updateArt(tidalApi) {
        return new Promise((resolve, reject) => {
            this.mkdirSync("/tmp/tidal-cli-client");
            this.artURL = tidalApi.getArtURL(this.artId, 750, 750);
            this.artSrc = "/tmp/tidal-cli-client/" + this.artId + ".jpg";
            let artFile = fs.createWriteStream(this.artSrc);
            https.get(this.artURL, response => {
                response.pipe(artFile);
                resolve();
            });
        });
    }

    mkdirSync(dirPath) {
        try {
            fs.mkdirSync(dirPath)
        } catch (err) {
            if (err.code !== "EXIST") throw err;
        }
    }

    
};<commit_msg>Check if directory exists before creating<commit_after>const https = require("https");
const fs = require("fs");

module.exports = class Artist {
    constructor(artistObject) {
        this.id = artistObject.id;
        this.name = artistObject.name;
        this.tracks = [];
        this.artistObject = artistObject;
        this.artId = artistObject.picture;
    }

    async updateTracks(tidalApi) {
        this.tracks = await tidalApi.getArtistTopTracks(this);
    }

    updateArt(tidalApi) {
        return new Promise((resolve, reject) => {
            this.mkdirSync("/tmp/tidal-cli-client");
            this.artURL = tidalApi.getArtURL(this.artId, 750, 750);
            this.artSrc = "/tmp/tidal-cli-client/" + this.artId + ".jpg";
            let artFile = fs.createWriteStream(this.artSrc);
            https.get(this.artURL, response => {
                response.pipe(artFile);
                resolve();
            });
        });
    }

    mkdirSync(dirPath) {
        if(!fs.existsSync(dirPath)) {
            try {
                fs.mkdirSync(dirPath)
            } catch (err) {
                if (err.code !== "EEXIST") throw err;
            }
        }
    }

    
};
{'fraction_non_alphanumeric': 0.13234653896386592, 'fraction_numerical': 0.00522420548541576, 'mean_word_length': 1.837037037037037, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4573234', 'n_tokens_mistral': 715, 'n_tokens_neox': 674, 'n_words': 116}