Skip to content

Commit f6d3454

Browse files
authored
fix: Only run npm when building from source (#758)
1 parent e407056 commit f6d3454

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

scripts/npm.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import subprocess
2+
from pathlib import Path
23

34
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
45

56

67
class NpmBuildHook(BuildHookInterface):
78
def initialize(self, version, build_data):
8-
subprocess.check_output("npm ci", shell=True)
9-
subprocess.check_output("npm run build", shell=True)
9+
is_source = Path(self.root, ".git").exists()
10+
app_js_exists = Path(
11+
self.root, "src", "pytest_html", "resources", "app.js"
12+
).exists()
13+
if is_source or not app_js_exists:
14+
subprocess.run("npm ci", capture_output=True, check=True, shell=True)
15+
subprocess.run("npm run build", capture_output=True, check=True, shell=True)

0 commit comments

Comments
 (0)