11'use strict' ;
22
33import * as path from 'path' ;
4+ import * as fs from 'fs' ;
45import { Uri , workspace , window , Disposable , ExtensionContext , commands , version , extensions } from 'vscode' ;
56import {
67 LanguageClient ,
@@ -19,9 +20,8 @@ function createLangServer(context: ExtensionContext): LanguageClient {
1920 const token = workspace . getConfiguration ( 'sourcery' ) . get < string > ( 'token' ) ;
2021 const packageJson = extensions . getExtension ( 'sourcery.sourcery' ) . packageJSON ;
2122 const extensionVersion = packageJson . version ;
22- const sourceryVersion = packageJson . sourceryVersion ;
2323
24- const command = path . join ( __dirname , ".." , "binaries/sourcery- " + sourceryVersion + "-" + getOperatingSystem ( ) ) ;
24+ const command = path . join ( __dirname , ".." , "sourcery_binaries/ " + getExecutablePath ( ) ) ;
2525
2626 const serverOptions : ServerOptions = {
2727 command,
@@ -65,18 +65,32 @@ function createLangServer(context: ExtensionContext): LanguageClient {
6565}
6666
6767
68- function getOperatingSystem ( ) : string {
69- if ( process . platform == 'win32' ) {
70- return 'win/sourcery.exe'
71- } else if ( process . platform == 'darwin' ) {
72- return 'mac/sourcery'
68+
69+ function getExecutablePath ( ) : string {
70+ const activePath = path . join ( __dirname , ".." , "sourcery_binaries/active" ) ;
71+ if ( fs . existsSync ( activePath ) ) {
72+ if ( process . platform == 'win32' ) {
73+ return 'active/sourcery.exe'
74+ } else if ( process . platform == 'darwin' ) {
75+ return 'active/sourcery'
76+ } else {
77+ // Assume everything else is linux compatible
78+ return 'active/sourcery'
79+ }
7380 } else {
74- // Assume everything else is linux compatible
75- return 'linux/sourcery'
81+ if ( process . platform == 'win32' ) {
82+ return 'install/win/sourcery.exe'
83+ } else if ( process . platform == 'darwin' ) {
84+ return 'install/mac/sourcery'
85+ } else {
86+ // Assume everything else is linux compatible
87+ return 'install/linux/sourcery'
88+ }
7689 }
7790}
7891
7992
93+
8094export function activate ( context : ExtensionContext ) {
8195 const languageClient = createLangServer ( context )
8296
0 commit comments