119e95205Sopenharmony_ci/*
219e95205Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
319e95205Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
419e95205Sopenharmony_ci * you may not use this file except in compliance with the License.
519e95205Sopenharmony_ci * You may obtain a copy of the License at
619e95205Sopenharmony_ci *
719e95205Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
819e95205Sopenharmony_ci *
919e95205Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1019e95205Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1119e95205Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1219e95205Sopenharmony_ci * See the License for the specific language governing permissions and
1319e95205Sopenharmony_ci * limitations under the License.
1419e95205Sopenharmony_ci */
1519e95205Sopenharmony_ci
1619e95205Sopenharmony_ci@rem
1719e95205Sopenharmony_ci@rem ----------------------------------------------------------------------------
1819e95205Sopenharmony_ci@rem  Hvigor startup script for Windows, version 1.0.0
1919e95205Sopenharmony_ci@rem
2019e95205Sopenharmony_ci@rem  Required ENV vars:
2119e95205Sopenharmony_ci@rem  ------------------
2219e95205Sopenharmony_ci@rem    NODE_HOME - location of a Node home dir
2319e95205Sopenharmony_ci@rem    or
2419e95205Sopenharmony_ci@rem    Add %NODE_HOME%/bin to the PATH environment variable
2519e95205Sopenharmony_ci@rem ----------------------------------------------------------------------------
2619e95205Sopenharmony_ci@rem
2719e95205Sopenharmony_ci@echo off
2819e95205Sopenharmony_ci
2919e95205Sopenharmony_ci@rem Set local scope for the variables with windows NT shell
3019e95205Sopenharmony_ciif "%OS%"=="Windows_NT" setlocal
3119e95205Sopenharmony_ci
3219e95205Sopenharmony_ciset DIRNAME=%~dp0
3319e95205Sopenharmony_ciif "%DIRNAME%" == "" set DIRNAME=.
3419e95205Sopenharmony_ciset APP_BASE_NAME=%~n0
3519e95205Sopenharmony_ciset APP_HOME=%DIRNAME%
3619e95205Sopenharmony_ci
3719e95205Sopenharmony_ciset WRAPPER_MODULE_PATH=%APP_HOME%\hvigor\hvigor-wrapper.js
3819e95205Sopenharmony_ciset NODE_EXE=node.exe
3919e95205Sopenharmony_ci@rem set NODE_OPTS="--max-old-space-size=4096"
4019e95205Sopenharmony_ci
4119e95205Sopenharmony_ci@rem Resolve any "." and ".." in APP_HOME to make it shorter.
4219e95205Sopenharmony_cifor %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
4319e95205Sopenharmony_ci
4419e95205Sopenharmony_ciif not defined NODE_OPTS set NODE_OPTS="--"
4519e95205Sopenharmony_ci
4619e95205Sopenharmony_ci@rem Find node.exe
4719e95205Sopenharmony_ciif defined NODE_HOME (
4819e95205Sopenharmony_ci  set NODE_HOME=%NODE_HOME:"=%
4919e95205Sopenharmony_ci  set NODE_EXE_PATH=%NODE_HOME%/%NODE_EXE%
5019e95205Sopenharmony_ci)
5119e95205Sopenharmony_ci
5219e95205Sopenharmony_ci%NODE_EXE% --version >NUL 2>&1
5319e95205Sopenharmony_ciif "%ERRORLEVEL%" == "0" (
5419e95205Sopenharmony_ci  "%NODE_EXE%" "%NODE_OPTS%" "%WRAPPER_MODULE_PATH%" %*
5519e95205Sopenharmony_ci) else if exist "%NODE_EXE_PATH%" (
5619e95205Sopenharmony_ci  "%NODE_EXE%" "%NODE_OPTS%" "%WRAPPER_MODULE_PATH%" %*
5719e95205Sopenharmony_ci) else (
5819e95205Sopenharmony_ci  echo.
5919e95205Sopenharmony_ci  echo ERROR: NODE_HOME is not set and no 'node' command could be found in your PATH.
6019e95205Sopenharmony_ci  echo.
6119e95205Sopenharmony_ci  echo Please set the NODE_HOME variable in your environment to match the
6219e95205Sopenharmony_ci  echo location of your NodeJs installation.
6319e95205Sopenharmony_ci)
6419e95205Sopenharmony_ci
6519e95205Sopenharmony_ciif "%ERRORLEVEL%" == "0" (
6619e95205Sopenharmony_ci  if "%OS%" == "Windows_NT" endlocal
6719e95205Sopenharmony_ci) else (
6819e95205Sopenharmony_ci  exit /b %ERRORLEVEL%
6919e95205Sopenharmony_ci)