Skip to content

Commit

Permalink
feat: Add Deno.dir("executable") (denoland#3526)
Browse files Browse the repository at this point in the history
  • Loading branch information
nayeemrmn authored and ry committed Dec 21, 2019
1 parent f4f4c6b commit f07ffe8
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
14 changes: 11 additions & 3 deletions cli/js/lib.deno_runtime.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ declare namespace Deno {
| "home"
| "cache"
| "config"
| "executable"
| "data"
| "data_local"
| "audio"
Expand All @@ -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 |
Expand All @@ -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 |
* | ------- | ---------------------------------------- | ---------------------------------------- |
Expand Down
14 changes: 11 additions & 3 deletions cli/js/os.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ type DirKind =
| "home"
| "cache"
| "config"
| "executable"
| "data"
| "data_local"
| "audio"
Expand All @@ -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 |
Expand All @@ -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 |
* | ------- | ---------------------------------------- | ---------------------------------------- |
Expand Down
8 changes: 8 additions & 0 deletions cli/js/os_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [
Expand Down
1 change: 1 addition & 0 deletions cli/ops/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit f07ffe8

Please sign in to comment.