Skip to content

Commit

Permalink
catch generator errors (#299)
Browse files Browse the repository at this point in the history
* catch generator errors

* Update .nycrc.json

* handle uncaught exception
  • Loading branch information
slavik-lvovsky authored Jun 9, 2020
1 parent 5423c0f commit 3cb5f87
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
8 changes: 4 additions & 4 deletions backend/.nycrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"temp-dir": "./reports/.nyc_output",
"report-dir": "./reports/coverage",
"check-coverage": true,
"branches": 79.8,
"lines": 86,
"functions": 80.3,
"statements": 85.6
"branches": 79,
"lines": 85,
"functions": 78,
"statements": 85
}
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "yeoman-ui",
"version": "1.0.12",
"version": "1.0.13",
"displayName": "Application Wizard",
"publisher": "SAPOS",
"author": {
Expand Down
15 changes: 10 additions & 5 deletions backend/src/yeomanui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,16 +190,21 @@ export class YeomanUI {
this.onGeneratorFailure(generatorName, error);
env.emit("error", error);
});

this.gen.on("error", error => {
this.onGeneratorFailure(generatorName, error);
});

process.on('uncaughtException', error => {
this.onGeneratorFailure(generatorName, error);
});

// we cannot use new async method, "await this.gen.run()", because generators based on older versions
// (for example: 2.0.5) of "yeoman-generator" do not support it
this.gen.run(async (error) => {
if (!this.errorThrown) {
if (error) {
this.onGeneratorFailure(generatorName, error);
} else {
if (!this.errorThrown && !error) {
const dirsAfter = await this.getChildDirectories(this.gen.destinationRoot());
this.onGeneratorSuccess(generatorName, dirsBefore, dirsAfter);
}
}
});
} catch (error) {
Expand Down

0 comments on commit 3cb5f87

Please sign in to comment.