Skip to content

Commit

Permalink
fix: fix some critical error
Browse files Browse the repository at this point in the history
  • Loading branch information
leoli0605 committed May 9, 2024
1 parent 2ac77e5 commit 71e0a5b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
11 changes: 1 addition & 10 deletions packageData.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
"Node.js": {
"description": "",
"install": {
"linux": "asdf plugin add nodejs && asdf install nodejs 16.20.2 && asdf global nodejs 16.20.2",
"linux": "asdf plugin add nodejs && asdf install nodejs 18.18.0 && asdf global nodejs 18.18.0",
"mac": "asdf plugin add nodejs && asdf install nodejs 18.18.0 && asdf global nodejs 18.18.0",
"windows": "choco install nodejs --version=18.18.0 -y ; choco pin add -n=nodejs"
},
Expand Down Expand Up @@ -506,15 +506,6 @@
},
"type": "enable"
},
"ImageMagick": {
"description": "圖像處理工具",
"install": {
"linux": "asdf plugin add imagemagick && asdf install imagemagick latest && asdf global imagemagick latest",
"mac": "asdf plugin add imagemagick && asdf install imagemagick latest && asdf global imagemagick latest",
"windows": "choco install imagemagick -y"
},
"type": "enable"
},
"Inkscape": {
"description": "免費向量繪圖軟體,類似 Adobe Illustrator",
"install": {
Expand Down
19 changes: 9 additions & 10 deletions src/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,6 @@ class SetupManager {
this.setupNonWindowsEnvironment();
}

selectedPackages.forEach((p) => p && this.shell.addCommand(p.installCommand));

this.refreshEnvironment();

if (selectedPackages.some((p) => p && p.packageName.startsWith('Python'))) {
if (os.platform() === 'win32') {
this.shell.addEnvironment('$HOME\\AppData\\Roaming\\Python\\Scripts');
Expand All @@ -72,12 +68,11 @@ class SetupManager {
if (selectedPackages.some((p) => p && p.packageName.startsWith('Node.js'))) {
if (os.platform() === 'linux' && fs.existsSync('/etc/os-release')) {
const data = fs.readFileSync('/etc/os-release', 'utf8');
if (/VERSION_ID="20\.\d+"|VERSION_ID="2[1-9]\.\d+"/.test(data) || /PRETTY_NAME="Ubuntu 20\.\d+.*"|PRETTY_NAME="Ubuntu 2[1-9]\.\d+.*"/.test(data)) {
console.log('Ubuntu 20.04 detected');
this.shell.addCommand('asdf install nodejs 18.18.0');
this.shell.addCommand('asdf global nodejs 18.18.0');
} else {
console.log('Ubuntu 20.04 not detected');
const isUbuntuVersion2X = /VERSION_ID="20\.\d+"|VERSION_ID="2[1-9]\.\d+"/.test(data) || /PRETTY_NAME="Ubuntu 20\.\d+.*"|PRETTY_NAME="Ubuntu 2[1-9]\.\d+.*"/.test(data);
if (!isUbuntuVersion2X) {
console.log('Ubuntu 2x.xx not detected');
this.shell.addCommand('asdf install nodejs 16.20.2');
this.shell.addCommand('asdf global nodejs 16.20.2');
}
}
this.refreshEnvironment();
Expand All @@ -87,6 +82,10 @@ class SetupManager {
this.refreshEnvironment();
}

selectedPackages.forEach((p) => p && this.shell.addCommand(p.installCommand));

this.refreshEnvironment();

if (os.platform() === 'win32' && selectedPackages.some((p) => p && p.packageName.startsWith('Sublime Text'))) {
this.shell.addCommand(fs.readFileSync(path.join(__dirname, 'scripts/windows/SublimeSetup.ps1'), 'utf8').trim().replace('${PATH}', path.join(__dirname, 'scripts/windows/Preferences.sublime-settings')));
this.shell.addCommand('refreshenv\n');
Expand Down

0 comments on commit 71e0a5b

Please sign in to comment.