svg-sprite: bug: 2.0.0: `shape.id.separator` does not produce an `id` with the parent directory names
In 1.5.0 shape.id.separator traversed full directory path + file name into the shape ID. Now in 2.0.0 shape ID is always a svg file name, without any parent folders.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 4
- Comments: 21 (14 by maintainers)
Released in v2.0.1
Hi, the problem is related with the change in shape.js line 150:
In version 1.5.4 it was: https://github.com/svg-sprite/svg-sprite/blob/v1.5.4/lib/svg-sprite/shape.js#L150
(It was getting the difference between the full path to the file and the path used to search files).
And now in version 2.0:
[It’s getting th](https://github.com/svg-sprite/svg-sprite/blob/v2.0.0/lib/svg-sprite/shape.js#L151)
It’s getting the name of the full path:
Before:
And the code in the createIdGenerator (not changed), at line 41, it’s waiting a relative path (it’s also explined in the variable comment). https://github.com/svg-sprite/svg-sprite/blob/v1.5.4/lib/svg-sprite/shape.js#L33 https://github.com/svg-sprite/svg-sprite/blob/v2.0.0/lib/svg-sprite/shape.js#L33
So, it can restore the previous line, or comparing the directory full path with the directory base path used to search with path.relative:
And the ID generated is going to have the expected value:
@kan-erik https://github.com/svg-sprite/svg-sprite/blob/main/docs/command-line.md#advanced-globbing
I’m closing this, because this feature is covered in docs
I just wanted to add that this didn’t work for me if the glob-pattern does not contain the “./” in the beginning.
Does not work:
path/to/somefolder/**/*.svgDoes work:
path/to/somefolder/./**/*.svgI think I might know what’s the root cause. I’ll try to have a closer look later.
On Tue, Nov 8, 2022, 15:43 Yehor Kolesnykov @.***> wrote: