@@ -97,33 +97,35 @@ async function main() {
97
97
if ( importMapFile ) {
98
98
const importMap = await loadImportMap ( importMapFile )
99
99
let updateImportMaps : boolean | null = null
100
- let verison : string | null = null
100
+ let verison = VERSION
101
101
for ( const key in importMap . imports ) {
102
102
const url = importMap . imports [ key ]
103
103
if ( / \/ \/ d e n o \. l a n d \/ x \/ a l e p h @ v ? \d + \. \d + \. \d + ( - [ a - z 0 - 9 \. ] + ) ? \/ / . test ( url ) ) {
104
104
const [ prefix , rest ] = util . splitBy ( url , '@' )
105
105
const [ ver , suffix ] = util . splitBy ( rest , '/' )
106
106
if ( ver !== 'v' + VERSION && updateImportMaps === null ) {
107
107
updateImportMaps = confirm ( `You are using a different version of Aleph.js, expect ${ ver } -> v${ bold ( VERSION ) } , update '${ basename ( importMapFile ) } '?` )
108
+ if ( ! updateImportMaps ) {
109
+ verison = ver . slice ( 1 )
110
+ }
108
111
}
109
112
if ( updateImportMaps ) {
110
113
importMap . imports [ key ] = `${ prefix } @v${ VERSION } /${ suffix } `
111
- } else if ( verison === null ) {
112
- verison = ver
113
114
}
114
115
}
115
116
}
116
117
if ( updateImportMaps ) {
117
118
await Deno . writeTextFile ( importMapFile , JSON . stringify ( importMap , undefined , 2 ) )
118
119
}
119
- await run ( command , verison || undefined , importMapFile )
120
+ await run ( command , verison , importMapFile )
121
+ return
120
122
}
121
123
122
124
// run the command without import maps
123
- await run ( command )
125
+ await run ( command , VERSION )
124
126
}
125
127
126
- async function run ( name : string , version ? : string , importMap ?: string ) {
128
+ async function run ( name : string , version : string , importMap ?: string ) {
127
129
const cmd : string [ ] = [
128
130
Deno . execPath ( ) ,
129
131
'run' ,
@@ -135,20 +137,18 @@ async function run(name: string, version?: string, importMap?: string) {
135
137
if ( importMap ) {
136
138
cmd . push ( '--import-map' , importMap )
137
139
}
138
- if ( ! version || version === 'v' + VERSION ) {
140
+ if ( Deno . env . get ( 'ALEPH_DEV' ) && version === VERSION ) {
139
141
cmd . push ( `./commands/${ name } .ts` )
140
142
} else {
141
- cmd . push ( `https://deno.land/x/aleph@${ version } /commands/${ name } .ts` )
143
+ cmd . push ( `https://deno.land/x/aleph@v ${ version } /commands/${ name } .ts` )
142
144
}
143
145
cmd . push ( ...Deno . args . slice ( 1 ) )
144
- console . log ( cmd . join ( ' ' ) )
145
146
const p = Deno . run ( {
146
147
cmd,
147
148
stdout : 'inherit' ,
148
149
stderr : 'inherit'
149
150
} )
150
151
const c = await p . status ( )
151
- console . log ( c )
152
152
p . close ( )
153
153
}
154
154
0 commit comments