Skip to content

Commit b231731

Browse files
committed
refactor: normalize function API
1 parent ff9f65a commit b231731

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

crates/lua_fmt/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ use stylua_lib::{
66
use wasm_bindgen::prelude::wasm_bindgen;
77

88
#[wasm_bindgen]
9-
pub fn format(input: &str, config: Option<Config>) -> Result<String, String> {
9+
pub fn format(input: &str, filename: &str, config: Option<Config>) -> Result<String, String> {
10+
let _ = filename;
11+
1012
let config = config
1113
.map(|x| serde_wasm_bindgen::from_value::<LuaConfig>(x.clone()))
1214
.transpose()

crates/lua_fmt/test_bun/bun.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ for await (const input_path of walk(test_root)) {
4444
]);
4545

4646
test(test_name, () => {
47-
const actual = format(input);
47+
const actual = format(input, input_path);
4848
expect(actual).toBe(expected);
4949
});
5050
}

crates/lua_fmt/test_deno/deno.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ for await (const entry of walk(test_root, {
2121
const input = Deno.readTextFileSync(entry.path);
2222

2323
if (update) {
24-
const actual = format(input);
24+
const actual = format(input, entry.path);
2525
Deno.writeTextFileSync(entry.path + ".snap", actual);
2626
} else {
2727
const test_name = relative(test_root.pathname, entry.path);
2828
const expected = Deno.readTextFileSync(entry.path + ".snap");
2929

3030
Deno.test(test_name, () => {
31-
const actual = format(input);
31+
const actual = format(input, entry.path);
3232
assertEquals(actual, expected);
3333
});
3434
}

crates/lua_fmt/test_node/test-node.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ for await (const dirent of await fs.opendir(test_root, { recursive: true })) {
3636
]);
3737

3838
test(test_name, () => {
39-
const actual = format(input);
39+
const actual = format(input, input_path);
4040
assert.equal(actual, expected);
4141
});
4242
}

0 commit comments

Comments
 (0)