iconify/tools

Filenames are changed in conversion

peterennis opened this issue · 6 comments

My_File_Name.svg becomes my-file-name.svg

Is there an option to not change file names?

capture317

Sure. I assume you are using ImportDir module, then in module options specify keywordCallback option like this:

ImportDir(dir, {
    keywordCallback: function(key, file) {
        let result = file.split('/');
        return result.pop();
    }
})

modules.js shows this: ImportDir: require('./import/dir'),

The only other reference to ImportDir is in the parse.js example:

// Do stuff
tools.ImportDir(sourceDir).then(result => {
    collection = result;
    console.log('Found ' + collection.length() + ' icons.');

Sorry, I don't understand how to use the example you provided.

What code are you using to import svg files?

I am using a modification of this: https://github.com/simplesvg/tools/blob/master/sample/parse.js and passing in the absolute path to the files.

On line 31 you can find tools.ImportDir. Add second parameter to it.

So instead of

tools.ImportDir(sourceDir).then(result => {

it should be

tools.ImportDir(sourceDir, {
    keywordCallback: function(key, file) {
        return file.split('/').pop().split('.').shift();
    }
}).then(result => {

(slightly modified code above)

@cyberalien, That worked. Thanks!