|
5 | 5 | # - Debug -> Extension
|
6 | 6 | set -e
|
7 | 7 |
|
8 |
| -# Set the correct Node version at the start of the script |
9 |
| -setup_node_version() { |
10 |
| - # Get required node version from .node-version or .nvmrc |
11 |
| - if [ -f .node-version ]; then |
12 |
| - required_node_version=$(cat .node-version) |
13 |
| - elif [ -f .nvmrc ]; then |
| 8 | +# Check if node version matches .nvmrc |
| 9 | +if [ -f .nvmrc ]; then |
14 | 10 | required_node_version=$(cat .nvmrc)
|
15 |
| - else |
16 |
| - echo "No .node-version or .nvmrc file found. Skipping Node.js version check." |
17 |
| - return |
18 |
| - fi |
| 11 | + current_node_version=$(node -v) |
| 12 | + |
| 13 | + # Remove 'v' prefix from versions for comparison |
| 14 | + required_version=${required_node_version#v} |
| 15 | + current_version=${current_node_version#v} |
19 | 16 |
|
20 |
| - # Remove 'v' prefix if present |
21 |
| - required_version=${required_node_version#v} |
22 |
| - |
23 |
| - # Try fnm first |
24 |
| - if command -v fnm &> /dev/null; then |
25 |
| - echo "📦 Using fnm to set Node.js version to $required_version..." |
26 |
| - # Capture output to avoid duplicate messages |
27 |
| - eval "$(fnm env --use-on-cd)" &> /dev/null |
28 |
| - fnm use "$required_version" &> /dev/null || fnm use &> /dev/null |
29 |
| - # Then try nvm |
30 |
| - elif command -v nvm &> /dev/null || [ -s "$NVM_DIR/nvm.sh" ]; then |
31 |
| - echo "📦 Using nvm to set Node.js version to $required_version..." |
32 |
| - export NVM_DIR="$HOME/.nvm" |
33 |
| - [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # Load nvm |
34 |
| - nvm use "$required_version" &> /dev/null || nvm use &> /dev/null |
35 |
| - # Fall back to version check only |
36 |
| - else |
37 |
| - echo "Neither fnm nor nvm found. Proceeding with current Node.js version." |
38 |
| - fi |
39 |
| - |
40 |
| - # Verify the current Node.js version after our attempt to set it |
41 |
| - current_node_version=$(node -v) |
42 |
| - current_version=${current_node_version#v} |
43 |
| - |
44 |
| - if [ "$required_version" != "$current_version" ]; then |
45 |
| - echo "⚠️ Warning: Your Node.js version ($current_node_version) does not match the required version (v$required_version)" |
46 |
| - echo "Even after attempting to use version managers, the correct version couldn't be activated." |
47 |
| - if [ -t 0 ]; then |
48 |
| - read -p "Press Enter to continue with installation anyway..." |
49 |
| - else |
50 |
| - echo "Continuing with installation anyway..." |
| 17 | + if [ "$required_version" != "$current_version" ]; then |
| 18 | + echo "⚠️ Warning: Your Node.js version ($current_node_version) does not match the required version ($required_node_version)" |
| 19 | + echo "Please consider switching to the correct version using: nvm use" |
| 20 | + |
| 21 | + if [ -t 0 ]; then |
| 22 | + read -p "Press Enter to continue with installation anyway..." |
| 23 | + else |
| 24 | + echo "Continuing with installation anyway..." |
| 25 | + fi |
| 26 | + echo |
51 | 27 | fi
|
52 |
| - echo |
53 |
| - else |
54 |
| - echo "✅ Using Node.js $current_node_version as required." |
55 |
| - fi |
56 |
| -} |
57 |
| - |
58 |
| -# Run the node version setup |
59 |
| -setup_node_version |
| 28 | +fi |
60 | 29 |
|
61 | 30 | echo "Installing root-level dependencies..."
|
62 | 31 | npm install
|
|
0 commit comments