Skip to content

Commit 49abb87

Browse files
committed
fix: add arch to the folder name
use process.cwd
1 parent d6bfe0c commit 49abb87

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ Note that you will also need to add various entries to the `providedServices` an
8585

8686
### Minimal example (General LSP exe)
8787

88-
If the LSP is a general executable (not a JavaScript file), you should use `spawn` inside `startServerProcess`.
89-
90-
`getExePath` is a cross-platform utility function to get the exe path for the given exe name (under the `bin` folder by default).
88+
If the LSP is a general executable (not a JavaScript file), you should use `spawn` inside `startServerProcess`. `getExePath` is a cross-platform utility function to get the exe path for the given exe name (under the `bin/platform-arch/exeName` by default).
9189

9290
```javascript
9391
const {AutoLanguageClient, getExePath} = require('atom-languageclient')

lib/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ export function promiseWithTimeout<T>(ms: number, promise: Promise<T>): Promise<
114114
}
115115

116116

117-
/** Finds an exe file in the package assuming it is placed under `rootPath/platform/exe`
118-
* For example on Windows, if the `exeName` is `serve-d`, it returns the absolute path to `bin/win32/exeName.exe`
117+
/** Finds an exe file in the package assuming it is placed under `rootPath/platform-arch/exe`
118+
* For example on Windows x64, if the `exeName` is `serve-d`, it returns the absolute path to `./bin/win32-x64/exeName.exe`
119119
* @param exeName name of the exe file
120120
* @param rootPath the path of the folder of the exe file. Defaults to 'bin'
121121
* @param exeExtention the extention of the exe file. Defaults to `process.platform === "win32" ? ".exe" : ""`
@@ -125,5 +125,5 @@ export function getExePath(
125125
rootPath = "bin",
126126
exeExtention = process.platform === "win32" ? ".exe" : ""
127127
): string {
128-
return resolve(join(rootPath, process.platform, `${exeName}${exeExtention}`));
128+
return resolve(join(rootPath, `${process.platform}-${process.arch}`, `${exeName}${exeExtention}`));
129129
}

test/utils.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as Utils from '../lib/utils';
22
import { createFakeEditor } from './helpers';
33
import { expect } from 'chai';
44
import { Point } from 'atom';
5-
import { join, dirname } from 'path'
5+
import { join } from 'path'
66

77
describe('Utils', () => {
88
describe('getWordAtPosition', () => {
@@ -35,15 +35,15 @@ describe('Utils', () => {
3535
describe('getExePath', () => {
3636
it('returns the exe path under bin folder by default', () => {
3737
const exePath = Utils.getExePath('serve-d');
38-
let expectedExe = join(dirname(dirname(__dirname)), 'bin', process.platform, 'serve-d');
38+
let expectedExe = join(process.cwd(), 'bin', `${process.platform}-${process.arch}`, 'serve-d');
3939
if (process.platform === 'win32') {
4040
expectedExe = expectedExe + '.exe';
4141
}
4242
expect(exePath).eq(expectedExe);
4343
})
4444
it('returns the exe path for the given root', () => {
4545
const exePath = Utils.getExePath('serve-d', __dirname);
46-
let expectedExe = join(__dirname, process.platform, 'serve-d');
46+
let expectedExe = join(__dirname, `${process.platform}-${process.arch}`, 'serve-d');
4747
if (process.platform === 'win32') {
4848
expectedExe = expectedExe + '.exe';
4949
}

0 commit comments

Comments
 (0)