Skip to content

Commit 1a424fe

Browse files
committedSep 9, 2024·
Fix bug in execpath.ts
1 parent e92c3c6 commit 1a424fe

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed
 

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ functionality:
166166
table(myData);
167167
```
168168

169-
- **execPath(): Promise<string>**
169+
- **execPath(): string**
170170
- Returns the actual path to the current runtime executable.
171171
- **Examples:**
172172
```javascript

‎utils/execpath.ts

+5-10
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,20 @@ import process from "node:process";
66
* Cross-runtime compatible way to return the current executable path in a manner, regardless of Node, Deno or Bun.
77
*
88
* @returns {string} The current working directory path.
9-
* @throws
9+
* @throws {Error} If the runtime executable cannot be found from the runtime.
1010
* @example
1111
* // import { execPath } from "@cross/utils";
1212
*
1313
* const currentExecPath = execPath();
1414
* console.log("The path to the current runtime executable is :", currentExecPath);
1515
*/
16-
export function execPath(): Promise<string> {
16+
export function execPath(): string {
1717
if (CurrentRuntime === Runtime.Deno) {
18-
//@ts-ignore cross-runtime
1918
return Deno.execPath();
2019
} else if (
2120
CurrentRuntime === Runtime.Node || CurrentRuntime === Runtime.Bun
2221
) {
23-
//@ts-ignore cross-runtime
24-
return process.execPath();
22+
return process.execPath;
2523
} else {
2624
throw new Error(
2725
`Cannot determine execPath using current runtime ('${CurrentRuntime}').`,
@@ -49,24 +47,21 @@ export async function resolvedExecPath(): Promise<string> {
4947
if (foundDeno !== null) {
5048
return foundDeno;
5149
} else {
52-
//@ts-ignore cross-runtime
5350
return Deno.execPath();
5451
}
5552
} else if (CurrentRuntime === Runtime.Node) {
5653
const foundNode = await which("node");
5754
if (foundNode !== null) {
5855
return foundNode;
5956
} else {
60-
//@ts-ignore cross-runtime
61-
return process.execPath();
57+
return process.execPath;
6258
}
6359
} else if (CurrentRuntime === Runtime.Bun) {
6460
const foundBun = await which("bun");
6561
if (foundBun !== null) {
6662
return foundBun;
6763
} else {
68-
//@ts-ignore cross-runtime
69-
return process.execPath();
64+
return process.execPath;
7065
}
7166
} else {
7267
throw new Error(

0 commit comments

Comments
 (0)
Please sign in to comment.