Skip to content

Commit fb5a0ae

Browse files
output_basename for inputs (#164)
Implements a new `output_basename` field that specifies the basenames of the generated files. Defaults to the input name like before. I tried my best 🙏
1 parent 9dd33ac commit fb5a0ae

4 files changed

Lines changed: 15 additions & 1 deletion

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ output_path = "src/shared"
146146
- A glob pattern to match files to upload.
147147
- `output_path`: string
148148
- The directory path to output the generated code.
149+
- `output_basename`: string
150+
- The filename of the generated files. Defaults to the input's name.
149151
- `web`: map<string, [WebAsset](#webasset)>
150152
- A map of paths relative to the input path to existing assets on Roblox.
151153
- `bleed`: boolean (optional)

schema.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@
105105
"type": "boolean",
106106
"default": true
107107
},
108+
"output_basename": {
109+
"description": "The basename of the file to output the generated code",
110+
"type": [
111+
"string",
112+
"null"
113+
]
114+
},
108115
"output_path": {
109116
"description": "The directory path to output the generated code",
110117
"type": "string"

src/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ pub struct Input {
8686
/// The directory path to output the generated code
8787
pub output_path: PathBuf,
8888

89+
/// The basename of the file to output the generated code
90+
pub output_basename: Option<String>,
91+
8992
/// Enable alpha bleeding images. Keep in mind that changing this setting won't invalidate your lockfile or reupload your images
9093
#[serde(default = "default_true")]
9194
pub bleed: bool,

src/sync/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ pub async fn sync(args: SyncArgs, mp: MultiProgress) -> anyhow::Result<()> {
147147

148148
let output_path = config.project_dir.join(&input.output_path);
149149
fs::create_dir_all(&output_path).await?;
150-
fs::write(output_path.join(format!("{input_name}.{ext}")), code).await?;
150+
151+
let base_name = &input.output_basename.as_deref().unwrap_or(&input_name);
152+
fs::write(output_path.join(format!("{base_name}.{ext}")), code).await?;
151153
}
152154
}
153155

0 commit comments

Comments
 (0)