Skip to content

Commit 9746992

Browse files
committed
fix: add platform-arch to rootPath
1 parent 798ab56 commit 9746992

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

lib/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,13 @@ export function promiseWithTimeout<T>(ms: number, promise: Promise<T>): Promise<
117117
/** Finds an exe file in the package assuming it is placed under `rootPath/platform-arch/exe`
118118
* 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
120-
* @param rootPath the path of the folder of the exe file. Defaults to 'bin'
120+
* @param rootPath the path of the folder of the exe file. Defaults to 'join("bin", `${process.platform}-${process.arch}`)'
121121
* @param exeExtention the extention of the exe file. Defaults to `process.platform === "win32" ? ".exe" : ""`
122122
*/
123123
export function getExePath(
124124
exeName: string,
125-
rootPath = "bin",
125+
rootPath = join("bin", `${process.platform}-${process.arch}`),
126126
exeExtention = process.platform === "win32" ? ".exe" : ""
127127
): string {
128-
return resolve(join(rootPath, `${process.platform}-${process.arch}`, `${exeName}${exeExtention}`));
128+
return resolve(join(rootPath, `${exeName}${exeExtention}`));
129129
}

test/utils.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ describe('Utils', () => {
4242
expect(exePath).eq(expectedExe);
4343
})
4444
it('returns the exe path for the given root', () => {
45-
const exePath = Utils.getExePath('serve-d', __dirname);
46-
let expectedExe = join(__dirname, `${process.platform}-${process.arch}`, 'serve-d');
45+
const rootPath = join(__dirname, `${process.platform}-${process.arch}`);
46+
const exePath = Utils.getExePath('serve-d', rootPath);
47+
let expectedExe = join(rootPath, 'serve-d');
4748
if (process.platform === 'win32') {
4849
expectedExe = expectedExe + '.exe';
4950
}

0 commit comments

Comments
 (0)