@@ -3,7 +3,7 @@ import path from "path";
33
44import * as vscode from "vscode" ;
55
6- import { VersionManager , ActivationResult } from "./versionManager" ;
6+ import { VersionManager , ActivationResult , DetectionResult } from "./versionManager" ;
77import { WorkspaceChannel } from "../workspaceChannel" ;
88import { pathToUri } from "../common" ;
99
@@ -36,28 +36,28 @@ export class Asdf extends VersionManager {
3636 static async detect (
3737 workspaceFolder : vscode . WorkspaceFolder ,
3838 outputChannel : WorkspaceChannel ,
39- ) : Promise < vscode . Uri | undefined > {
39+ ) : Promise < DetectionResult > {
4040 // Check for v0.16+ executables first
4141 const executablePaths = Asdf . getPossibleExecutablePaths ( ) ;
4242 const asdfExecPaths = executablePaths . map ( ( dir ) => vscode . Uri . joinPath ( dir , "asdf" ) ) ;
4343 const execResult = await VersionManager . findFirst ( asdfExecPaths ) ;
4444 if ( execResult ) {
45- return execResult ;
45+ return { type : "path" , uri : execResult } ;
4646 }
4747
4848 // Check for < v0.16 scripts
4949 const scriptResult = await VersionManager . findFirst ( Asdf . getPossibleScriptPaths ( ) ) ;
5050 if ( scriptResult ) {
51- return scriptResult ;
51+ return { type : "path" , uri : scriptResult } ;
5252 }
5353
5454 // check on PATH
5555 const toolExists = await VersionManager . toolExists ( "asdf" , workspaceFolder , outputChannel ) ;
5656 if ( toolExists ) {
57- return vscode . Uri . file ( " asdf") ;
57+ return { type : "semantic" , marker : " asdf" } ;
5858 }
5959
60- return undefined ;
60+ return { type : "none" } ;
6161 }
6262
6363 async activate ( ) : Promise < ActivationResult > {
@@ -68,9 +68,13 @@ export class Asdf extends VersionManager {
6868 if ( configuredPath ) {
6969 asdfUri = vscode . Uri . file ( configuredPath ) ;
7070 } else {
71- asdfUri = await Asdf . detect ( this . workspaceFolder , this . outputChannel ) ;
71+ const result = await Asdf . detect ( this . workspaceFolder , this . outputChannel ) ;
7272
73- if ( ! asdfUri ) {
73+ if ( result . type === "path" ) {
74+ asdfUri = result . uri ;
75+ } else if ( result . type === "semantic" ) {
76+ // Use ASDF from PATH
77+ } else {
7478 throw new Error (
7579 `Could not find ASDF installation. Searched in ${ [
7680 ...Asdf . getPossibleExecutablePaths ( ) ,
@@ -82,7 +86,7 @@ export class Asdf extends VersionManager {
8286
8387 let baseCommand : string ;
8488
85- if ( asdfUri . fsPath !== "/asdf" ) {
89+ if ( asdfUri ) {
8690 const asdfPath = asdfUri . fsPath ;
8791 // If there's no extension name, then we are using the ASDF executable directly. If there is an extension, then it's
8892 // a shell script and we have to source it first
0 commit comments