Browse Source

[mod] introduce node.env.devtools function

Markus Heiser 3 years ago
parent
commit
309147d86f
2 changed files with 12 additions and 3 deletions
  1. 9 3
      manage
  2. 3 0
      utils/lib_nvm.sh

+ 9 - 3
manage

@@ -20,6 +20,8 @@ source "$(dirname "${BASH_SOURCE[0]}")/utils/lib_go.sh"
 # shellcheck source=utils/lib_redis.sh
 # shellcheck source=utils/lib_redis.sh
 source "$(dirname "${BASH_SOURCE[0]}")/utils/lib_redis.sh"
 source "$(dirname "${BASH_SOURCE[0]}")/utils/lib_redis.sh"
 
 
+PATH="${REPO_ROOT}/node_modules/.bin:${PATH}"
+
 # config
 # config
 
 
 PYOBJECTS="searx"
 PYOBJECTS="searx"
@@ -559,6 +561,12 @@ node.env() {
     dump_return $?
     dump_return $?
 }
 }
 
 
+node.env.devtools() {
+    nodejs.ensure
+    build_msg INSTALL "package.json: developer and CI tools"
+    npm install
+}
+
 node.clean() {
 node.clean() {
     if ! required_commands npm 2>/dev/null; then
     if ! required_commands npm 2>/dev/null; then
         build_msg CLEAN "npm is not installed / ignore npm dependencies"
         build_msg CLEAN "npm is not installed / ignore npm dependencies"
@@ -683,11 +691,9 @@ test.pylint() {
     dump_return $?
     dump_return $?
 }
 }
 
 
-
 test.pyright() {
 test.pyright() {
     build_msg TEST "[pyright] static type check of python sources"
     build_msg TEST "[pyright] static type check of python sources"
-    nodejs.ensure
-    npm install
+    node.env.devtools
     # We run Pyright in the virtual environment because Pyright
     # We run Pyright in the virtual environment because Pyright
     # executes "python" to determine the Python version.
     # executes "python" to determine the Python version.
     pyenv.cmd npx --no-install pyright -p pyrightconfig-ci.json
     pyenv.cmd npx --no-install pyright -p pyrightconfig-ci.json

+ 3 - 0
utils/lib_nvm.sh

@@ -117,6 +117,9 @@ nvm.install() {
     info_msg "checkout ${NVM_VERSION_TAG}"
     info_msg "checkout ${NVM_VERSION_TAG}"
     git checkout "${NVM_VERSION_TAG}" 2>&1 | prefix_stdout "  ${_Yellow}||${_creset} "
     git checkout "${NVM_VERSION_TAG}" 2>&1 | prefix_stdout "  ${_Yellow}||${_creset} "
     popd &> /dev/null
     popd &> /dev/null
+    if [ -f "${REPO_ROOT}/.nvm_packages" ]; then
+        cp "${REPO_ROOT}/.nvm_packages" "${NVM_DIR}/default-packages"
+    fi
     nvm.env
     nvm.env
 }
 }