diff --git a/backend/parsers/windmill-parser-bash/src/lib.rs b/backend/parsers/windmill-parser-bash/src/lib.rs index e153c51041..662ce1fb61 100644 --- a/backend/parsers/windmill-parser-bash/src/lib.rs +++ b/backend/parsers/windmill-parser-bash/src/lib.rs @@ -88,6 +88,7 @@ fn parse_powershell_file(code: &str) -> anyhow::Result>> { "string" => Typ::Str(None), "int" | "long" => Typ::Int, "decimal" | "double" | "single" => Typ::Float, + "datetime" | "DateTime" => Typ::Datetime, _ => Typ::Str(None), }, default: default.clone(), diff --git a/backend/parsers/windmill-parser-wasm/tests/wasm.rs b/backend/parsers/windmill-parser-wasm/tests/wasm.rs index 3c6fd4d291..191e64655a 100644 --- a/backend/parsers/windmill-parser-wasm/tests/wasm.rs +++ b/backend/parsers/windmill-parser-wasm/tests/wasm.rs @@ -2,6 +2,7 @@ use serde_json::json; use wasm_bindgen_test::wasm_bindgen_test; use windmill_parser::{Arg, MainArgSignature, ObjectProperty, Typ}; use windmill_parser_ts::{parse_deno_signature, parse_expr_for_ids, parse_expr_for_imports}; +use windmill_parser_bash::{parse_powershell_sig}; #[wasm_bindgen_test] fn test_parse_deno_sig() -> anyhow::Result<()> { @@ -317,3 +318,79 @@ export type foo = number Ok(()) } + +#[wasm_bindgen_test] +fn test_parse_powershell_sig() -> anyhow::Result<()> { + let code = " +param($test_none, [string]$test_string [int]$test_int, [decimal]$test_decimal, [double]$test_double, [single]$test_single, [datetime]$test_datetime_lower, [DateTime]$test_datetime_upper) + +Write-Output 'Testing...' +"; + assert_eq!( + parse_powershell_sig(code)?, + MainArgSignature { + star_args: false, + star_kwargs: false, + args: vec![ + Arg { + otyp: None, + name: "test_none".to_string(), + typ: Typ::Str(None), + default: None, + has_default: false + }, + Arg { + otyp: None, + name: "test_string".to_string(), + typ: Typ::Str(None), + default: None, + has_default: false + }, + Arg { + otyp: None, + name: "test_int".to_string(), + typ: Typ::Int, + default: None, + has_default: false + }, + Arg { + otyp: None, + name: "test_decimal".to_string(), + typ: Typ::Float, + default: None, + has_default: false + }, + Arg { + otyp: None, + name: "test_double".to_string(), + typ: Typ::Float, + default: None, + has_default: false + }, + Arg { + otyp: None, + name: "test_single".to_string(), + typ: Typ::Float, + default: None, + has_default: false + }, + Arg { + otyp: None, + name: "test_datetime_lower".to_string(), + typ: Typ::Datetime, + default: None, + has_default: false + }, + Arg { + otyp: None, + name: "test_datetime_upper".to_string(), + typ: Typ::Datetime, + default: None, + has_default: false + } + ] + } + ); + + Ok(()) +}