Skip to content

Commit

Permalink
fix: clarigen --watch issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hstove committed May 17, 2024
1 parent d197d08 commit ee3a60f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/serious-chicken-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@clarigen/cli': patch
---

Fixes `clarigen --watch` by generating types automatically, and properly reloading the session when files change.
2 changes: 1 addition & 1 deletion packages/cli/src/clarinet-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { mapVariables } from './files/variables';
import { SessionContract, SessionWithVariables } from './session';

export async function getSession(config: Config): Promise<SessionWithVariables> {
const simnet = await initSimnet(config.clarinetFile());
const simnet = await initSimnet(config.clarinetFile(), true);
const interfaces = simnet.getContractsInterfaces();
const accounts = simnet.getAccounts();

Expand Down
4 changes: 3 additions & 1 deletion packages/cli/src/commands/default-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ export async function generate(config: Config) {

export async function watch(config: Config, cwd?: string) {
// const ora = await import('ora');
return new Promise((resolve, reject) => {
return new Promise(async (resolve, reject) => {
const clarinetFolder = dirname(config.clarinetFile());
const contractsFolder = join(clarinetFolder, '/contracts/**/*.clar');
// First, generate the types
await generate(config);
// const watchCwd = cwd || process.cwd();
const relativeFolder = relative(cwd || process.cwd(), contractsFolder);
logger.info(`Watching for changes in ${relativeFolder}`);
Expand Down

0 comments on commit ee3a60f

Please sign in to comment.