@@ -19,7 +19,7 @@ import which from "which";
1919import semver from "semver" ;
2020
2121import * as minisign from "./minisign" ;
22- import { getVersion , getZigArchName , getZigOSName } from "./zigUtil" ;
22+ import { getHostZigName , getVersion , getZigArchName , getZigOSName } from "./zigUtil" ;
2323
2424const execFile = util . promisify ( childProcess . execFile ) ;
2525const chmod = util . promisify ( fs . chmod ) ;
@@ -68,7 +68,12 @@ export async function install(config: Config, version: semver.SemVer): Promise<s
6868
6969async function installGuarded ( config : Config , version : semver . SemVer ) : Promise < string > {
7070 const exeName = config . exeName + ( process . platform === "win32" ? ".exe" : "" ) ;
71- const subDirName = `${ getZigOSName ( ) } -${ getZigArchName ( ) } -${ version . raw } ` ;
71+ // With the release of Zig 0.14.1 the release scripts were updated to put the
72+ // architecture first as they are in target triples.
73+ const subDirName =
74+ config . exeName === "zig" && version . compare ( "0.14.0" ) === 1
75+ ? `${ getZigArchName ( ) } -${ getZigOSName ( ) } -${ version . raw } `
76+ : `${ getZigOSName ( ) } -${ getZigArchName ( ) } -${ version . raw } ` ;
7277 const exeUri = vscode . Uri . joinPath ( config . context . globalStorageUri , config . exeName , subDirName , exeName ) ;
7378
7479 await setLastAccessTime ( config , version ) ;
@@ -124,7 +129,7 @@ async function installFromMirror(
124129 const isWindows = process . platform === "win32" ;
125130 const fileExtension = isWindows ? "zip" : "tar.xz" ;
126131 const exeName = config . exeName + ( isWindows ? ".exe" : "" ) ;
127- const subDirName = `${ getZigOSName ( ) } - ${ getZigArchName ( ) } -${ version . raw } ` ;
132+ const subDirName = `${ getHostZigName ( ) } -${ version . raw } ` ;
128133 const fileName = `${ config . exeName } -${ subDirName } .${ fileExtension } ` ;
129134
130135 const installDir = vscode . Uri . joinPath ( config . context . globalStorageUri , config . exeName , subDirName ) ;
@@ -271,13 +276,23 @@ async function installFromMirror(
271276/** Returns all locally installed versions */
272277export async function query ( config : Config ) : Promise < semver . SemVer [ ] > {
273278 const available : semver . SemVer [ ] = [ ] ;
274- const prefix = `${ getZigOSName ( ) } -${ getZigArchName ( ) } ` ;
279+ const prefix = getHostZigName ( ) ;
280+
281+ // Remove after some time has passed from the prefix change.
282+ const prefixOld = `${ getZigOSName ( ) } -${ getZigArchName ( ) } ` ;
275283
276284 const storageDir = vscode . Uri . joinPath ( config . context . globalStorageUri , config . exeName ) ;
277285 try {
278286 for ( const [ name ] of await vscode . workspace . fs . readDirectory ( storageDir ) ) {
279287 if ( name . startsWith ( prefix ) ) {
280288 available . push ( new semver . SemVer ( name . substring ( prefix . length + 1 ) ) ) ;
289+ } else if ( name . startsWith ( prefixOld ) ) {
290+ const version = name . substring ( prefixOld . length + 1 ) ;
291+ await vscode . workspace . fs . rename (
292+ vscode . Uri . joinPath ( storageDir , name ) ,
293+ vscode . Uri . joinPath ( storageDir , `${ prefix } -${ version } ` ) ,
294+ ) ;
295+ available . push ( new semver . SemVer ( version ) ) ;
281296 }
282297 }
283298 } catch ( e ) {
@@ -293,7 +308,7 @@ export async function query(config: Config): Promise<semver.SemVer[]> {
293308/** Set the last access time of the (installed) version. */
294309async function setLastAccessTime ( config : Config , version : semver . SemVer ) : Promise < void > {
295310 await config . context . globalState . update (
296- `${ config . exeName } -last-access-time-${ getZigOSName ( ) } - ${ getZigArchName ( ) } -${ version . raw } ` ,
311+ `${ config . exeName } -last-access-time-${ getHostZigName ( ) } -${ version . raw } ` ,
297312 Date . now ( ) ,
298313 ) ;
299314}
0 commit comments