Skip to content

Commit

Permalink
#667: devon npm setup ignores a given version (#668)
Browse files Browse the repository at this point in the history
* Bugfix or issue #667 - devon npm setup ignores a given version

* constructive review changes

* Adaptation to new download process

Co-authored-by: fdcg <fdcg@users.noreply.github.com>
Co-authored-by: Jörg Hohwiller <hohwille@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 25, 2022
1 parent 0fe3c1b commit 07d9407
Showing 1 changed file with 42 additions and 7 deletions.
49 changes: 42 additions & 7 deletions scripts/src/main/resources/scripts/command/npm
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,46 @@ source "$(dirname "${0}")"/../functions

# $1: optional setup
function doSetup() {
if [ ! -x "${NPM_CMD}" ]
local software_version=${NPM_VERSION}
local installed_version
if [ -x "${NPM_CMD}" ]
then
installed_version=$(${NPM_CMD} -version)
else
doDevonCommand node setup silent
elif [ "${1}" != "silent" ]
then
doEcho "npm is already installed at ${NPM_CMD}"
installed_version=$(${NPM_CMD} -version)
fi
if [ -n "${NPM_VERSION}" ]

if [ -z "${software_version}" ] || [ "${installed_version}" == "${software_version}" ]
then
doDevonCommand npm install -g "npm@${NPM_VERSION}"
fi
if [ "${1}" != "silent" ]
then
doEcho "Version ${installed_version} of npm is already installed at ${NPM_CMD}"
fi
else
local software_dir="${NODE_HOME}/node_modules/npm"
doInstall "-" "${software_dir}" "npm" "${software_version}"
if [ -f "${NODE_HOME}/npm" ]
then
rm "${NODE_HOME}/npm"
fi
if [ -f "${NODE_HOME}/npm.cmd" ]
then
rm "${NODE_HOME}/npm.cmd"
fi
if [ -f "${NODE_HOME}/npx" ]
then
rm "${NODE_HOME}/npx"
fi
if [ -f "${NODE_HOME}/npx.cmd" ]
then
rm "${NODE_HOME}/npx.cmd"
fi
cp "${software_dir}/bin/npm" "${NODE_HOME}"
cp "${software_dir}/bin/npm.cmd" "${NODE_HOME}"
cp "${software_dir}/bin/npx" "${NODE_HOME}"
cp "${software_dir}/bin/npx.cmd" "${NODE_HOME}"
fi
}

function doGetProjectVersion() {
Expand Down Expand Up @@ -96,6 +125,12 @@ then
echo "Options:"
exit
fi

if [ -z "${NODE_HOME}" ]
then
NODE_HOME="${DEVON_IDE_HOME}/software/node"
fi

NPM_CMD="${DEVON_IDE_HOME}/software/node/npm"
if [ ! -x "${NPM_CMD}" ]
then
Expand Down

0 comments on commit 07d9407

Please sign in to comment.