|
1 | | -import * as prettier from "prettier"; |
2 | | -import fs from "fs/promises"; |
3 | | -import spawn from "nano-spawn"; |
4 | | -import repositories from "../repositories.json" with { type: "json" }; |
5 | | - |
6 | | -export const REPOSITORIES_JSON_FILE = new URL( |
7 | | - "../repositories.json", |
8 | | - import.meta.url, |
9 | | -); |
10 | | - |
11 | | -export async function getRepositoryCommitHash(repository) { |
12 | | - const { stdout } = await spawn("git", [ |
13 | | - "ls-remote", |
14 | | - "--exit-code", |
15 | | - `https://github.com/${repository}`, |
16 | | - "HEAD", |
17 | | - ]); |
18 | | - |
19 | | - const [commit] = stdout.trim().split(/\s/); |
20 | | - return commit; |
21 | | -} |
22 | | - |
23 | | -export async function updatedRepositories(processFunction) { |
24 | | - const updated = await processFunction(repositories); |
25 | | - |
26 | | - await fs.writeFile( |
27 | | - REPOSITORIES_JSON_FILE, |
28 | | - await prettier.format(JSON.stringify(updated), { parser: "json" }), |
29 | | - ); |
30 | | -} |
| 1 | +import * as prettier from "prettier"; |
| 2 | +import fs from "fs/promises"; |
| 3 | +import spawn from "nano-spawn"; |
| 4 | +import repositories from "../repositories.json" with { type: "json" }; |
| 5 | + |
| 6 | +export const REPOSITORIES_JSON_FILE = new URL( |
| 7 | + "../repositories.json", |
| 8 | + import.meta.url, |
| 9 | +); |
| 10 | + |
| 11 | +export async function getRepositoryCommitHash(repository) { |
| 12 | + const { stdout } = await spawn("git", [ |
| 13 | + "ls-remote", |
| 14 | + "--exit-code", |
| 15 | + `https://github.com/${repository}`, |
| 16 | + "HEAD", |
| 17 | + ]); |
| 18 | + |
| 19 | + const [commit] = stdout.trim().split(/\s/); |
| 20 | + return commit; |
| 21 | +} |
| 22 | + |
| 23 | +export async function updatedRepositories(processFunction) { |
| 24 | + const updated = await processFunction(repositories); |
| 25 | + |
| 26 | + await fs.writeFile( |
| 27 | + REPOSITORIES_JSON_FILE, |
| 28 | + await prettier.format(JSON.stringify(updated), { parser: "json" }), |
| 29 | + ); |
| 30 | +} |
0 commit comments