88import { ensureDirSync , existsSync } from "fs/mod.ts" ;
99import { Confirm } from "cliffy/prompt/mod.ts" ;
1010import { Table } from "cliffy/table/mod.ts" ;
11- import { writeAllSync } from "streams/mod.ts" ;
1211import { basename , dirname , join } from "path/mod.ts" ;
1312
1413import { projectContext } from "../project/project-context.ts" ;
@@ -19,6 +18,7 @@ import { Extension, kExtensionDir } from "./extension-shared.ts";
1918import { withSpinner } from "../core/console.ts" ;
2019import { downloadWithProgress } from "../core/download.ts" ;
2120import { readExtensions } from "./extension.ts" ;
21+ import { info } from "log/mod.ts" ;
2222
2323export interface ExtensionSource {
2424 type : "remote" | "local" ;
@@ -73,10 +73,7 @@ export async function installExtension(
7373
7474// Cancels the installation, providing user feedback that the installation is canceled
7575function cancelInstallation ( ) {
76- writeAllSync (
77- Deno . stdout ,
78- new TextEncoder ( ) . encode ( "Installation canceled\n" ) ,
79- ) ;
76+ info ( "Installation canceled\n" ) ;
8077}
8178
8279// Determines whether the user trusts the extension
@@ -88,7 +85,7 @@ async function isTrusted(
8885 // Write the preamble
8986 const preamble =
9087 `\nQuarto extensions may execute code when documents are rendered. If you do not \ntrust the authors of the extension, we recommend that you do not install or \nuse the extension.\n\n` ;
91- writeAllSync ( Deno . stdout , new TextEncoder ( ) . encode ( preamble ) ) ;
88+ info ( preamble ) ;
9289
9390 // Ask for trust
9491 const question = "Do you trust the authors of this extension" ;
@@ -210,11 +207,7 @@ async function unzipAndStage(
210207// them to a destination directory
211208function readAndCopyExtensions ( extensionsDir : string , targetDir : string ) {
212209 const extensions = readExtensions ( extensionsDir ) ;
213-
214- writeAllSync (
215- Deno . stdout ,
216- new TextEncoder ( ) . encode ( ` Found ${ extensions . length } extensions.` ) ,
217- ) ;
210+ info ( ` Found ${ extensions . length } extensions.` ) ;
218211
219212 for ( const extension of extensions ) {
220213 copyTo (
@@ -395,33 +388,18 @@ async function confirmInstallation(
395388
396389 if ( extensionRows . length > 0 ) {
397390 const table = new Table ( ...extensionRows ) ;
398- writeAllSync (
399- Deno . stdout ,
400- new TextEncoder ( ) . encode (
401- `\nThe following changes will be made:\n${ table . toString ( ) } \n\n` ,
402- ) ,
403- ) ;
404-
391+ info ( `\nThe following changes will be made:\n${ table . toString ( ) } \n\n` ) ;
405392 const question = "Would you like to continue" ;
406393 return ! allowPrompt || await Confirm . prompt ( question ) ;
407394 } else {
408- writeAllSync (
409- Deno . stdout ,
410- new TextEncoder ( ) . encode (
411- `\nNo changes required - extensions already installed.\n\n` ,
412- ) ,
413- ) ;
395+ info ( `\nNo changes required - extensions already installed.\n\n` ) ;
414396 return true ;
415397 }
416398}
417399
418400// Copy the extension files into place
419401async function completeInstallation ( downloadDir : string , installDir : string ) {
420- writeAllSync (
421- Deno . stdout ,
422- new TextEncoder ( ) . encode ( "\n" ) ,
423- ) ;
424-
402+ info ( "\n" ) ;
425403 await withSpinner ( {
426404 message : `Copying` ,
427405 doneMessage : `Extension installation complete` ,
0 commit comments