Skip to content

Commit

Permalink
refactor: normalize function API
Browse files Browse the repository at this point in the history
  • Loading branch information
magic-akari committed Mar 1, 2024
1 parent ff9f65a commit b231731
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion crates/lua_fmt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ use stylua_lib::{
use wasm_bindgen::prelude::wasm_bindgen;

#[wasm_bindgen]
pub fn format(input: &str, config: Option<Config>) -> Result<String, String> {
pub fn format(input: &str, filename: &str, config: Option<Config>) -> Result<String, String> {
let _ = filename;

let config = config
.map(|x| serde_wasm_bindgen::from_value::<LuaConfig>(x.clone()))
.transpose()
Expand Down
2 changes: 1 addition & 1 deletion crates/lua_fmt/test_bun/bun.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ for await (const input_path of walk(test_root)) {
]);

test(test_name, () => {
const actual = format(input);
const actual = format(input, input_path);
expect(actual).toBe(expected);
});
}
4 changes: 2 additions & 2 deletions crates/lua_fmt/test_deno/deno.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ for await (const entry of walk(test_root, {
const input = Deno.readTextFileSync(entry.path);

if (update) {
const actual = format(input);
const actual = format(input, entry.path);
Deno.writeTextFileSync(entry.path + ".snap", actual);
} else {
const test_name = relative(test_root.pathname, entry.path);
const expected = Deno.readTextFileSync(entry.path + ".snap");

Deno.test(test_name, () => {
const actual = format(input);
const actual = format(input, entry.path);
assertEquals(actual, expected);
});
}
Expand Down
2 changes: 1 addition & 1 deletion crates/lua_fmt/test_node/test-node.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ for await (const dirent of await fs.opendir(test_root, { recursive: true })) {
]);

test(test_name, () => {
const actual = format(input);
const actual = format(input, input_path);
assert.equal(actual, expected);
});
}

0 comments on commit b231731

Please sign in to comment.