sindresorhus / cpy

Copy files
MIT License
425 stars 63 forks source link

The file doesn't exist, even though it does #72

Closed anogr closed 4 years ago

anogr commented 4 years ago

If I try to copy a folder using cpy-cli, I get an error message saying the file doesn't exist. The "file" is a folder, and it does exist.

The error is in index.js, line 81. I don't know the intent of the check !sourcePaths.every(value => files.includes(value)) but that's the reason it fails.

That check was added September 22.

sindresorhus commented 4 years ago

// @whitecrownclown

smileLilith commented 4 years ago

I've faced the same issue when I've tried to copy directory that exists in v8.0.0.

(node:35974) UnhandledPromiseRejectionWarning: NestedError: Cannot copy `node_modules/@fortawesome/fontawesome-free/webfonts`: the file doesn't exist
    at promise (/<my-project-path>/node_modules/cpy/index.js:76:10)
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:35974) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:35974) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Downgrading to v7.3.0 fix the issue.

whitecrownclown commented 4 years ago

// @sindresorhus

The issue introduced here is that we cannot differentiate between folders & files without reading the fs. (afaik)

The !sourcePaths.every(value => files.includes(value)) check would verify the returned files from globby with the provided source (excluding globs). However, directories are listed in the source, but not in the files output and the check would fail.

I think we should revert to only throwing an error when files.length === 0 && !hasGlob(source).

taion commented 4 years ago

ref https://github.com/sindresorhus/cpy/pull/74 – that check had some other problems, too

sindresorhus commented 4 years ago

@whitecrownclown Yeah, lets do that.