app/lib/rotator.js
async function renameOrDelete(srcPath, targetPath) {
  if (srcPath === targetPath) {
    return;
  }
  const srcExists = await fs.exists(srcPath);
  if (!srcExists) {
    return;
  }
  const targetExists = await fs.exists(targetPath);
  // if target file exists, then throw
  // because the target file always be renamed first.
  if (targetExists) {
    const err = new Error(`targetFile ${targetPath} exists!!!`);
    throw err;
  }
  await fs.rename(srcPath, targetPath);
}
async function renameOrDelete(srcPath, targetPath) {
  if (srcPath === targetPath) {
    return;
  }
  const srcExists = await fs.exists(srcPath);
  if (!srcExists) {
    return;
  }
  const targetExists = await fs.exists(targetPath);
  // if target file exists, then throw
  // because the target file always be renamed first.
  if (targetExists) {
    const err = new Error(`targetFile ${targetPath} exists!!!`);
    throw err;
  }
  await fs.rename(srcPath, targetPath);
}
async function renameOrDelete ( srcPath , targetPath ) { if ( srcPath === targetPath ) { return ; } const srcExists = await fs . exists ( srcPath ) ; if ( ! srcExists ) { return ; } const targetExists = await fs . exists ( targetPath ) ; // if target file exists, then throw // because the target file always be renamed first. if ( targetExists ) { const err = new Error ( ` ${ targetPath } ` ) ; throw err ; } await fs . rename ( srcPath , targetPath ) ; }
rename from srcPath to targetPath, for example foo.log.1 > foo.log.2
rename from srcPath to targetPath for example foo . log . 1 > foo . log . 2