Skip to content

Commit

Permalink
[cli] mops watch fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ZenVoich committed Oct 2, 2024
1 parent 20dfb99 commit 1761cfa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions cli/commands/watch/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export class Generator {

if (this.errorChecker.status === 'error') {
this.status = 'syntax-error';
onProgress();
return;
}

Expand Down
14 changes: 9 additions & 5 deletions cli/commands/watch/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ let ignore = [
];

export async function watch(options : {error : boolean, warning : boolean, test : boolean, generate : boolean, deploy : boolean}) {
options.error = Object.values(options).includes(true) ? options.error : true;
let hasOptions = Object.values(options).includes(true);
if (!hasOptions) {
options.warning = true;
}
options.error = true;

let rootDir = getRootDir();
let canisters = getMotokoCanisters();
Expand All @@ -41,11 +45,10 @@ export async function watch(options : {error : boolean, warning : boolean, test
generator.reset();

options.error && await errorChecker.run(print);
options.warning && await warningChecker.run(print);
options.test && await tester.run(print);
options.generate && await generator.run(print);
options.warning && warningChecker.run(print);
options.test && tester.run(print);
options.generate && generator.run(print);
// options.deploy && await deployer.run(print);
print();
}, 200);

let print = () => {
Expand All @@ -65,6 +68,7 @@ export async function watch(options : {error : boolean, warning : boolean, test
options.generate && statuses.push(generator.status);

if (statuses.every(status => status !== 'pending' && status !== 'running')) {
console.log(chalk.dim('-'.repeat(50)));
console.log(chalk.dim('Waiting for file changes...'));
console.log(chalk.dim(`Press ${chalk.bold('Ctrl+C')} to exit.`));
}
Expand Down

0 comments on commit 1761cfa

Please sign in to comment.