fix: better paths

This commit is contained in:
Vlad Stan
2026-02-13 16:59:01 +02:00
parent 7d9d975312
commit 68229be4b4
+8 -5
View File
@@ -66,23 +66,26 @@ class LightsparkSparkWallet(Wallet):
return return
logger.info(f"npm found: {npm_path}") logger.info(f"npm found: {npm_path}")
repo, branch = "spark_sidecar", "main"
node_modules_path = Path(self._sidecar_path, f"{repo}-{branch}")
if not Path(self._sidecar_path, "package.json").is_file(): if not Path(self._sidecar_path, "package.json").is_file():
logger.info("⏳ Downloading Spark sidecar.") logger.info("⏳ Downloading Spark sidecar.")
await asyncio.to_thread( await asyncio.to_thread(
download_url, download_url,
"https://github.com/lnbits/spark_sidecar/archive/refs/heads/main.zip", f"https://github.com/lnbits/{repo}/archive/refs/heads/{branch}.zip",
Path(self._sidecar_path, "spark_sidecar.zip"), Path(self._sidecar_path, f"{repo}.zip"),
) )
logger.info("✅ Downloaded Spark sidecar.") logger.info("✅ Downloaded Spark sidecar.")
logger.info("⏳ Extracting Spark sidecar.") logger.info("⏳ Extracting Spark sidecar.")
shutil.unpack_archive( shutil.unpack_archive(
Path(self._sidecar_path, "spark_sidecar.zip"), Path(self._sidecar_path, f"{repo}.zip"),
self._sidecar_path, self._sidecar_path,
) )
logger.info("✅ Extracted Spark sidecar.") logger.info("✅ Extracted Spark sidecar.")
# todo: remove zip # todo: remove zip
node_modules_path = Path(self._sidecar_path, "spark_sidecar-main")
if not Path(self._sidecar_path, node_modules_path, "node_modules").is_dir(): if not Path(self._sidecar_path, node_modules_path, "node_modules").is_dir():
result = subprocess.run( result = subprocess.run(
["npm", "install"], ["npm", "install"],
@@ -101,7 +104,7 @@ class LightsparkSparkWallet(Wallet):
cwd=str(node_modules_path), cwd=str(node_modules_path),
capture_output=True, capture_output=True,
text=True, text=True,
check=True, # raises an exception if node fails # check=True, # raises an exception if node fails
) )
print("### Spark sidecar output:") print("### Spark sidecar output:")