function copyFile(obj, callback) {
  let called = false;
  function done(err) {
    if (!called) {
      called = true;
      callback(err);
    }
  }

  const read = fs.createReadStream(obj.src);
  read.on('error', (err) => {
    done(err);
  });

  const write = fs.createWriteStream(obj.dest);
  write.on('error', (err) => {
    done(err);
  });
  write.on('close', () => {
    done();
  });

  read.pipe(write);
}
Copy a file.
@param {Object} obj Object with src and dest properties.
@param {function(Error):void} callback Callback