1
1
'use strict' ;
2
2
3
3
import * as path from 'path' ;
4
+ import * as fs from 'fs' ;
4
5
import { Uri , workspace , window , Disposable , ExtensionContext , commands , version , extensions } from 'vscode' ;
5
6
import {
6
7
LanguageClient ,
@@ -19,9 +20,8 @@ function createLangServer(context: ExtensionContext): LanguageClient {
19
20
const token = workspace . getConfiguration ( 'sourcery' ) . get < string > ( 'token' ) ;
20
21
const packageJson = extensions . getExtension ( 'sourcery.sourcery' ) . packageJSON ;
21
22
const extensionVersion = packageJson . version ;
22
- const sourceryVersion = packageJson . sourceryVersion ;
23
23
24
- const command = path . join ( __dirname , ".." , "binaries/sourcery- " + sourceryVersion + "-" + getOperatingSystem ( ) ) ;
24
+ const command = path . join ( __dirname , ".." , "sourcery_binaries/ " + getExecutablePath ( ) ) ;
25
25
26
26
const serverOptions : ServerOptions = {
27
27
command,
@@ -65,18 +65,32 @@ function createLangServer(context: ExtensionContext): LanguageClient {
65
65
}
66
66
67
67
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
+ }
73
80
} 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
+ }
76
89
}
77
90
}
78
91
79
92
93
+
80
94
export function activate ( context : ExtensionContext ) {
81
95
const languageClient = createLangServer ( context )
82
96
0 commit comments