{"size": 654, "ext": "js", "max_stars_repo_path": "script/prepublishOnly.dev.js", "max_stars_repo_name": "distubejs/yt-dlp", "max_stars_repo_stars_event_min_datetime": "2022-01-29T01:21:04.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-04T02:50:13.000Z", "max_issues_repo_path": "script/prepublishOnly.dev.js", "max_issues_repo_name": "distubejs/yt-dlp", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "script/prepublishOnly.dev.js", "max_forks_repo_name": "distubejs/yt-dlp", "max_forks_repo_forks_event_min_datetime": "2022-02-14T02:47:25.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-14T02:47:25.000Z"}
{"max_stars_count": 3, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 32.7, "max_line_length": 95, "alphanum_fraction": 0.6651376147}
const fs = require("fs");
const path = require("path");
const fromEntries = require("fromentries");

function fn(name) {
  if (name === "postinstall:prod") return "postinstall";
  else if (name === "postinstall") return "postinstall:dev";
  return name;
}

const file = path.join(process.cwd(), "package.json");
let data = fs.readFileSync(file, "utf-8");
const pkg = JSON.parse(data);
pkg.scripts = fromEntries(Object.entries(pkg.scripts).map(([key, value]) => [fn(key), value]));
const regex = /^[ ]+|\t+/m;
const res = regex.exec(data);
const indent = res ? res[0] : null;
data = JSON.stringify(pkg, null, indent);
fs.writeFileSync(file, `${data}\n`);
