cmake-action/src/utils.ts
Alfi Maulana a5cd911f7b
test: strict TypeScript ESLint configuration (#744)
* test: enable strict TypeScript ESLint configuration

Signed-off-by: Alfi Maulana <alfi.maulana.f@gmail.com>

* test: convert ESLint configuration to TypeScript

Signed-off-by: Alfi Maulana <alfi.maulana.f@gmail.com>

---------

Signed-off-by: Alfi Maulana <alfi.maulana.f@gmail.com>
2025-06-23 11:08:47 +07:00

19 lines
609 B
TypeScript

const regex = /"([^"]*)"|'([^']*)'|`([^`]*)`|(\S+)/g;
/**
* Converts a space-separated string into a list of arguments.
*
* This function parses the provided string, which contains arguments separated by spaces and possibly enclosed in quotes, into a list of arguments.
*
* @param str - The space-separated string to parse.
* @returns A list of arguments.
*/
export function parse(str: string): string[] {
const args: string[] = [];
let match: RegExpExecArray | null;
while ((match = regex.exec(str)) !== null) {
args.push(match[1] || match[2] || match[3] || match[4]);
}
return args;
}