This repository has been archived by the owner on May 1, 2022. It is now read-only.
fix(windows): normalize incoming paths to getDestPath #57
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Which issue does this fix?
Closes #46
Describe the solution
Originally, the path separator/resolution issue was fixed in the watch mode but I missed that the fix indeed caused a regression on Windows during the initial build - my bad!
The regression was due to the glob package returning paths with forward slashes regardless of the platform (as documented), causing the initial build to fail on Windows and crashing when the build ended up in the wrong place (src/). Previously, this step would have worked as forward slashes were getting replaced correctly but backslashes returned through watch were not.
This solution uses Node standard library path.normalize to normalize the input paths to getDestPath, in order to always have the OS-specific path to do the regexp magic with.
I guess in the future, using the path package might open up a door to get rid of the regexp altogether and making the path generation more resilient?