Skip to content

Commit 09568e5

Browse files
committed
Go back to using declaration file. Fix indentation to tabs
1 parent aad7e71 commit 09568e5

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/commands/sync/codegen.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::collections::BTreeMap;
33
use std::path::Path;
44

55
pub struct GeneratorOptions {
6+
pub output_name: String,
67
pub style: CodegenStyle,
78
pub strip_extension: bool,
89
}
@@ -35,9 +36,9 @@ impl Generator {
3536
let data_value = self.build_data_value();
3637
let mut output = String::new();
3738

38-
output.push_str("export = ");
39+
output.push_str(&format!("declare const {}: ", self.options.output_name));
3940
self.serialize_value_typescript(&data_value, &mut output, 0);
40-
output.push(';');
41+
output.push_str(";\nexport = assets;\n");
4142

4243
output
4344
}
@@ -109,7 +110,7 @@ impl Generator {
109110
DataValue::Node(map) => {
110111
output.push_str("{\n");
111112

112-
let indent_str = " ".repeat(indent + 1);
113+
let indent_str = "\t".repeat(indent + 1);
113114

114115
for (i, (key, val)) in map.iter().enumerate() {
115116
output.push_str(&indent_str);
@@ -129,7 +130,7 @@ impl Generator {
129130
output.push('\n');
130131
}
131132

132-
output.push_str(&" ".repeat(indent));
133+
output.push_str(&"\t".repeat(indent));
133134
output.push('}');
134135
}
135136
}
@@ -144,7 +145,7 @@ impl Generator {
144145
DataValue::Node(map) => {
145146
output.push_str("{\n");
146147

147-
let indent_str = " ".repeat(indent + 1);
148+
let indent_str = "\t".repeat(indent + 1);
148149

149150
for (i, (key, val)) in map.iter().enumerate() {
150151
output.push_str(&indent_str);
@@ -165,7 +166,7 @@ impl Generator {
165166
output.push('\n');
166167
}
167168

168-
output.push_str(&" ".repeat(indent));
169+
output.push_str(&"\t".repeat(indent));
169170
output.push('}');
170171
}
171172
}

src/commands/sync/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ pub async fn sync(args: SyncArgs, existing_lockfile: LockFile) -> anyhow::Result
194194
GeneratorOptions {
195195
style: state.style,
196196
strip_extension: state.strip_extension,
197+
output_name: state.output_name.clone(),
197198
},
198199
);
199200

@@ -204,7 +205,7 @@ pub async fn sync(args: SyncArgs, existing_lockfile: LockFile) -> anyhow::Result
204205
.context("Failed to write output Luau file")?;
205206

206207
if state.typescript {
207-
let ts_filename = format!("{}.ts", state.output_name);
208+
let ts_filename = format!("{}.d.ts", state.output_name);
208209
let ts_output = generator.generate_typescript();
209210

210211
write(Path::new(&state.write_dir).join(ts_filename), ts_output)

0 commit comments

Comments
 (0)