0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 17:34:47 -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" | "home"
| "cache" | "cache"
| "config" | "config"
| "executable"
| "data" | "data"
| "data_local" | "data_local"
| "audio" | "audio"
@ -77,9 +78,9 @@ declare namespace Deno {
* Returns null if there is no applicable directory or if any other error * Returns null if there is no applicable directory or if any other error
* occurs. * occurs.
* *
* Argument values: "home", "cache", "config", "data", "data_local", "audio", * Argument values: "home", "cache", "config", "executable", "data",
* "desktop", "document", "download", "font", "picture", "public", "template", * "data_local", "audio", "desktop", "document", "download", "font", "picture",
* "video" * "public", "template", "video"
* *
* "cache" * "cache"
* |Platform | Value | Example | * |Platform | Value | Example |
@ -95,6 +96,13 @@ declare namespace Deno {
* | macOS | `$HOME`/Library/Preferences | /Users/Alice/Library/Preferences | * | macOS | `$HOME`/Library/Preferences | /Users/Alice/Library/Preferences |
* | Windows | `{FOLDERID_RoamingAppData}` | C:\Users\Alice\AppData\Roaming | * | 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" * "data"
* |Platform | Value | Example | * |Platform | Value | Example |
* | ------- | ---------------------------------------- | ---------------------------------------- | * | ------- | ---------------------------------------- | ---------------------------------------- |

View file

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

View file

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

View file

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