Skip to content

Commit

Permalink
Added an informative notice to the user when RuboCop could not be found.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsmecham committed Feb 22, 2020
1 parent 16cb264 commit fc47cc3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions RuboCop.novaextension/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## UNRELEASED

- Added an informative notice to the user when RuboCop could not be found.
- Restructured the project to allow for npm dependencies to be consumed.
- Added a new icon for the extension.
- Added documentation to the README.
Expand Down
27 changes: 26 additions & 1 deletion Source/Scripts/RuboCopProcess.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//

const Offense = require("./Offense");
var isUserNotifiedOfMissingCommand;

class RuboCopProcess {

Expand Down Expand Up @@ -46,7 +47,11 @@ class RuboCopProcess {
}

handleError(error) {
console.error(error);
if (error.match(/(no such file or directory|command not found)/i)) {
this.handleMissingCommand();
} else {
console.error(error);
}
}

handleOutput(output) {
Expand All @@ -62,6 +67,26 @@ class RuboCopProcess {
}
}

handleMissingCommand() {
if (isUserNotifiedOfMissingCommand) { return; }

const request = new NotificationRequest("rubocop-not-found");
request.title = nova.localize("RuboCop Not Found");
request.body = nova.localize("The \"rubocop\" command could not be found in your environment.");
request.actions = [nova.localize("OK"), nova.localize("More Information…")];

const notificationPromise = nova.notifications.add(request);
notificationPromise.then((response) => {
if (response.actionIdx === 1) { // More Information…
nova.openURL("https://github.com/jsmecham/nova-rubocop/wiki/Environment");
}
}).catch((error) => {
console.error(error);
}).finally(() => {
isUserNotifiedOfMissingCommand = true;
});
}

onComplete(callback) {
this._onCompleteCallback = callback;
}
Expand Down

0 comments on commit fc47cc3

Please sign in to comment.