@@ -7,7 +7,7 @@ import { makeCapTP } from '@agoric/captp/lib/captp';
7
7
import fs from 'fs' ;
8
8
import path from 'path' ;
9
9
10
- import buildSourceBundle from '@agoric/bundle-source' ;
10
+ import bundleSource from '@agoric/bundle-source' ;
11
11
12
12
const makePromise = ( ) => {
13
13
const pr = { } ;
@@ -27,27 +27,27 @@ const sendJSON = (ws, obj) => {
27
27
} ;
28
28
29
29
export default async function bundle ( insistIsBasedir , args ) {
30
- const { _ : a , evaluate, input, once, output, 'ag-solo' : agSolo } = parseArgs (
31
- args ,
32
- {
33
- boolean : [ 'once' , 'evaluate' , 'input' ] ,
34
- alias : { o : 'output' , e : 'evaluate' , i : 'input' } ,
35
- stopEarly : true ,
36
- } ,
37
- ) ;
30
+ const {
31
+ _ : a ,
32
+ evaluate : evflag ,
33
+ input,
34
+ once,
35
+ output,
36
+ 'ag-solo' : agSolo ,
37
+ } = parseArgs ( args , {
38
+ boolean : [ 'once' , 'evaluate' , 'input' ] ,
39
+ alias : { o : 'output' , e : 'evaluate' , i : 'input' } ,
40
+ stopEarly : true ,
41
+ } ) ;
38
42
39
- if ( ! output && ! evaluate ) {
40
- console . error (
41
- `You must specify at least one of '--output' or '--evaluate'` ,
42
- ) ;
43
- return 1 ;
44
- }
43
+ // Default to evaluate.
44
+ const evaluate = evflag || ! output ;
45
45
46
46
const bundles = [ ] ;
47
47
if ( input ) {
48
48
const fileNames = a ;
49
49
for ( const fileName of fileNames ) {
50
- const contents = file . promises . readFile ( fileName , 'utf-8' ) ;
50
+ const contents = fs . promises . readFile ( fileName , 'utf-8' ) ;
51
51
bundles . push ( JSON . parse ( contents ) ) ;
52
52
}
53
53
} else {
@@ -70,7 +70,8 @@ export default async function bundle(insistIsBasedir, args) {
70
70
}
71
71
const name = match [ 1 ] ;
72
72
const filepath = match [ 2 ] ;
73
- bundled [ name ] = await buildSourceBundle ( filepath ) ;
73
+ bundled [ name ] = await bundleSource ( filepath ) ;
74
+ bundled [ name ] . path = filepath ;
74
75
} ) ,
75
76
) ;
76
77
bundles . push ( bundled ) ;
@@ -145,7 +146,9 @@ export default async function bundle(insistIsBasedir, args) {
145
146
continue ;
146
147
}
147
148
148
- await main ( { bundle : bundled , home : boot } ) ;
149
+ const pathResolve = ( ...resArgs ) =>
150
+ path . resolve ( path . dirname ( bundled . main . path ) , ...resArgs ) ;
151
+ await main ( boot , { bundleSource, pathResolve } ) ;
149
152
}
150
153
console . error ( 'Done!' ) ;
151
154
if ( once ) {
0 commit comments