From 57761b52534dec7d42b8e590aecbc182859be101 Mon Sep 17 00:00:00 2001 From: yeyedeshen Date: Thu, 18 Jul 2024 14:30:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=A9=BA=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yeyedeshen --- code/BasicFeature/Security/Asset/hvigorw | 125 +++++++++++------------ 1 file changed, 62 insertions(+), 63 deletions(-) diff --git a/code/BasicFeature/Security/Asset/hvigorw b/code/BasicFeature/Security/Asset/hvigorw index b99d5d5f3..2bc405528 100755 --- a/code/BasicFeature/Security/Asset/hvigorw +++ b/code/BasicFeature/Security/Asset/hvigorw @@ -1,63 +1,62 @@ -#!/bin/bash - -# ---------------------------------------------------------------------------- -# Copyright (c) 2024 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ---------------------------------------------------------------------------- - -# ---------------------------------------------------------------------------- -# Hvigor startup script, version 1.0.0 -# -# Required ENV vars: -# ------------------ -# NODE_HOME - location of a Node home dir -# or -# Add /usr/local/nodejs/bin to the PATH environment variable -# ---------------------------------------------------------------------------- - -HVIGOR_APP_HOME="`pwd -P`" -HVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js -warn() { - echo "" - echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" -} - -error() { - echo "" - echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" -} - -fail() { - error "$@" - exit 1 -} - -# Determine node to start hvigor wrapper script -if [ -n "${NODE_HOME}" ];then - EXECUTABLE_NODE="${NODE_HOME}/bin/node" - if [ ! -x "$EXECUTABLE_NODE" ];then - fail "ERROR: NODE_HOME is set to an invalid directory,check $NODE_HOME\n\nPlease set NODE_HOME in your environment to the location where your nodejs installed" - fi -else - EXECUTABLE_NODE="node" - which ${EXECUTABLE_NODE} > /dev/null 2>&1 || fail "ERROR: NODE_HOME is not set and not 'node' command found in your path" -fi - -# Check hvigor wrapper script -if [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ];then - fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}" -fi - -# start hvigor-wrapper script -exec "${EXECUTABLE_NODE}" \ - "${HVIGOR_WRAPPER_SCRIPT}" "$@" +#!/bin/bash +# ---------------------------------------------------------------------------- +# Copyright (c) 2024 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Hvigor startup script, version 1.0.0 +# +# Required ENV vars: +# ------------------ +# NODE_HOME - location of a Node home dir +# or +# Add /usr/local/nodejs/bin to the PATH environment variable +# ---------------------------------------------------------------------------- + +HVIGOR_APP_HOME="`pwd -P`" +HVIGOR_WRAPPER_SCRIPT=${HVIGOR_APP_HOME}/hvigor/hvigor-wrapper.js +warn() { + echo "" + echo -e "\033[1;33m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" +} + +error() { + echo "" + echo -e "\033[1;31m`date '+[%Y-%m-%d %H:%M:%S]'`$@\033[0m" +} + +fail() { + error "$@" + exit 1 +} + +# Determine node to start hvigor wrapper script +if [ -n "${NODE_HOME}" ];then + EXECUTABLE_NODE="${NODE_HOME}/bin/node" + if [ ! -x "$EXECUTABLE_NODE" ];then + fail "ERROR: NODE_HOME is set to an invalid directory,check $NODE_HOME\n\nPlease set NODE_HOME in your environment to the location where your nodejs installed" + fi +else + EXECUTABLE_NODE="node" + which ${EXECUTABLE_NODE} > /dev/null 2>&1 || fail "ERROR: NODE_HOME is not set and not 'node' command found in your path" +fi + +# Check hvigor wrapper script +if [ ! -r "$HVIGOR_WRAPPER_SCRIPT" ];then + fail "ERROR: Couldn't find hvigor/hvigor-wrapper.js in ${HVIGOR_APP_HOME}" +fi + +# start hvigor-wrapper script +exec "${EXECUTABLE_NODE}" \ + "${HVIGOR_WRAPPER_SCRIPT}" "$@"