copyfiles
copyfiles copied to clipboard
Does not give error when copying fails
Nothing happens when I run the following script. I don't get an error and no files are being produced.
#!/usr/bin/env node --harmony
const copyfiles = require('copyfiles');
const path = require('path');
const RAZOR_PATH = "Microsoft.AspNet.Razor.3.0.0/lib/net45/System.Web.Razor.dll"
const RAZORENG_PATH = "RazorEngine.3.8.2/lib/net45/RazorEngine.dll"
const JSON_PATH = "Newtonsoft.Json.8.0.3/lib/net45/Newtonsoft.Json.dll"
const destination = '.';
const paths = [ RAZOR_PATH, RAZORENG_PATH, JSON_PATH, destination ].map(path.normalize);
const opts = {};
copyfiles(paths, opts, function(err) {
if(err) {
console.error(`Failed copying dependencies: ${paths}`);
process.exit(1);
}
console.log('.NET dependencies copied successfully')
});
it's not going to give an error if it can't find the paths so that's why it doesn't throw an error
@calvinmetcalf: yeah but why not? It should throw or log a warning when the source path does not exist! It is completely unreliable otherwise ...
That logic makes no sense. If missing files is not an error, then WTF is.
so we pass the paths to glob which tries to match them with paths on the hard drive, but a missing file just means a glob that doesn't match anything, which means we just don't put any files into the queue, so we could do a couple things
- throw an error if a glob doesn't produce any files, though this might be not great if somebody was just using it to transfer a bunch of directories not actually checking if anything was in them
- have it throw an error if nothing gets transferred at all, which would almost always be an error but might miss something
- do 2 by default but has an option for 1
Ok that makes sense - I think adding a verbose flag, that logs a warning when a glob is not returning files would be sufficient for me - no idea what others think of this approach so...
copyfiles does-not.exist out
did not throw. so I'm here..
- If copying a file without glob paths & file doesn't exist or fails — should definitely throw an error.
- If nothing gets copied at all — should definitely throw an error.
- If any defined glob does not produce any files and/or dirs — should definitely throw an error.