@@ -19,6 +19,7 @@ import ../pystring/strimpl
19
19
const weirdTarget = defined(js) or defined(nimscript)
20
20
when defined(js):
21
21
import std/ jsffi
22
+ import ../ jsutils/ deno
22
23
when not weirdTarget:
23
24
const inFileSystemUtf8os = defined(macosx) or defined(android) or defined(vxworks)
24
25
when not inFileSystemUtf8os:
@@ -220,17 +221,30 @@ else:
220
221
when defined(nimscript):
221
222
template executable* : PyStr = str getCurrentCompilerExe()
222
223
elif defined(js):
223
- const execPathJs =
224
- when defined(nodejs): " process.execPath"
225
- else : " typeof Deno === 'undefined' ? '' : Deno.execPath()"
226
- let execPath{.importjs: execPathJs.}: cstring
227
- template executable* : PyStr =
228
- bind execPath
229
- str execPath
224
+ when defined(nodejs):
225
+ let execPath{.importjs: " process.execPath" .}: cstring
226
+ template executable* : PyStr =
227
+ bind execPath
228
+ str $ execPath
229
+ else :
230
+ func getExecPath: cstring =
231
+ # Deno.execPath() may ask permission,
232
+ # so we only invoke it when called
233
+ if inDeno:
234
+ asm " `result` = Deno.execPath()"
235
+ else : result = " "
236
+ template executable* : PyStr =
237
+ bind getExecPath
238
+ str $ getExecPath()
230
239
else :
231
240
template executable* : PyStr =
232
- # # .. note:: when nimscript, this is path of `Nim`;
233
- # # otherwise, it's the path of current app/exe.
241
+ # # returns:
242
+ # #
243
+ # # - when nimscript, path of `Nim`;
244
+ # # - when JavaScript:
245
+ # # - on browser: empty string
246
+ # # - on NodeJS/Deno: executable path of Node/Deno
247
+ # # - otherwise, it's the path of current app/exe.
234
248
str getAppFilename()
235
249
236
250
template getsizeof* (x): int =
0 commit comments