Skip to content

Commit 7bb14c1

Browse files
committed
upgrade to 0.9.0 and change directory structure
1 parent 44ee65b commit 7bb14c1

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
"url": "https://github.com/sourcery-ai/public/issues"
99
},
1010
"license": "MIT",
11-
"version": "0.8.8",
12-
"sourceryVersion": "0.8.8",
11+
"version": "0.9.0",
1312
"publisher": "sourcery",
1413
"icon": "sourcery-icon.png",
1514
"keywords": [

src/extension.ts

+23-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
import * as path from 'path';
4+
import * as fs from 'fs';
45
import {Uri, workspace, window, Disposable, ExtensionContext, commands, version, extensions} from 'vscode';
56
import {
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+
8094
export function activate(context: ExtensionContext) {
8195
const languageClient = createLangServer(context)
8296

0 commit comments

Comments
 (0)