Skip to content

Commit

Permalink
[INTERNAL] CLI Error Handling: Recommend ui5-tooling repository for c…
Browse files Browse the repository at this point in the history
…reating issue
  • Loading branch information
RandomByte committed Nov 19, 2020
1 parent 12b663e commit 3b9a01d
Showing 1 changed file with 6 additions and 26 deletions.
32 changes: 6 additions & 26 deletions lib/cli/commands/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,32 +47,12 @@ cli.usage("Usage: ui5 <command> [options]")
console.log("");
console.log(chalk.underline("Stack Trace:"));
console.log(err.stack);

// Try to guess responsible module from stack trace file paths
// This should work for the following paths:
// - @ui5/cli (npm consumption)
// - ui5-cli (local repository consumption)
// - lib/cli (local consumption without repository name in path, i.e. Azure CI)
const moduleRegExp = /@?(?:ui5|lib).(?:logger|fs|builder|server|project|cli)/ig;

// Only check the lowest stack entry
const rootStackEntry = err.stack.split("\n")[1];
const match = rootStackEntry.match(moduleRegExp);
if (match) {
// Use the last match of the line because of cases like this:
// node_modules/@ui5/cli/node_modules/@ui5/builder/lib/ => should match the builder
let moduleNameGuess = match[match.length - 1];

// Normalize match
moduleNameGuess = moduleNameGuess.replace(/.*(?:ui5|lib).(.*)/i, "ui5-$1").toLowerCase();
const newIssueUrl = `https://github.com/SAP/${moduleNameGuess}/issues/new`;
console.log("");
console.log(
chalk.dim(
`If you think this is an issue of the UI5 Tooling, you might report it using the ` +
`following URL: `) +
chalk.dim.bold.underline(newIssueUrl));
}
console.log("");
console.log(
chalk.dim(
`If you think this is an issue of the UI5 Tooling, you might report it using the ` +
`following URL:`) +
chalk.dim.bold.underline(`https://github.com/SAP/ui5-tooling/issues/new`));
} else {
console.log("");
console.log(chalk.dim(
Expand Down

0 comments on commit 3b9a01d

Please sign in to comment.