44* Copyright (C) 2020-2022 Posit Software, PBC
55*
66*/
7+ import { execProcess } from "../../../src/core/process.ts" ;
78import { info } from "../../../src/deno_ral/log.ts" ;
89import { isWindows } from "../../../src/deno_ral/platform.ts" ;
910import { Configuration } from "../common/config.ts" ;
1011
12+ // TODO in we only use the bundler for quarto.ts
13+ // so we hardcode it in the new esbuild-based bundler
1114export async function bundle (
12- input : string ,
13- output : string ,
1415 configuration : Configuration ,
1516) {
1617 // Bundle source code
@@ -19,28 +20,23 @@ export async function bundle(
1920 if ( ! denoExecPath ) {
2021 throw Error ( "QUARTO_DENO is not defined" ) ;
2122 }
22- denoBundleCmd . push ( denoExecPath ) ;
23- denoBundleCmd . push ( "bundle" ) ;
24- denoBundleCmd . push ( "--no-check" ) ;
25- denoBundleCmd . push ( "--unstable-kv" ) ;
26- denoBundleCmd . push ( "--unstable-ffi" ) ;
27- denoBundleCmd . push (
28- "--importmap=" + configuration . importmap ,
29- ) ;
23+ denoBundleCmd . push ( "run" ) ;
24+ denoBundleCmd . push ( "--allow-all" ) ;
25+ denoBundleCmd . push ( "../tools/deno-esbuild-bundle.ts" ) ;
3026 /*
3127 denoBundleCmd.push("--log-level");
3228 denoBundleCmd.push("debug");
3329 */
30+ // denoBundleCmd.push(input);
31+ // denoBundleCmd.push(output);
3432
35- denoBundleCmd . push ( input ) ;
36- denoBundleCmd . push ( output ) ;
37-
38- const p = Deno . run ( {
39- cmd : denoBundleCmd ,
33+ const status = await execProcess ( {
34+ cmd : denoExecPath ,
35+ args : denoBundleCmd ,
36+ cwd : configuration . directoryInfo . src ,
4037 } ) ;
41- const status = await p . status ( ) ;
4238 if ( status . code !== 0 ) {
43- throw Error ( `Failure to bundle ${ input } ` ) ;
39+ throw Error ( `Failure to bundle src/quarto.ts ` ) ;
4440 }
4541}
4642
@@ -55,7 +51,6 @@ export async function compile(
5551 if ( ! denoExecPath ) {
5652 throw Error ( "QUARTO_DENO is not defined" ) ;
5753 }
58- denoBundleCmd . push ( denoExecPath ) ;
5954 denoBundleCmd . push ( "compile" ) ;
6055 denoBundleCmd . push ( "--unstable-kv" ) ;
6156 denoBundleCmd . push ( "--unstable-ffi" ) ;
@@ -68,15 +63,14 @@ export async function compile(
6863
6964 denoBundleCmd . push ( input ) ;
7065
71- const p = Deno . run ( {
72- cmd : denoBundleCmd ,
66+ const status = await execProcess ( {
67+ cmd : denoExecPath ,
68+ args : denoBundleCmd ,
7369 } ) ;
74- const status = await p . status ( ) ;
7570 if ( status . code !== 0 ) {
7671 throw Error ( `Failure to compile ${ input } ` ) ;
7772 }
7873}
79-
8074export async function install (
8175 input : string ,
8276 flags : string [ ] ,
@@ -87,7 +81,6 @@ export async function install(
8781 if ( ! denoExecPath ) {
8882 throw Error ( "QUARTO_DENO is not defined" ) ;
8983 }
90- denoBundleCmd . push ( denoExecPath ) ;
9184 denoBundleCmd . push ( "install" ) ;
9285 denoBundleCmd . push ( "--unstable-kv" ) ;
9386 denoBundleCmd . push ( "--unstable-ffi" ) ;
@@ -98,24 +91,19 @@ export async function install(
9891
9992 denoBundleCmd . push ( input ) ;
10093
101- const p = Deno . run ( {
102- cmd : denoBundleCmd ,
94+ const status = await execProcess ( {
95+ cmd : denoExecPath ,
96+ args : denoBundleCmd ,
10397 stdout : "piped" ,
10498 } ) ;
105- const status = await p . status ( ) ;
10699 if ( status . code !== 0 ) {
107100 throw Error ( `Failure to install ${ input } ` ) ;
108101 }
109- const output = await p . output ( ) ;
110-
111- if ( output ) {
112- // Try to read the installation path and return it
113- const outputTxt = new TextDecoder ( ) . decode ( output ) ;
114-
102+ if ( status . stdout ) {
115103 // Forward the output
116- info ( outputTxt ) ;
104+ info ( status . stdout ) ;
117105
118- const match = outputTxt . match ( / S u c c e s s f u l l y i n s t a l l e d .* \n ( .* ) / ) ;
106+ const match = status . stdout . match ( / S u c c e s s f u l l y i n s t a l l e d .* \n ( .* ) / ) ;
119107 if ( match ) {
120108 return match [ 1 ] ;
121109 }
0 commit comments