filer icon indicating copy to clipboard operation
filer copied to clipboard

Adding in support for fs.copyFile.

Open Mordax opened this issue 6 years ago • 9 comments

I noticed that Filer does not support fs.copyFile. What's your opinion on me taking on writing out the code/doing a test for this? Difficult or good feature to work on? @humphd

Mordax avatar Sep 21 '18 20:09 Mordax

Nice catch, I didn't realize node had added this to fs. Yes, I think it would be good to have it. Why don't you start by writing a test and submit that, then seen where you're at. You could always use the full implementation as another release later in the course if you find it's too big.

In the simplest case, a copyFile is basically:

function copyFile(src, dest, flags, callback) {
  // Deal with flags, which could be something we add in future PRs...

  fs.readFile(src, null, (err) => {
    if(err) {
      return callback(err);
    }
    fs.writeFile(dest, null, callback);
  });
}

humphd avatar Sep 21 '18 23:09 humphd

Alright, I'll take a crack at it, if you don't mind.

Mordax avatar Sep 21 '18 23:09 Mordax

Hi, how is it going with the test, anything you would like to work on together?

YuechengWu avatar Sep 23 '18 20:09 YuechengWu

@YuechengWu I'm not sure if @Mordax is doing just the implementation or if she is doing tests too. Would be great if you two could collaborate somehow.

humphd avatar Sep 23 '18 21:09 humphd

@humphd I took your advice and I'm currently working on the tests first and implementation later. Besides the regular testing, copyFile has some flags that we can test out, @YuechengWu. So there is some more work there.

Mordax avatar Sep 23 '18 21:09 Mordax

Agree, doing tests for all those various flags, even if we don't land an implementation for them all, would be good.

humphd avatar Sep 23 '18 21:09 humphd

@Mordax Hi Mordax, what is your name on slack? It would be easier for us to communicate that way if you want.

YuechengWu avatar Sep 23 '18 21:09 YuechengWu

@YuechengWu Sent you a message ✌️

Mordax avatar Sep 23 '18 23:09 Mordax

#481 has added some basic tests for this, currently skipped.

humphd avatar Dec 17 '18 21:12 humphd