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

wrong behavior on windows when using glob "*" #23

Open
oupala opened this issue Jul 27, 2017 · 2 comments
Open

wrong behavior on windows when using glob "*" #23

oupala opened this issue Jul 27, 2017 · 2 comments
Labels

Comments

@oupala
Copy link

oupala commented Jul 27, 2017

I've just noticed a wrong behavior on windows when using glob "*".

C:\test
└───source
    └───path
        └───to
            └───a
                └───file
└───dest1
└───dest2

The main objective is to copy the file file and its tree to the destination directory (dest1 or dest2).

When using a full path to specify which files to copy, everything goes well.

λ node_modules\.bin\copy source/path/to/a/file dest1/
√ dest1\source\path\to\a\file

The result is that the file file is copied with is whole tree.

C:\test
└───source
    └───path
        └───to
            └───a
                └───file
└───dest1
    └───source
        └───path
            └───to
                └───a
                    └───file
└───dest2

When using a glob pattern "*" to specify multiple files to copy, things get worse.

node_modules\.bin\copy source/path/to/a/* dest2/
√ ..\..\..\..\dest2\file

The result is that the file file is copied but without its tree.

C:\test
└───source
    └───path
        └───to
            └───a
                └───file
└───dest1
    └───source
        └───path
            └───to
                └───a
                    └───file
└───dest2
    └───file

This bug does not happen on linux.

@ghost
Copy link

ghost commented Mar 18, 2018

Any update ?

@DJDaveMark
Copy link

I think this bug comes from the fact that the flatten option is inconsistent if the glob matches a single file or multiple files. If you always specify the flatten option, you'll get the expected results:

No flatten option (commented out)

copy('path/to/a/file', 'dest', /*{flatten: false},*/ function (err, files) {
    // dest/path/to/a/file
});
copy('path/to/a/file*', 'dest', /*{flatten: true},*/ function (err, files) {
    // dest/file
});

Flatten option (inversed from above)

copy('path/to/a/file', 'dest', {flatten: true}, function (err, files) {
    // dest/file
});
copy('path/to/a/file*', 'dest', {flatten: false}, function (err, files) {
    // dest/path/to/a/file
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants