private syncRepo()

in src/targets/go.ts [303:321]


  private syncRepo(repoDir: string) {
    const topLevel = path.join(repoDir, 'go.mod');
    if (fs.existsSync(topLevel)) {
      // with top level modules we sync the entire repository
      // so we just empty it out
      fs.readdirSync(repoDir)
        .filter(f => f !== '.git')
        .forEach(f => fs.removeSync(path.join(repoDir, f)));
    } else {
      // otherwise, we selectively remove the submodules only.
      for (const p of fs.readdirSync(repoDir)) {
        const submodule = path.join(repoDir, p, 'go.mod');
        if (fs.existsSync(submodule)) {
          fs.removeSync(path.join(repoDir, p));
        }
      }
    }
    fs.copySync(this.dir, repoDir, { recursive: true });
  }