Skip to content

Windows paths are not handled correctly #1

@CrazyBS

Description

@CrazyBS

I'm using this plugin on windows and I get the following output when I use level: 0

[hello-world:src\main\webapp\app\page\newClassType.container] Testing

I am importing the plugin to babel using the webpack babel-loader with the following:
['js-logger', { format: { level: 0}}]

When I use the default level of -1, I only get [hello-world] because this path is interpreted as a depth of 1, rather than the correct depth of 6.

Looking at the source code, it appears to only look for forward slash in the directory name and is not normalizing a Windows backslash before doing so:

line 33,34:

  // adjust path length
  modName = modName.split('/').filter(function(i) { return i.length > 0; });

I would suggest that you use the following code instead:
modName = modName.split(path.sep).filter(function(i) { return i.length > 0; });

The reference for path.sep is here: path.sep

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions