Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Won't copy files when there are square brackets [ ] in the path #231

Closed
flawiddsouza opened this issue Feb 23, 2018 · 9 comments · Fixed by #264
Closed

Won't copy files when there are square brackets [ ] in the path #231

flawiddsouza opened this issue Feb 23, 2018 · 9 comments · Fixed by #264

Comments

@flawiddsouza
Copy link

flawiddsouza commented Feb 23, 2018

A tiny repo to reproduce the issue:
https://github.com/flawiddsouza/Reproduce-bracket-bug-in-copy-webpack-plugin

Go to each folder & run:
npm install
npm start

The folder without brackets will copy the file "from" to "to" but the one with brackets will not.

@alexander-akait
Copy link
Member

@flawiddsouza Can you upgrade to latest version (npm cache clear --force & npm install)

@flawiddsouza
Copy link
Author

Updated. Still broken. The files aren't copied if the path contains square brackets.

@alexander-akait
Copy link
Member

@flawiddsouza don't reproduce, what os you use?

@flawiddsouza
Copy link
Author

Windows 10 Version 1709

@goldenram
Copy link

this happens for me when using regex captures:

new CopyWebpackPlugin([ { from: '../../../src/**/docs/*.md', to: 'docs/[1][name].[ext]', toType: 'template', test: /([^/]+)\/([a-z,0-9]*)\/(\/?$).md/, } ], {debug: 'debug'}),

I am expecting to get files outputted as "dirName-fileName.md" however I am getting instead [1]-fileName.md".

@marcoqu
Copy link

marcoqu commented May 2, 2018

I have the same issue with regular brackets in the path. I.e. D:/User/Dropbox (My Company)/project/**/*

Could it be related to this issue in Globby?
See also this very similar issue with globbing and windows folders in Chokidar. They ended up adding a "disable globbing" option.

@alexander-akait
Copy link
Member

@marcoqu looks like we have two issue - one in globby (i.e. node-glob) and second in chokidar 😄 Also latest globby use fast-glob package, maybe update deps can solve this problem

@marcoqu
Copy link

marcoqu commented May 2, 2018

Sorry. In my case this has nothing to do with the globbing.
The issue is with path escaping in escape.js which escapes characters (the parentheses) that are part actual parts of the path.
If I remove the parentheses pattern from the regular expression, everything works fine.

edit
or does it?

Please only use forward-slashes in glob expressions.
https://github.com/isaacs/node-glob/#windows
isaacs/node-glob#212

loveky added a commit to loveky/copy-webpack-plugin that referenced this issue May 23, 2018
@loveky
Copy link
Contributor

loveky commented May 28, 2018

@goldenram If you are on Windows system. You should use \ as path separator in your test regexp.

if you want it works on both Windows and Mac/Linux. You can leverage path.sep. So you can try

const path = require('path');
// then
test: new RegExp(`([^/]+)\\${path.sep}([a-z,0-9]*)\\${path.sep}(\\/?$).md`)

alexander-akait pushed a commit that referenced this issue Jun 1, 2018
* fix #231 allow brackets in path

* only need take care of [

* use character sets to escape special character to avoid issue on Windows

* [fix 220] create special directory/file through scripts

* rm helpers directory on every test

* add new line to the end of scripts

* update code, add tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants