0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 09:31:22 -05:00

feat: Add Deno.dir("executable") (#3526)

This commit is contained in:
Nayeem Rahman 2019-12-21 11:30:13 +00:00 committed by Ry Dahl
parent f4f4c6bcb4
commit f07ffe8980
4 changed files with 31 additions and 6 deletions

View file

@ -59,6 +59,7 @@ declare namespace Deno {
| "home"
| "cache"
| "config"
| "executable"
| "data"
| "data_local"
| "audio"
@ -77,9 +78,9 @@ declare namespace Deno {
* Returns null if there is no applicable directory or if any other error
* occurs.
*
* Argument values: "home", "cache", "config", "data", "data_local", "audio",
* "desktop", "document", "download", "font", "picture", "public", "template",
* "video"
* Argument values: "home", "cache", "config", "executable", "data",
* "data_local", "audio", "desktop", "document", "download", "font", "picture",
* "public", "template", "video"
*
* "cache"
* |Platform | Value | Example |
@ -95,6 +96,13 @@ declare namespace Deno {
* | macOS | `$HOME`/Library/Preferences | /Users/Alice/Library/Preferences |
* | Windows | `{FOLDERID_RoamingAppData}` | C:\Users\Alice\AppData\Roaming |
*
* "executable"
* |Platform | Value | Example |
* | ------- | --------------------------------------------------------------- | -----------------------|
* | Linux | `XDG_BIN_HOME` or `$XDG_DATA_HOME`/../bin or `$HOME`/.local/bin | /home/alice/.local/bin |
* | macOS | - | - |
* | Windows | - | - |
*
* "data"
* |Platform | Value | Example |
* | ------- | ---------------------------------------- | ---------------------------------------- |

View file

@ -133,6 +133,7 @@ type DirKind =
| "home"
| "cache"
| "config"
| "executable"
| "data"
| "data_local"
| "audio"
@ -151,9 +152,9 @@ type DirKind =
* Returns null if there is no applicable directory or if any other error
* occurs.
*
* Argument values: "home", "cache", "config", "data", "data_local", "audio",
* "desktop", "document", "download", "font", "picture", "public", "template",
* "video"
* Argument values: "home", "cache", "config", "executable", "data",
* "data_local", "audio", "desktop", "document", "download", "font", "picture",
* "public", "template", "video"
*
* "cache"
* |Platform | Value | Example |
@ -169,6 +170,13 @@ type DirKind =
* | macOS | `$HOME`/Library/Preferences | /Users/Alice/Library/Preferences |
* | Windows | `{FOLDERID_RoamingAppData}` | C:\Users\Alice\AppData\Roaming |
*
* "executable"
* |Platform | Value | Example |
* | ------- | --------------------------------------------------------------- | -----------------------|
* | Linux | `XDG_BIN_HOME` or `$XDG_DATA_HOME`/../bin or `$HOME`/.local/bin | /home/alice/.local/bin |
* | macOS | - | - |
* | Windows | - | - |
*
* "data"
* |Platform | Value | Example |
* | ------- | ---------------------------------------- | ---------------------------------------- |

View file

@ -146,6 +146,14 @@ testPerm({ env: true }, function getDir(): void {
{ os: "linux", shouldHaveValue: true }
]
},
{
kind: "executable",
runtime: [
{ os: "mac", shouldHaveValue: false },
{ os: "win", shouldHaveValue: false },
{ os: "linux", shouldHaveValue: true }
]
},
{
kind: "data",
runtime: [

View file

@ -75,6 +75,7 @@ fn op_get_dir(
"home" => dirs::home_dir(),
"config" => dirs::config_dir(),
"cache" => dirs::cache_dir(),
"executable" => dirs::executable_dir(),
"data" => dirs::data_dir(),
"data_local" => dirs::data_local_dir(),
"audio" => dirs::audio_dir(),