Skip to content

Commit 1781940

Browse files
committed
Fix build
1 parent bddb866 commit 1781940

13 files changed

+57362
-9
lines changed

bin/index.js

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
import fs from 'fs';
22
import fetch from 'node-fetch';
3-
import * as cheerio from 'cheerio';
43
import decompress from 'decompress';
54

65
async function getSqliteWasmDownloadLink() {
76
const response = await fetch('https://sqlite.org/download.html');
87
const html = await response.text();
9-
const $ = cheerio.load(html);
10-
const fileName = $('a[name="wasm"]').closest('tr').next().find('a').text();
11-
const sqliteWasmLink = `https://sqlite.org/${new Date().getFullYear()}/${fileName}`;
8+
const sqliteWasmLink =
9+
'https://sqlite.org/' +
10+
html
11+
.replace(
12+
/^.*?<!-- Download product data for scripts to read(.*?)-->.*?$/gms,
13+
'$1',
14+
)
15+
.split(/\n/)
16+
.filter((row) => /sqlite-wasm/.test(row))[0]
17+
.split(/,/)[2];
1218
console.log(`Found SQLite Wasm download link: ${sqliteWasmLink}`);
1319
return sqliteWasmLink;
1420
}
@@ -19,6 +25,11 @@ async function downloadAndUnzipSqliteWasm(sqliteWasmDownloadLink) {
1925
}
2026
console.log('Downloading and unzipping SQLite Wasm...');
2127
const response = await fetch(sqliteWasmDownloadLink);
28+
if (!response.ok || response.status !== 200) {
29+
throw new Error(
30+
`Unable to download SQLite Wasm from ${sqliteWasmDownloadLink}`,
31+
);
32+
}
2233
const buffer = await response.arrayBuffer();
2334
fs.writeFileSync('sqlite-wasm.zip', Buffer.from(buffer));
2435
const files = await decompress('sqlite-wasm.zip', 'sqlite-wasm', {
@@ -35,9 +46,9 @@ async function downloadAndUnzipSqliteWasm(sqliteWasmDownloadLink) {
3546
}
3647

3748
async function main() {
38-
const sqliteWasmLink = await getSqliteWasmDownloadLink();
39-
await downloadAndUnzipSqliteWasm(sqliteWasmLink);
4049
try {
50+
const sqliteWasmLink = await getSqliteWasmDownloadLink();
51+
await downloadAndUnzipSqliteWasm(sqliteWasmLink);
4152
fs.copyFileSync(
4253
'./node_modules/module-workers-polyfill/module-workers-polyfill.min.js',
4354
'./demo/module-workers-polyfill.min.js',

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sqlite.org/sqlite-wasm",
3-
"version": "3.44.2-build2",
3+
"version": "3.44.2-build3",
44
"description": "SQLite Wasm conveniently wrapped as an ES Module.",
55
"keywords": [
66
"sqlite",

0 commit comments

Comments
 (0)