File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import * as vscode from 'vscode'
22import * as os from 'os'
33
4- export const update_extension = ( params : { tag_name : string } ) => {
4+ export const update_extension = async ( params : { tag_name : string } ) => {
55 const terminal = vscode . window . createTerminal ( 'CWC Updater' )
66 terminal . show ( )
77
88 const uri_scheme = vscode . env . uriScheme
99 const lang = vscode . env . language
1010
11- if ( os . platform ( ) === 'win32' ) {
12- terminal . sendText (
13- `powershell -c "& ([scriptblock]::Create((irm https://github.com/CodeWebChat/CWC/raw/refs/heads/main/install.ps1))) -editor '${ uri_scheme } ' -lang '${ lang } ' -tag '${ params . tag_name } '"`
14- )
15- } else {
16- terminal . sendText (
17- `curl -fsSL https://github.com/CodeWebChat/CWC/raw/refs/heads/main/install.sh | bash -s -- --editor "${ uri_scheme } " --lang "${ lang } " --tag "${ params . tag_name } "`
18- )
19- }
11+ const command =
12+ os . platform ( ) === 'win32'
13+ ? `powershell -c "& ([scriptblock]::Create((irm https://github.com/CodeWebChat/CWC/raw/refs/heads/main/install.ps1))) -editor '${ uri_scheme } ' -lang '${ lang } ' -tag '${ params . tag_name } '"; exit $LASTEXITCODE`
14+ : `curl -fsSL https://github.com/CodeWebChat/CWC/raw/refs/heads/main/install.sh | bash -s -- --editor "${ uri_scheme } " --lang "${ lang } " --tag "${ params . tag_name } " && exit`
15+
16+ const terminal_closed = new Promise < vscode . TerminalExitStatus | undefined > (
17+ ( resolve ) => {
18+ const disposable = vscode . window . onDidCloseTerminal ( ( t ) => {
19+ if ( t === terminal ) {
20+ disposable . dispose ( )
21+ resolve ( t . exitStatus )
22+ }
23+ } )
24+ }
25+ )
26+
27+ terminal . sendText ( command )
28+
29+ await terminal_closed
30+ vscode . commands . executeCommand ( 'workbench.action.reloadWindow' )
2031}
You can’t perform that action at this time.
0 commit comments