fs#copyFile JavaScript Examples

The following examples show how to use fs#copyFile. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: jpg.js    From ucompress with ISC License 6 votes vote down vote up
optimize = (args, source, dest) => new Promise((res, rej) => {
  sharp(source).jpeg(args).toFile(dest).then(
    () => res(dest),
    () => {
      copyFile(source, dest, err => {
        /* istanbul ignore else */
        if (err) rej(err);
        else res(dest);
      });
    }
  );
})
Example #2
Source File: png.js    From ucompress with ISC License 6 votes vote down vote up
optimize = (source, dest) => new Promise((res, rej) => {
  execFile(pngquant, pngquantArgs.concat(dest, source), err => {
    if (err) {
      copyFile(source, dest, err => {
        if (err) rej(err);
        else res(dest);
      });
    }
    else
      res(dest);
  });
})