Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/utils/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { NameApi } from './nameTransformers';
export type RenderOptions = GetRenderMapOptions & {
deleteFolderBeforeRendering?: boolean;
formatCode?: boolean;
generateBorsh?: boolean;
};

export type GetRenderMapOptions = {
Expand Down
24 changes: 22 additions & 2 deletions src/visitors/renderVisitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export function renderVisitor(path: string, options: RenderOptions) {

if (options.formatCode ?? true) {
try {
execSync(`dart format "${path}"`, {
cwd: process.cwd(),
execSync(`dart format .`, {
cwd: path,
stdio: 'ignore',
});
console.log('Dart formatting completed successfully.');
Expand All @@ -28,5 +28,25 @@ export function renderVisitor(path: string, options: RenderOptions) {
console.warn('You can manually format the code by running: dart format "' + path + '"');
}
}
if (options.generateBorsh ?? true) {
try {
execSync('dart pub get', {
cwd: path,
stdio: 'ignore',
});
execSync('dart run build_runner build', {
cwd: path,
stdio: 'ignore',
});
execSync('dart fix --apply', {
cwd: path,
stdio: 'ignore',
});
} catch (error) {
console.log(error);
console.warn('Warning: Failed to run Dart commands. Make sure Dart SDK is installed.');
console.warn(`You can manually run commands in ${path}: dart pub get && dart run build_runner build && dart fix --apply`);
}
}
});
}