Skip to content

Commit

Permalink
fix: add better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
cecilia-sanare committed Aug 8, 2023
1 parent d957796 commit 4d70ae8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
4 changes: 3 additions & 1 deletion packages/core/@types/source-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export abstract class SourceModule {

await this.cleanup();
} catch (error) {
console.log(`Error detected, reverting to previous state...`);
console.log('Error detected, reverting to previous state...');

await Promise.all(
this.options.targets.map(async (target) => {
Expand All @@ -39,6 +39,8 @@ export abstract class SourceModule {
);

await this.revert();

throw error;
}
}

Expand Down
15 changes: 10 additions & 5 deletions packages/core/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
import { SourceModule } from './@types/source-module';

export async function Refreshly(...sources: SourceModule[]) {
await Promise.all(
sources.map(async (source) => {
await source.exec();
})
);
try {
await Promise.all(
sources.map(async (source) => {
await source.exec();
})
);
} catch (error) {
console.error(error);
process.exit(1);
}
}

// This is temporary
Expand Down

0 comments on commit 4d70ae8

Please sign in to comment.