Skip to content

Instantly share code, notes, and snippets.

@JamieMason
Created October 30, 2024 13:04
Show Gist options
  • Save JamieMason/d640f8377513807941fafaaa208372b4 to your computer and use it in GitHub Desktop.
Save JamieMason/d640f8377513807941fafaaa208372b4 to your computer and use it in GitHub Desktop.
Create Syncpack Issue Reproduction

Create Syncpack Issue Reproduction

Delete all files in the current directory except for this script, lerna.json, package.json, pnpm-workspace.yaml, and syncpack.config.cjs. Also delete all empty directories except for the .git directory.

Put this script at create-syncpack-issue-reproduction.js in the root of the repo.

const child_process = require("child_process");
const fs = require("fs");

child_process.exec("find . -type f", (err, stdout) => {
  if (err) {
    console.error(err);
    return;
  }
  stdout
    .trim()
    .split("\n")
    .forEach((file) => {
      if (
        file.endsWith("./create-syncpack-issue-reproduction.js") ||
        file.endsWith("/lerna.json") ||
        file.endsWith("/package.json") ||
        file.endsWith("/pnpm-workspace.yaml") ||
        file.endsWith("/syncpack.config.cjs") ||
        file.includes("/.git/")
      ) {
        return;
      }
      console.log(file);
      fs.unlinkSync(file);
    });
});

// delete empty folders, but not in the .git dir
child_process.exec("find . -type d -empty -delete", (err) => {
  if (err) {
    console.error(err);
  }
  console.log("deleted empty directories");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment