<commit_before>'use strict';

const path = require('path');
const fs = require('fs');
const glob = require('glob');
const SVGSpriter = require('./lib/svg-sprite.js');

const cwd = path.join(__dirname, 'test/fixture/svg/single');
const dest = path.join(__dirname, 'tmp');
const files = glob.sync('**/weather*.svg', { cwd });

const spriter = new SVGSpriter({
    dest,
    log: 'debug',
    shape: {
        transform: [{
            svgo: {
                multipass: true,
                plugins: [{
                    name: 'preset-default',
                    params: {
                        overrides: {
                            cleanupListOfValues: true,
                            removeAttrs: {
                                attrs: [
                                    'data-name',
                                    'fill',
                                    'clip-rule'
                                ]
                            },
                            removeUnknownsAndDefaults: {
                                keepRoleAttr: true
                            },
                            removeViewBox: false,
                            sortAttrs: true
                        }
                    }
                }]
            }
        }]
    }
});

/**
 * Add a bunch of SVG files
 *
 * @param {SVGSpriter} spriter          Spriter instance
 * @param {Array} files                 SVG files
 * @return {SVGSpriter}                 Spriter instance
 */
function addFixtureFiles(spriter, files) {
    files.forEach(file => {
        spriter.add(
            path.resolve(path.join(cwd, file)),
            file,<commit_msg>example: fix SVGO config<commit_after>'use strict';

const path = require('path');
const fs = require('fs');
const glob = require('glob');
const SVGSpriter = require('./lib/svg-sprite.js');

const cwd = path.join(__dirname, 'test/fixture/svg/single');
const dest = path.join(__dirname, 'tmp');
const files = glob.sync('**/weather*.svg', { cwd });

const spriter = new SVGSpriter({
    dest,
    log: 'debug',
    svg: {
        doctypeDeclaration: false,
        xmlDeclaration: false
    },
    shape: {
        transform: [{
            svgo: {
                multipass: true,
                plugins: [
                    {
                        name: 'preset-default',
                        params: {
                            overrides: {
                                removeUnknownsAndDefaults: {
                                    keepRoleAttr: true
                                },
                                removeViewBox: false
                            }
                        }
                    },
                    'cleanupListOfValues',
                    'convertStyleToAttrs',
                    'sortAttrs',
                    {
                        name: 'removeAttrs',
                        params: {
                            attrs: [
                                'clip-rule',
                                'data-name'
                            ]
                        }
                    }
                ]
            }
        }]
    }
});

/**
 * Add a bunch of SVG files
 *
 * @param {SVGSpriter} spriter          Spriter instance
 * @param {Array} files                 SVG files
 * @return {SVGSpriter}                 Spriter instance
 */
function addFixtureFiles(spriter, files) {
    files.forEach(file => {
        spriter.add(
            path.resolve(path.join(cwd, file)),
            file,
{'fraction_non_alphanumeric': 0.10341904492794575, 'fraction_numerical': 0.0, 'mean_word_length': 0.9547211485367201, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5118893', 'n_tokens_mistral': 885, 'n_tokens_neox': 845, 'n_words': 177}