diff --git a/src/frontend/lib/objects.py b/src/frontend/lib/objects.py new file mode 100644 index 0000000..c6e26b5 --- /dev/null +++ b/src/frontend/lib/objects.py @@ -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)