From edfe20b2e1b95e21519e0f0962b4d920577b27ec Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Mon, 17 Jun 2024 14:28:56 -0700 Subject: [PATCH] fix --- scripts/prepare-pyodide.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/prepare-pyodide.js b/scripts/prepare-pyodide.js index e01ab4650..e746c09ed 100644 --- a/scripts/prepare-pyodide.js +++ b/scripts/prepare-pyodide.js @@ -24,12 +24,16 @@ async function downloadPackages() { const packageJson = JSON.parse(await readFile('package.json')); const pyodideVersion = packageJson.dependencies.pyodide; - const pyodidePackageJson = JSON.parse(await readFile('static/pyodide/package.json')); - const pyodidePackageVersion = pyodidePackageJson.version; + try { + const pyodidePackageJson = JSON.parse(await readFile('static/pyodide/package.json')); + const pyodidePackageVersion = pyodidePackageJson.version; - if (pyodideVersion.replace('^', '') !== pyodidePackageVersion) { - console.log('Pyodide version mismatch, removing static/pyodide directory'); - await rmdir('static/pyodide', { recursive: true }); + if (pyodideVersion.replace('^', '') !== pyodidePackageVersion) { + console.log('Pyodide version mismatch, removing static/pyodide directory'); + await rmdir('static/pyodide', { recursive: true }); + } + } catch (e) { + console.log('Pyodide package not found, downloading packages'); } await pyodide.loadPackage('micropip');