aboutsummaryrefslogtreecommitdiff
path: root/.scripts/make-dev-timer.ts
blob: 4b5f8d53598f9d2adb8112b4e0ad1af7e4caeced (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// I would have made this a bash script but there isn't an easy way to track
// time in bash sub-second cross platform.
import fs from "fs";
const start = Date.now() + 5;
const result = Bun.spawnSync(process.argv.slice(2), {
  stdio: ["inherit", "inherit", "inherit"],
});
const end = Date.now();
const diff = (Math.max(Math.round(end - start), 0) / 1000).toFixed(3);
const success = result.exitCode === 0;
try {
  const line = `${new Date().toISOString()}, ${success ? "success" : "fail"}, ${diff}\n`;
  if (fs.existsSync(".scripts/make-dev-stats.csv")) {
    fs.appendFileSync(".scripts/make-dev-stats.csv", line);
  } else {
    fs.writeFileSync(".scripts/make-dev-stats.csv", line);
  }
} catch {
  // Ignore
}
process.exit(result.exitCode);