Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit e24c2e3

Browse files
committed
Fix cli
1 parent 1e84ab0 commit e24c2e3

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

cli.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,33 +97,35 @@ async function main() {
9797
if (importMapFile) {
9898
const importMap = await loadImportMap(importMapFile)
9999
let updateImportMaps: boolean | null = null
100-
let verison: string | null = null
100+
let verison = VERSION
101101
for (const key in importMap.imports) {
102102
const url = importMap.imports[key]
103103
if (/\/\/deno\.land\/x\/aleph@v?\d+\.\d+\.\d+(-[a-z0-9\.]+)?\//.test(url)) {
104104
const [prefix, rest] = util.splitBy(url, '@')
105105
const [ver, suffix] = util.splitBy(rest, '/')
106106
if (ver !== 'v' + VERSION && updateImportMaps === null) {
107107
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+
}
108111
}
109112
if (updateImportMaps) {
110113
importMap.imports[key] = `${prefix}@v${VERSION}/${suffix}`
111-
} else if (verison === null) {
112-
verison = ver
113114
}
114115
}
115116
}
116117
if (updateImportMaps) {
117118
await Deno.writeTextFile(importMapFile, JSON.stringify(importMap, undefined, 2))
118119
}
119-
await run(command, verison || undefined, importMapFile)
120+
await run(command, verison, importMapFile)
121+
return
120122
}
121123

122124
// run the command without import maps
123-
await run(command)
125+
await run(command, VERSION)
124126
}
125127

126-
async function run(name: string, version?: string, importMap?: string) {
128+
async function run(name: string, version: string, importMap?: string) {
127129
const cmd: string[] = [
128130
Deno.execPath(),
129131
'run',
@@ -135,20 +137,18 @@ async function run(name: string, version?: string, importMap?: string) {
135137
if (importMap) {
136138
cmd.push('--import-map', importMap)
137139
}
138-
if (!version || version === 'v' + VERSION) {
140+
if (Deno.env.get('ALEPH_DEV') && version === VERSION) {
139141
cmd.push(`./commands/${name}.ts`)
140142
} 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`)
142144
}
143145
cmd.push(...Deno.args.slice(1))
144-
console.log(cmd.join(' '))
145146
const p = Deno.run({
146147
cmd,
147148
stdout: 'inherit',
148149
stderr: 'inherit'
149150
})
150151
const c = await p.status()
151-
console.log(c)
152152
p.close()
153153
}
154154

0 commit comments

Comments
 (0)