@@ -6,22 +6,20 @@ import process from "node:process";
6
6
* Cross-runtime compatible way to return the current executable path in a manner, regardless of Node, Deno or Bun.
7
7
*
8
8
* @returns {string } The current working directory path.
9
- * @throws
9
+ * @throws { Error } If the runtime executable cannot be found from the runtime.
10
10
* @example
11
11
* // import { execPath } from "@cross/utils";
12
12
*
13
13
* const currentExecPath = execPath();
14
14
* console.log("The path to the current runtime executable is :", currentExecPath);
15
15
*/
16
- export function execPath ( ) : Promise < string > {
16
+ export function execPath ( ) : string {
17
17
if ( CurrentRuntime === Runtime . Deno ) {
18
- //@ts -ignore cross-runtime
19
18
return Deno . execPath ( ) ;
20
19
} else if (
21
20
CurrentRuntime === Runtime . Node || CurrentRuntime === Runtime . Bun
22
21
) {
23
- //@ts -ignore cross-runtime
24
- return process . execPath ( ) ;
22
+ return process . execPath ;
25
23
} else {
26
24
throw new Error (
27
25
`Cannot determine execPath using current runtime ('${ CurrentRuntime } ').` ,
@@ -49,24 +47,21 @@ export async function resolvedExecPath(): Promise<string> {
49
47
if ( foundDeno !== null ) {
50
48
return foundDeno ;
51
49
} else {
52
- //@ts -ignore cross-runtime
53
50
return Deno . execPath ( ) ;
54
51
}
55
52
} else if ( CurrentRuntime === Runtime . Node ) {
56
53
const foundNode = await which ( "node" ) ;
57
54
if ( foundNode !== null ) {
58
55
return foundNode ;
59
56
} else {
60
- //@ts -ignore cross-runtime
61
- return process . execPath ( ) ;
57
+ return process . execPath ;
62
58
}
63
59
} else if ( CurrentRuntime === Runtime . Bun ) {
64
60
const foundBun = await which ( "bun" ) ;
65
61
if ( foundBun !== null ) {
66
62
return foundBun ;
67
63
} else {
68
- //@ts -ignore cross-runtime
69
- return process . execPath ( ) ;
64
+ return process . execPath ;
70
65
}
71
66
} else {
72
67
throw new Error (
0 commit comments