Skip to content

Commit cde409c

Browse files
authored
Rust Renderer: Add toolchain arg to formatter (#56)
* add toolchain arg to Rust renderer formatter * add changeset * update to use string for custom toolchains
1 parent b08a8f4 commit cde409c

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

.changeset/little-planes-poke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@kinobi-so/renderers-rust': patch
3+
---
4+
5+
Rust Renderer: Add toolchain arg to formatter

packages/renderers-rust/src/renderVisitor.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export type RenderOptions = GetRenderMapOptions & {
99
crateFolder?: string;
1010
deleteFolderBeforeRendering?: boolean;
1111
formatCode?: boolean;
12+
toolchain?: string;
1213
};
1314

1415
export function renderVisitor(path: string, options: RenderOptions = {}) {
@@ -24,7 +25,8 @@ export function renderVisitor(path: string, options: RenderOptions = {}) {
2425
// format the code
2526
if (options.formatCode) {
2627
if (options.crateFolder) {
27-
runFormatter('cargo-fmt', ['--manifest-path', `${options.crateFolder}/Cargo.toml`]);
28+
const toolchain = options.toolchain ?? '+stable';
29+
runFormatter('cargo', [toolchain, 'fmt', '--manifest-path', `${options.crateFolder}/Cargo.toml`]);
2830
} else {
2931
logWarn('No crate folder specified, skipping formatting.');
3032
}

0 commit comments

Comments
 (0)