Skip to content

Commit 4f0227a

Browse files
committed
Use named parameters for extension installation scripts
- should use named params 'editor' 'lang' and 'tag' ├── apps │ └── editor │ └── src │ ├── commands │ │ ├── check-for-updates-command.ts │ │ └── install-specific-version-command.ts │ ├── utils │ │ └── update-extension.ts │ └── views │ └── prompt │ └── backend │ └── message-handlers │ └── handle-update-extension.ts ├── install.ps1 └── install.sh
1 parent 06eaed5 commit 4f0227a

3 files changed

Lines changed: 22 additions & 8 deletions

File tree

‎apps/editor/src/utils/update-extension.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ export const update_extension = (params: { tag_name: string }) => {
1010

1111
if (os.platform() === 'win32') {
1212
terminal.sendText(
13-
`powershell -c "& ([scriptblock]::Create((irm https://raw.githubusercontent.com/CodeWebChat/CWC/main/install.ps1))) '${uri_scheme}' '${lang}' '${params.tag_name}'"`
13+
`powershell -c "& ([scriptblock]::Create((irm https://raw.githubusercontent.com/CodeWebChat/CWC/main/install.ps1))) -editor '${uri_scheme}' -lang '${lang}' -tag '${params.tag_name}'"`
1414
)
1515
} else {
1616
terminal.sendText(
17-
`curl -fsSL https://raw.githubusercontent.com/CodeWebChat/CWC/main/install.sh | bash -s -- "${uri_scheme}" "${lang}" "${params.tag_name}"`
17+
`curl -fsSL https://raw.githubusercontent.com/CodeWebChat/CWC/main/install.sh | bash -s -- --editor "${uri_scheme}" --lang "${lang}" --tag "${params.tag_name}"`
1818
)
1919
}
2020
}

‎install.ps1‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1+
param(
2+
[string]$editor = "",
3+
[string]$lang = "en",
4+
[string]$tag = ""
5+
)
6+
17
$ErrorActionPreference = "Stop"
28
$ProgressPreference = "SilentlyContinue"
3-
$targetScheme = $args[0]
4-
$lang = $args[1]
5-
$tagName = $args[2]
9+
$targetScheme = $editor
10+
$tagName = $tag
611

712
$msg_error="Error:"
813
$msg_git_required="git is required but not installed."

‎install.sh‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
TARGET_SCHEME="$1"
5-
LANGUAGE="${2:-en}"
6-
TAG_NAME="$3"
4+
TARGET_SCHEME=""
5+
LANGUAGE="en"
6+
TAG_NAME=""
7+
8+
while [[ "$#" -gt 0 ]]; do
9+
case "$1" in
10+
--editor) TARGET_SCHEME="$2"; shift 2 ;;
11+
--lang) LANGUAGE="$2"; shift 2 ;;
12+
--tag) TAG_NAME="$2"; shift 2 ;;
13+
*) echo "Unknown parameter passed: $1"; exit 1 ;;
14+
esac
15+
done
716

817
msg_error="Error:"
918
msg_git_required="git is required but not installed."

0 commit comments

Comments
 (0)