django-npm icon indicating copy to clipboard operation
django-npm copied to clipboard

Path separators should be translated on Windows

Open bblanchon opened this issue 1 year ago • 2 comments

On Windows, NPM_FILE_PATTERNS only works if you use backslash separators like so:

NPM_FILE_PATTERNS = {
    "bootstrap": [
        "dist\\css\\bootstrap.min.css",
        "dist\\css\\bootstrap.min.css.map",
        "dist\\js\\bootstrap.bundle.min.js",
        "dist\\js\\bootstrap.bundle.min.js.map",
    ],
}

This is problematic when you want to write portable code. We should be able to use forward slash on all operating systems.

Let me know if you want me to open a Pull Request.

bblanchon avatar Dec 14 '23 12:12 bblanchon

~~I believe this bug is already fixed by #18.~~

Nope, I just checked with the master branch, and the problem is still there.

bblanchon avatar Dec 14 '23 19:12 bblanchon

Interestingly, you can work around this issue by using Paths instead of strings:

NPM_FILE_PATTERNS = {
    "bootstrap": [
        Path("dist/css/bootstrap.min.css"),
        Path("dist/css/bootstrap.min.css.map"),
        Path("dist/js/bootstrap.bundle.min.js"),
        Path("dist/js/bootstrap.bundle.min.js.map"),
    ],
}

bblanchon avatar Dec 15 '23 10:12 bblanchon