@@ -34,7 +34,7 @@ export async function installExtension(
3434 temp : TempContext ,
3535 allowPrompt : boolean ,
3636 embed ?: string ,
37- ) {
37+ ) : Promise < boolean > {
3838 // Is this local or remote?
3939 const source = await extensionSource ( target ) ;
4040
@@ -43,68 +43,70 @@ export async function installExtension(
4343 info (
4444 `Extension not found in local or remote sources` ,
4545 ) ;
46- return ;
46+ return false ;
4747 }
4848
4949 // Does the user trust the extension?
5050 const trusted = await isTrusted ( source , allowPrompt ) ;
5151 if ( ! trusted ) {
5252 // Not trusted, cancel
5353 cancelInstallation ( ) ;
54- } else {
55- // Compute the installation directory
56- const currentDir = Deno . cwd ( ) ;
57- const installDir = await determineInstallDir (
58- currentDir ,
59- allowPrompt ,
60- embed ,
61- ) ;
54+ return false ;
55+ }
6256
63- // Stage the extension locally
64- const extensionDir = await stageExtension ( source , temp . createDir ( ) ) ;
57+ // Compute the installation directory
58+ const currentDir = Deno . cwd ( ) ;
59+ const installDir = await determineInstallDir (
60+ currentDir ,
61+ allowPrompt ,
62+ embed ,
63+ ) ;
6564
66- // Validate the extension in in the staging dir
67- const stagedExtensions = await validateExtension ( extensionDir ) ;
65+ // Stage the extension locally
66+ const extensionDir = await stageExtension ( source , temp . createDir ( ) ) ;
6867
69- // Confirm that the user would like to take this action
70- const confirmed = await confirmInstallation (
71- stagedExtensions ,
72- installDir ,
73- { allowPrompt } ,
74- ) ;
68+ // Validate the extension in in the staging dir
69+ const stagedExtensions = await validateExtension ( extensionDir ) ;
7570
76- if ( confirmed ) {
77- // Complete the installation
78- await completeInstallation ( extensionDir , installDir ) ;
71+ // Confirm that the user would like to take this action
72+ const confirmed = await confirmInstallation (
73+ stagedExtensions ,
74+ installDir ,
75+ { allowPrompt } ,
76+ ) ;
7977
80- await withSpinner (
81- { message : "Extension installation complete" } ,
82- ( ) => {
83- return Promise . resolve ( ) ;
84- } ,
85- ) ;
78+ if ( ! confirmed ) {
79+ // Not confirmed, cancel the installation
80+ cancelInstallation ( ) ;
81+ }
8682
87- if ( source . learnMoreUrl ) {
88- info ( "" ) ;
89- if ( allowPrompt ) {
90- const open = await Confirm . prompt ( {
91- message : "View documentation using default browser?" ,
92- default : true ,
93- } ) ;
94- if ( open ) {
95- await openUrl ( source . learnMoreUrl ) ;
96- }
97- } else {
98- info (
99- `\nLearn more about this extension at:\n${ source . learnMoreUrl } \n` ,
100- ) ;
101- }
83+ // Complete the installation
84+ await completeInstallation ( extensionDir , installDir ) ;
85+
86+ await withSpinner (
87+ { message : "Extension installation complete" } ,
88+ ( ) => {
89+ return Promise . resolve ( ) ;
90+ } ,
91+ ) ;
92+
93+ if ( source . learnMoreUrl ) {
94+ info ( "" ) ;
95+ if ( allowPrompt ) {
96+ const open = await Confirm . prompt ( {
97+ message : "View documentation using default browser?" ,
98+ default : true ,
99+ } ) ;
100+ if ( open ) {
101+ await openUrl ( source . learnMoreUrl ) ;
102102 }
103103 } else {
104- // Not confirmed, cancel the installation
105- cancelInstallation ( ) ;
104+ info (
105+ `\nLearn more about this extension at:\n${ source . learnMoreUrl } \n` ,
106+ ) ;
106107 }
107108 }
109+ return true ;
108110}
109111
110112// Cancels the installation, providing user feedback that the installation is canceled
0 commit comments