Handle javascript dependencies.

This commit is contained in:
th3r00t
2023-03-11 01:00:04 -05:00
parent ebbd115653
commit 64d606f0a4

23
src/frontend/lib/objects.py vendored Normal file
View File

@@ -0,0 +1,23 @@
"""pyShelf's Frontend Objects."""
from sys import exit
from shutil import which
from subprocess import run
from pathlib import Path
from ...backend.lib.config import Config
class JSInterface():
"""A class to interface with the JavaScript side of pyShelf."""
def __init__(self, config: Config):
"""Initialize the JSInterface object."""
self.package_json: Path = Path(config.root, "src/frontend/package.json")
self.config: Config = config
def install(self):
"""Install the JavaScript dependencies."""
if which("npm"):
run(["npm", "install"], cwd=self.package_json.parent)
else:
self.config.logger.error("npm is not installed.")
exit(1)