1use crate::runners::CommandType;
5
6#[inline]
7pub fn set_args(
8 mut cmd: std::process::Command,
9 file_path: &std::path::Path,
10) -> std::process::Command {
11 cmd.arg("--verify");
12 cmd.arg(file_path);
13 cmd
14}
15
16pub const COMMANDS: [CommandType; 6] = [
17 CommandType::NodeModules("stylua"),
18 CommandType::Direct("stylua"),
19 CommandType::Npm("@johnnymorganz/stylua-bin"),
20 CommandType::Pnpm("@johnnymorganz/stylua-bin"),
21 CommandType::Bun("@johnnymorganz/stylua-bin"),
22 CommandType::Deno("@johnnymorganz/stylua-bin"),
23];
24
25pub const IS_STDIN: bool = false;
26
27#[cfg(test)]
28mod test_stylua {
29 #[test_with::executable(stylua || npx || pnpm || deno || bunx)]
30 fn test_stylua_lua_ab45775f0dc2fcca() {
31 let input = r#"
32
33 local function add ( a , b
34)
35
36return a +b
37
38
39end
40
41 "#;
42
43 let output = r#"local function add(a, b)
44 return a + b
45end
46"#;
47
48 let file_ext = crate::fttype::get_file_extension("lua");
49
50 let snippet =
51 crate::execution::setup_snippet(input, &file_ext).expect("it to create a snippet file");
52
53 let result = crate::tools::Tooling::Stylua
54 .format_snippet(
55 snippet.path(),
56 crate::testing::DEFAULT_TEST_FORMATTER_TIMEOUT,
57 crate::testing::DEFAULT_TEST_DEBUG_ENABLED,
58 &crate::config::MdsfConfigRunners::all(),
59 )
60 .expect("it to be successful")
61 .1
62 .expect("it to be some");
63
64 assert_eq!(result, output);
65 }
66}