@@ -47,25 +47,27 @@ export const getOutdatedVersion = async (devProxyExe: string): Promise<string> =
4747} ;
4848
4949export const isDevProxyRunning = async ( devProxyExe : string ) : Promise < boolean > => {
50- const platform = os . platform ( ) ;
51-
52- if ( platform === 'win32' ) {
53- const processId = await executeCommand ( `pwsh.exe -c "(Get-Process ${ devProxyExe } -ErrorAction SilentlyContinue).Id"` ) ;
54- return processId . trim ( ) !== '' ;
55- } ;
56- if ( platform === 'darwin' ) {
57- const processId = await executeCommand ( `$SHELL -c "ps -e -o pid=,comm= | awk \'\\$2==\"${ devProxyExe } \" {print \\$1}\'"` ) ;
58- return processId . trim ( ) !== '' ;
59- } ;
60- if ( platform === 'linux' ) {
61- const processId = await executeCommand ( `/bin/bash -c "ps -e -o pid=,comm= | awk \'\\$2==\"${ devProxyExe } \" {print \\$1}\'"` ) ;
62- return processId . trim ( ) !== '' ;
50+ try {
51+ // Get the API port from configuration
52+ const configuration = vscode . workspace . getConfiguration ( 'dev-proxy-toolkit' ) ;
53+ const apiPort = configuration . get ( 'apiPort' ) as number ;
54+
55+ // Try to connect to the Dev Proxy API on the configured port
56+ const response = await fetch ( `http://127.0.0.1:${ apiPort } /proxy` , {
57+ method : 'GET' ,
58+ signal : AbortSignal . timeout ( 2000 ) , // 2 second timeout
59+ } ) ;
60+
61+ // If we get any response (even an error), Dev Proxy is running
62+ return response . status >= 200 && response . status < 500 ;
63+ } catch ( error ) {
64+ // If the request fails (connection refused, timeout, etc.), Dev Proxy is not running
65+ return false ;
6366 }
64- return false ;
6567} ;
6668
6769export const getDevProxyExe = ( versionPreference : VersionPreference ) => {
6870 return versionPreference === VersionPreference . Stable
6971 ? VersionExeName . Stable
7072 : VersionExeName . Beta ;
71- } ;
73+ } ;
0 commit comments