mirror of
https://github.com/th3r00t/pyShelf.git
synced 2026-04-28 01:59:35 -04:00
Handle javascript dependencies.
This commit is contained in:
23
src/frontend/lib/objects.py
vendored
Normal file
23
src/frontend/lib/objects.py
vendored
Normal 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)
|
||||
Reference in New Issue
Block a user