<commit_before>'use strict';
const uniqueId = require('lodash/uniqueId');
const includes = require('lodash/includes');
const Config = require('./config');

module.exports = function dedupeProcessName(config) {
    let systemConfig = Config.load('system');
    let existingProcessNames = Object.keys(systemConfig.get('instances'));
    let pname = config.get('pname');

    // Continue searching until we've found a new unique id
    while (includes(existingProcessNames, pname)) {
        pname = uniqueId(pname.endsWith('-') ? pname : `${pname}-`);
    }

    // If pname has changed, update the config
    if (pname !== config.get('pname')) {
        config.set('pname', pname).save();
    }
}<commit_msg>🐛 ensure dedupeProcessName util doesn't fail if  no running instances<commit_after>'use strict';
const uniqueId = require('lodash/uniqueId');
const includes = require('lodash/includes');
const Config = require('./config');

module.exports = function dedupeProcessName(config) {
    let systemConfig = Config.load('system');
    let existingProcessNames = Object.keys(systemConfig.get('instances', {}));
    let pname = config.get('pname');

    // Continue searching until we've found a new unique id
    while (includes(existingProcessNames, pname)) {
        pname = uniqueId(pname.endsWith('-') ? pname : `${pname}-`);
    }

    // If pname has changed, update the config
    if (pname !== config.get('pname')) {
        config.set('pname', pname).save();
    }
}
{'fraction_non_alphanumeric': 0.15400271370420623, 'fraction_numerical': 0.0, 'mean_word_length': 3.9496644295302015, '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': '2992493', 'n_tokens_mistral': 442, 'n_tokens_neox': 428, 'n_words': 111}