sindresorhus / trash

Move files and directories to the trash
MIT License
2.57k stars 78 forks source link

Trash with globs exclusion needs to be passed array of paths from Globby #85

Open Cloud7050 opened 5 years ago

Cloud7050 commented 5 years ago

When running this code:

    let trashArr = [
        "./public/img",
        "!./public/img/*/**"
    ];
    Trash(trashArr);

I get this error:

(node:15172) UnhandledPromiseRejectionWarning: Error: Command failed: D:\x\node_modules\trash\lib\windows-trash.exe D:\x\public\img

    at ChildProcess.exithandler (child_process.js:275:12)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)

But this code works as expected:

    let trashArr = [
        "./public/img",
        "!./public/img/*/**"
    ];
    Globby(trashArr).then(paths => Trash(paths));
threequartersjohn commented 5 years ago

I was able to run your example code without errors, would you mind adding some information to help replicate this situation?

Cloud7050 commented 5 years ago

Hello, thanks for the response. May I know what additional information I can provide that would help?

threequartersjohn commented 5 years ago

I would think packages and node versions, and operating system.