mirror of
https://github.com/Noratrieb/vps.git
synced 2026-01-14 08:45:02 +01:00
23 lines
571 B
JavaScript
23 lines
571 B
JavaScript
import fs from "node:fs/promises";
|
|
|
|
const path = `${import.meta.dirname}/nixpkgs.json`;
|
|
const nixpkgs = JSON.parse(await fs.readFile(path));
|
|
|
|
const res = await fetch(
|
|
`https://api.github.com/repos/NixOS/nixpkgs/commits/${nixpkgs.channel}`
|
|
);
|
|
|
|
if (!res.ok) {
|
|
throw new Error(
|
|
`get commit for ${name}: ${res.status} - ${await res.text()}`
|
|
);
|
|
}
|
|
|
|
const body = await res.json();
|
|
|
|
if (body.sha !== nixpkgs.commit) {
|
|
nixpkgs.commit = body.sha;
|
|
nixpkgs.lastUpdated = new Date().toISOString();
|
|
|
|
await fs.writeFile(path, JSON.stringify(nixpkgs, null, 2) + "\n");
|
|
}
|