Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ Valid lang codes: sh, bash, zsh, fish... any shell that supports -c
echo "Hello, $name!"
```


## node (name)

> An example node script
Expand All @@ -313,7 +312,6 @@ const { name } = process.env;
console.log(`Hello, ${name}!`);
```


## python (name)

> An example python script
Expand All @@ -326,7 +324,6 @@ name = os.getenv("name", "WORLD")
print("Hello, " + name + "!")
```


## lua (name)

> An example lua script
Expand All @@ -336,7 +333,6 @@ name = os.getenv("name")
print("Hello, " .. name .. "!")
```


## ruby (name)

> An example ruby script
Expand All @@ -348,7 +344,6 @@ name = ENV["name"] || "WORLD"
puts "Hello, #{name}!"
```


## php (name)

> An example php script
Expand All @@ -357,6 +352,16 @@ puts "Hello, #{name}!"
$name = getenv("name") ?: "WORLD";
echo "Hello, " . $name . "!\n";
```

## swift (name)

> An example swift script

```swift
import Foundation
let name = ProcessInfo.processInfo.environment["name"] ?? "WORLD"
print("Hello, \(name)!")
```
````

#### Windows support
Expand Down
5 changes: 5 additions & 0 deletions mask/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ fn prepare_command(cmd: &Command) -> process::Command {
child.arg("-r").arg(source);
child
}
"swift" => {
let mut child = process::Command::new("swift");
child.arg("-e").arg(source);
child
}
#[cfg(windows)]
"cmd" | "batch" => {
let mut child = process::Command::new("cmd.exe");
Expand Down
23 changes: 23 additions & 0 deletions mask/tests/supported_runtimes_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,26 @@ echo "Hello, " . $name . "!\n";
.stdout(contains("Hello, World!"))
.success();
}

// GH Actions ubuntu-latest is the only runtime with Swift pre-installed.
#[cfg(target_os = "linux")]
#[test]
fn swift() {
let (_temp, maskfile_path) = common::maskfile(
r#"
## swift
~~~swift
import Foundation
let name = ProcessInfo.processInfo.environment["name"] ?? "WORLD"
print("Hello, \(name)!")
~~~
"#,
);

common::run_mask(&maskfile_path)
.command("swift")
.env("name", "World")
.assert()
.stdout(contains("Hello, World!"))
.success();
}
Loading