fix: Only run npm when building from source (#758)
This commit is contained in:
parent
e4070567db
commit
f6d34545f9
|
@ -1,9 +1,15 @@
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
|
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
|
||||||
|
|
||||||
|
|
||||||
class NpmBuildHook(BuildHookInterface):
|
class NpmBuildHook(BuildHookInterface):
|
||||||
def initialize(self, version, build_data):
|
def initialize(self, version, build_data):
|
||||||
subprocess.check_output("npm ci", shell=True)
|
is_source = Path(self.root, ".git").exists()
|
||||||
subprocess.check_output("npm run build", shell=True)
|
app_js_exists = Path(
|
||||||
|
self.root, "src", "pytest_html", "resources", "app.js"
|
||||||
|
).exists()
|
||||||
|
if is_source or not app_js_exists:
|
||||||
|
subprocess.run("npm ci", capture_output=True, check=True, shell=True)
|
||||||
|
subprocess.run("npm run build", capture_output=True, check=True, shell=True)
|
||||||
|
|
Loading…
Reference in New Issue