From 52b0b20c378977aba6b0f2d976cd930ba2c6947d Mon Sep 17 00:00:00 2001 From: Stanislav Lvovsky Date: Mon, 4 May 2020 15:33:33 +0300 Subject: [PATCH] forward environment errors (#250) * forward environment errors * Update .nycrc.json --- backend/.nycrc.json | 4 ++-- backend/package.json | 7 ++++--- backend/src/yeomanui.ts | 14 ++++++-------- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/backend/.nycrc.json b/backend/.nycrc.json index ea3e725c..7dd2d408 100644 --- a/backend/.nycrc.json +++ b/backend/.nycrc.json @@ -9,7 +9,7 @@ "report-dir": "./reports/coverage", "check-coverage": true, "branches": 81.8, - "lines": 87.3, + "lines": 87.1, "functions": 81.3, - "statements": 86.8 + "statements": 86.6 } diff --git a/backend/package.json b/backend/package.json index 769e72e9..5ea1c665 100644 --- a/backend/package.json +++ b/backend/package.json @@ -5,7 +5,7 @@ "license": "Apache 2.0", "description": "Provide rich user experience for Yeoman generators using VSCode extension or the browser", "repository": "https://github.com/SAP/yeoman-ui", - "version": "0.0.79", + "version": "0.0.80", "engines": { "vscode": "^1.39.2" }, @@ -13,6 +13,7 @@ "Other" ], "activationEvents": [ + "*", "onCommand:loadYeomanUI", "onWebviewPanel:yeomanui" ], @@ -105,7 +106,7 @@ "strip-ansi": "^6.0.0", "titleize": "^1.0.1", "ws": "^7.2.5", - "yeoman-environment": "2.8.0" + "yeoman-environment": "2.10.0" }, "devDependencies": { "@types/chai": "^4.2.9", @@ -117,7 +118,7 @@ "@types/object-hash": "^1.3.1", "@types/sinon": "^7.5.0", "@types/ws": "^6.0.3", - "@types/yeoman-environment": "^2.3.2", + "@types/yeoman-environment": "^2.3.3", "bufferutil": "^4.0.1", "chai": "^4.2.0", "copy-webpack-plugin": "^5.0.5", diff --git a/backend/src/yeomanui.ts b/backend/src/yeomanui.ts index 6bb7bf15..dc7b6de5 100644 --- a/backend/src/yeomanui.ts +++ b/backend/src/yeomanui.ts @@ -137,9 +137,8 @@ export class YeomanUI { const targetFolder = this.getCwd(); await fsextra.mkdirs(targetFolder); const dirsBefore = await this.getChildDirectories(targetFolder); - const env: Environment = Environment.createEnv(undefined, {}, this.youiAdapter); + const env: Environment = Environment.createEnv(undefined, {newErrorHandler: true}, this.youiAdapter); const meta: Environment.GeneratorMeta = this.getGenMetadata(generatorName); - // TODO: support sub-generators // @ts-ignore env.register(meta.resolved, meta.namespace, meta.packagePath); @@ -155,12 +154,11 @@ export class YeomanUI { this.promptCount = 0; this.gen = (gen as Generator); this.gen.destinationRoot(targetFolder); - /* Generator.run() returns promise. Sending a callback is deprecated: - https://yeoman.github.io/generator/Generator.html#run - ... but .d.ts hasn't been updated for a while: - https://www.npmjs.com/package/@types/yeoman-generator */ - this.gen.run(async (err) => { - if (!err) { + + env.run(generatorName, {}, async error => { + if (error) { + this.onGeneratorFailure(generatorName, error); + } else { const dirsAfter = await this.getChildDirectories(this.gen.destinationRoot()); this.onGeneratorSuccess(generatorName, dirsBefore, dirsAfter); }