Enhancement: Allow script configuration for a specific OS environment/type #385

Closed
opened 2026-10-05 02:44:20 +02:00 by adam · 3 comments
Owner

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

{
  "$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:

{
  "$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.

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 -->
adam closed this issue 2026-10-05 02:44:20 +02:00
Author
Owner

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 -->
Author
Owner

@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 -->
Author
Owner

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 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/vscode-front-matter#385