Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
npx66 linesDownload Raw Back to node24
1#!/usr/bin/env bash2 3# This is used by the Node.js installer, which expects the cygwin/mingw4# shell script to already be present in the npm dependency folder.5 6(set -o igncr) 2>/dev/null && set -o igncr; # cygwin encoding fix7 8basedir=`dirname "$0"`9 10case `uname` in11  *CYGWIN*) basedir=`cygpath -w "$basedir"`;;12esac13 14if [ `uname` = 'Linux' ] && type wslpath &>/dev/null ; then15  IS_WSL="true"16fi17 18function no_node_dir {19  # if this didn't work, then everything else below will fail20  echo "Could not determine Node.js install directory" >&221  exit 122}23 24NODE_EXE="$basedir/node.exe"25if ! [ -x "$NODE_EXE" ]; then26  NODE_EXE="$basedir/node"27fi28if ! [ -x "$NODE_EXE" ]; then29  NODE_EXE=node30fi31 32# this path is passed to node.exe, so it needs to match whatever33# kind of paths Node.js thinks it's using, typically win32 paths.34CLI_BASEDIR="$("$NODE_EXE" -p 'require("path").dirname(process.execPath)' 2> /dev/null)"35if [ $? -ne 0 ]; then36  # this fails under WSL 1 so add an additional message. we also suppress stderr above37  # because the actual error raised is not helpful. in WSL 1 node.exe cannot handle38  # output redirection properly. See https://github.com/microsoft/WSL/issues/237039  if [ "$IS_WSL" == "true" ]; then40    echo "WSL 1 is not supported. Please upgrade to WSL 2 or above." >&241  fi42  no_node_dir43fi44NPM_PREFIX_JS="$CLI_BASEDIR/node_modules/npm/bin/npm-prefix.js"45NPX_CLI_JS="$CLI_BASEDIR/node_modules/npm/bin/npx-cli.js"46NPM_PREFIX=`"$NODE_EXE" "$NPM_PREFIX_JS"`47if [ $? -ne 0 ]; then48  no_node_dir49fi50NPM_PREFIX_NPX_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npx-cli.js"51 52# a path that will fail -f test on any posix bash53NPX_WSL_PATH="/.."54 55# WSL can run Windows binaries, so we have to give it the win32 path56# however, WSL bash tests against posix paths, so we need to construct that57# to know if npm is installed globally.58if [ "$IS_WSL" == "true" ]; then59  NPX_WSL_PATH=`wslpath "$NPM_PREFIX_NPX_CLI_JS"`60fi61if [ -f "$NPM_PREFIX_NPX_CLI_JS" ] || [ -f "$NPX_WSL_PATH" ]; then62  NPX_CLI_JS="$NPM_PREFIX_NPX_CLI_JS"63fi64 65"$NODE_EXE" "$NPX_CLI_JS" "$@"66 
codekingpro/portable-devtools · Team Ai