Working on implementing the typescript target
This commit is contained in:
@ -45,7 +45,29 @@ impl CompileContext {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn write_file(&self, filename: &str, content: String) -> Result<()> {
|
||||
pub fn to_snake(name: &str) -> String {
|
||||
let mut result = String::new();
|
||||
let mut last_upper = false;
|
||||
for c in name.chars() {
|
||||
if c.is_uppercase() {
|
||||
if last_upper {
|
||||
result.push(c.to_ascii_lowercase());
|
||||
} else {
|
||||
if !result.is_empty() {
|
||||
result.push('_');
|
||||
}
|
||||
result.push(c.to_ascii_lowercase());
|
||||
}
|
||||
last_upper = true;
|
||||
} else {
|
||||
result.push(c);
|
||||
last_upper = false;
|
||||
}
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
pub fn write_file(&self, filename: &str, content: &str) -> Result<()> {
|
||||
let res_path = self.output_folder.clone().join(filename);
|
||||
let res_dir = res_path.parent().context("Path has no parent!")?;
|
||||
std::fs::create_dir_all(res_dir)?;
|
||||
|
Reference in New Issue
Block a user