Skip to content

Commit

Permalink
Do npm install as part of configuration step, use npm.cmd on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
willend committed Jul 5, 2024
1 parent 9e2a2d6 commit d8d9c7d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
11 changes: 9 additions & 2 deletions tools/Python/mcdisplay/webgl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ set(CPACK_NSIS_DISPLAY_NAME "${NSIS_NAME}")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${NSIS_NAME}")

# Debian
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${FLAVOR}-${MCCODE_VERSION}, python3, python3-ply, python3-numpy")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${FLAVOR}-${MCCODE_VERSION}, python3, python3-ply, python3-numpy nodejs")

# RPM
if (RPMPROFILE)
Expand All @@ -75,6 +75,13 @@ set(WORK "${PROJECT_BINARY_DIR}/work")
# Configure fallback script
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/mcdisplay.in" "${WORK}/${P}display" @ONLY)

# Put package.json in $WORK
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/package.json" "${WORK}/package.json" @ONLY)

# Run npm to install project
execute_process(COMMAND "npm" "install"
WORKING_DIRECTORY "${WORK}")

# Dist
install(
DIRECTORY "${PROJECT_SOURCE_DIR}/dist"
Expand All @@ -84,7 +91,7 @@ install(

# Node modules
install(
DIRECTORY "${PROJECT_SOURCE_DIR}/node_modules"
DIRECTORY "${WORK}/node_modules"
DESTINATION "${DEST_TOOLDIR}/${TOOLS_NAME}"
)

Expand Down
7 changes: 6 additions & 1 deletion tools/Python/mcdisplay/webgl/mcdisplay.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,13 @@ def copy(a, b):

# Function to run npm commands and capture port
def run_npm_and_capture_port(port_container):
if not os.name == 'nt':
npmexe = "npm"
else:
npmexe = "npm.cmd"

try:
proc = subprocess.Popen(["npm","run","dev"], cwd=str(destdist), stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
proc = subprocess.Popen([npmexe,"run","dev"], cwd=str(destdist), stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
for line in proc.stdout:
print(line)
if 'Local:' in line:
Expand Down

0 comments on commit d8d9c7d

Please sign in to comment.