Skip to content

Commit e5280b8

Browse files
chore: remove cross-fetch, use built-in node fetch
1 parent fc4836c commit e5280b8

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

bin/sync.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,21 @@
33
import { writeFileSync } from 'fs';
44
import { join } from 'path';
55

6-
import fetch from 'cross-fetch';
76
import * as z from 'zod';
87

98
const sourceUrl = (branch = 'master') =>
109
`https://github.com/postgres/postgres/raw/${branch}/src/backend/utils/errcodes.txt`;
1110

12-
const getSourceText = (): Promise<string[]> =>
13-
fetch(sourceUrl())
14-
.then((response) => response.text())
15-
.then((text) => text.split('\n'));
11+
const getSourceText = async (): Promise<string[]> => {
12+
const response = await fetch(sourceUrl());
13+
14+
if (!response.ok) {
15+
throw new Error(`Error fetching errcodes.txt: ${response.status}`);
16+
}
17+
18+
const text = await response.text();
19+
return text.split('\n');
20+
};
1621

1722
const stripCommentsAndEmptyLines = (lines: string[]) =>
1823
lines.filter((line) => line !== '' && line.charAt(0) !== '#');

0 commit comments

Comments
 (0)