-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetNodeInfo.sh
executable file
·66 lines (56 loc) · 1.62 KB
/
getNodeInfo.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
echo "Checking for Npm"
NPM_CMD=$(which npm)
if [[ "" == "$NPM_CMD" ]]
then
echo "No npm found"
else
echo "Running Npm Commands"
NPM_OUTDATED=$(npm outdated --json)
if [ -f npm_package_versions.json ]
then
rm npm_package_versions.json
fi
touch npm_package_versions.json
echo $NPM_OUTDATED > npm_package_versions.json
echo "Composer Outdated File Creation Completed"
fi
# Remove the 'npm_package_versions.json' file from the 'app_versions' folder if it exists
if [ -f "app_versions/npm_package_versions.json" ]; then
rm app_versions/npm_package_versions.json
fi
# Move the 'npm_package_versions.json' file to the 'app_versions' folder if it exists
if [ -f "npm_package_versions.json" ]; then
mv npm_package_versions.json app_versions
fi
if [ "" == "$NPM_CMD" ]
then
echo "Versions Generation Not Possible"
else
NODE_VERSION=$(node -v)
NPM_VERSION=$(npm -v)
cd app_versions
if [ -f current_versions.json ]
then
rm current_versions.json
fi
touch current_versions.json
printf "{\n \"node\": \"%s\",\n \"npm\": \"%s\"}" $NODE_VERSION $NPM_VERSION > current_versions.json
echo "Versions File Creation Completed"
fi
# Get latest version of node and npm
if [ "" == "$NPM_CMD" ]
then
echo "Versions Generation Not Possible"
else
NODE_LATEST=$(npm info node version)
NPM_LATEST=$(npm info npm version)
arr=($COMPOSER_VERSION)
if [ -f latest_versions.json ]
then
rm latest_versions.json
fi
touch latest_versions.json
printf "{\n \"node\": \"%s\",\n \"npm\": \"%s\"\n}" $NODE_LATEST $NPM_LATEST > latest_versions.json
echo "Latest Versions File Creation Completed"
fi