<commit_before>'use babel';

const ntc = require('ntc');
const config = require('./config.json');

export default {
    config: config,

    activate: function() {
        atom.commands.add('atom-workspace', {
            'var-that-color:convert': () => this.convert()
        });
    },

    /**
     * Replace selected lines of hex codes with document appropriate variables
     * for use in css pre-processors
     */
    convert: function() {
        this.editor = atom.workspace.getActiveTextEditor();

        const selection = this.editor.getLastSelection();
        const selectionRange = selection.getBufferRange();
        const selectedLines = selection.getText();
        const selectedLinesArray = selectedLines.match(/[^\r\n]+/g);

        let convertedLinesArray = selectedLinesArray;

        selectedLinesArray.map((line, index) => {
            let newLine = line;

            if (this.isHex(line)) {
                newLine = this.getOutput(line);
            }

            convertedLinesArray[index] = newLine;
        });
<commit_msg>Fail nicely and display a coherant error message<commit_after>'use babel';

const ntc = require('ntc');
const config = require('./config.json');

export default {
    config: config,

    activate: function() {
        atom.commands.add('atom-workspace', {
            'var-that-color:convert': () => this.convert()
        });
    },

    /**
     * Replace selected lines of hex codes with document appropriate variables
     * for use in css pre-processors
     */
    convert: function() {
        this.editor = atom.workspace.getActiveTextEditor();

        const selection = this.editor.getLastSelection();
        const selectionRange = selection.getBufferRange();
        const selectedLines = selection.getText();
        const selectedLinesArray = selectedLines.match(/[^\r\n]+/g);

        if (!selectedLinesArray) {
            atom.notifications.addError(
                'Unable to var that color: No hex color selected',
                {
                    dismissable: true
                }
            );
            return;
        }

        let convertedLinesArray = selectedLinesArray;

        selectedLinesArray.map((line, index) => {
            let newLine = line;

            if (this.isHex(line)) {
                newLine = this.getOutput(line);
            }

            convertedLinesArray[index] = newLine;
        });

{'fraction_non_alphanumeric': 0.11774461028192372, 'fraction_numerical': 0.0, 'mean_word_length': 2.0738853503184713, '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': '473708', 'n_tokens_mistral': 634, 'n_tokens_neox': 612, 'n_words': 146}