Currently, the scripts are defined for all OS types. Meaning if you create a bash script, and you would use it for Windows and macOS, it might fail.
A better solution would be the ability to specify scripts per OS type so that you can define a PowerShell script for Windows and a bash script for macOS.
By adding the environments property with options for windows, macos, and linux, it would allow you to override the default script for a specific environment.
Currently, the scripts are defined for all OS types. Meaning if you create a bash script, and you would use it for Windows and macOS, it might fail.
A better solution would be the ability to specify scripts per OS type so that you can define a PowerShell script for Windows and a bash script for macOS.
### The current script configuration
```json
{
"$schema": "https://frontmatter.codes/config/custom.scripts.schema.json",
"title": "Create image folder",
"id": "create-image-folder",
"script": "./.frontmatter/config/custom/scripts/create-image-folder.sh",
"command": "bash"
}
```
### Proposed change:
```json
{
"$schema": "https://frontmatter.codes/config/custom.scripts.schema.json",
"title": "Create image folder",
"id": "create-image-folder",
"script": "./.frontmatter/config/custom/scripts/create-image-folder.sh",
"command": "bash",
"environments": [
{
"type": "windows"
"script": "./.frontmatter/config/custom/scripts/create-image-folder.ps1",
"command": "powershell"
}
]
}
```
By adding the `environments` property with options for `windows`, `macos`, and `linux`, it would allow you to override the default script for a specific environment.
<!-- github-sync-id:1493838277 -->
It might be worth being able to define a fallback or graceful error message, while we're thinking about cross-platform concerns. For example, both PowerShell and Python are available on Linux, macOS, and Windows, but not on all three by default.
I definitely like this though, extremely useful!
It might be worth being able to define a fallback or graceful error message, while we're thinking about cross-platform concerns. For example, both PowerShell and Python are available on Linux, macOS, and Windows, but not on all three _by default_.
I definitely like this though, extremely useful!
<!-- github-comment-id:1349624058 -->
@michaeltlombardi cross-platform is indeed difficult to know what is available on the user's device.
The fallback would be tricky. For instance, if the above PowerShell fails, the fallback could be Bash, but it might fail again. Although, it would already be better to check the two options than count on one. I will check if there is an easy way to validate if the command is available.
@michaeltlombardi cross-platform is indeed difficult to know what is available on the user's device.
The fallback would be tricky. For instance, if the above PowerShell fails, the fallback could be Bash, but it might fail again. Although, it would already be better to check the two options than count on one. I will check if there is an easy way to validate if the `command` is available.
<!-- github-comment-id:1350531095 -->
The easiest way might be to rummage in the PATH (or call which on not-windows, unless there's a helpful javascript function for looking up executables) and skip trying if there's no matching binary (checking for <name>\.\w+ on windows, since it could be a cmd or exe or whatever).
The easiest way might be to rummage in the `PATH` (or call `which` on not-windows, unless there's a helpful javascript function for looking up executables) and skip trying if there's no matching binary (checking for `<name>\.\w+` on windows, since it could be a cmd or exe or whatever).
<!-- github-comment-id:1351736465 -->
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Currently, the scripts are defined for all OS types. Meaning if you create a bash script, and you would use it for Windows and macOS, it might fail.
A better solution would be the ability to specify scripts per OS type so that you can define a PowerShell script for Windows and a bash script for macOS.
The current script configuration
Proposed change:
By adding the
environmentsproperty with options forwindows,macos, andlinux, it would allow you to override the default script for a specific environment.It might be worth being able to define a fallback or graceful error message, while we're thinking about cross-platform concerns. For example, both PowerShell and Python are available on Linux, macOS, and Windows, but not on all three by default.
I definitely like this though, extremely useful!
@michaeltlombardi cross-platform is indeed difficult to know what is available on the user's device.
The fallback would be tricky. For instance, if the above PowerShell fails, the fallback could be Bash, but it might fail again. Although, it would already be better to check the two options than count on one. I will check if there is an easy way to validate if the
commandis available.The easiest way might be to rummage in the
PATH(or callwhichon not-windows, unless there's a helpful javascript function for looking up executables) and skip trying if there's no matching binary (checking for<name>\.\w+on windows, since it could be a cmd or exe or whatever).