async function copyFolder()

in scripts/sync-docs.js [227:244]


async function copyFolder(srcDir, tarDir) {
  const [files] = await Promise.all([fs.readdir(srcDir), fs.mkdir(tarDir, { recursive: true })]);

  return Promise.allSettled(
    files.map(async (file) => {
      const srcPath = path.join(srcDir, file);
      const tarPath = path.join(tarDir, file);

      if (await isDirExisted(srcPath)) {
        return copyFolder(srcPath, tarPath);
      }
      if (await isFileExisted(srcPath)) {
        return fs.copyFile(srcPath, tarPath);
      }
      return Promise.resolve();
    }),
  );
}