mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 04:01:58 +00:00
sdk comments
This commit is contained in:
@@ -1,5 +1,23 @@
|
||||
import { arrayOf, string } from "ts-matches"
|
||||
|
||||
/**
|
||||
* Normalizes a command into an array format suitable for execution.
|
||||
*
|
||||
* If the command is already an array, it's returned as-is.
|
||||
* If it's a string, it's wrapped in `sh -c` for shell interpretation.
|
||||
*
|
||||
* @param command - Command as string or array of strings
|
||||
* @returns Command as array suitable for process execution
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* splitCommand(['nginx', '-g', 'daemon off;'])
|
||||
* // Returns: ['nginx', '-g', 'daemon off;']
|
||||
*
|
||||
* splitCommand('nginx -g "daemon off;"')
|
||||
* // Returns: ['sh', '-c', 'nginx -g "daemon off;"']
|
||||
* ```
|
||||
*/
|
||||
export const splitCommand = (
|
||||
command: string | [string, ...string[]],
|
||||
): string[] => {
|
||||
|
||||
Reference in New Issue
Block a user