[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/rubocop 02ad056 35/64: [Fix #17] Consider rubocop installe
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/rubocop 02ad056 35/64: [Fix #17] Consider rubocop installed if bundled |
Date: |
Wed, 11 Aug 2021 10:08:00 -0400 (EDT) |
branch: elpa/rubocop
commit 02ad0561205ba10c6a1957c7e180667ab24e095d
Author: Tim Wade <imtayadeway@users.noreply.github.com>
Commit: Bozhidar Batsov <bozhidar.batsov@gmail.com>
[Fix #17] Consider rubocop installed if bundled
For those that vendorize their gems, the rubocop binary may not be on
the exec path, even if it has been bundled. For such users, their check
command will need to be `bundle exec rubocop` instead. This change will
allow rubocop-emacs to proceed with using the bundled rubocop if rubocop
is not found on the exec path.
---
rubocop.el | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/rubocop.el b/rubocop.el
index 0de6687..a1d224d 100644
--- a/rubocop.el
+++ b/rubocop.el
@@ -79,6 +79,10 @@ The current directory is assumed to be the project's root
otherwise."
"Generate a name for the RuboCop buffer from FILE-OR-DIR."
(concat "*RuboCop " file-or-dir "*"))
+(defun rubocop-build-command (command path)
+ "Compose the full command to be run, prefixing with `bundle exec` if rubocop
is bundled"
+ (concat (if (rubocop-bundled-p) "bundle exec " "") command " " path))
+
(defun rubocop--dir-command (command &optional directory)
"Run COMMAND on DIRECTORY (if present).
Alternatively prompt user for directory."
@@ -87,7 +91,7 @@ Alternatively prompt user for directory."
(or directory
(read-directory-name "Select directory:"))))
(compilation-start
- (concat command " " (rubocop-local-file-name directory))
+ (rubocop-build-command command (rubocop-local-file-name directory))
'compilation-mode
(lambda (arg) (message arg) (rubocop-buffer-name directory)))))
@@ -123,7 +127,7 @@ Alternatively prompt user for directory."
(let ((file-name (buffer-file-name (current-buffer))))
(if file-name
(compilation-start
- (concat command " " (rubocop-local-file-name file-name))
+ (rubocop-build-command command (rubocop-local-file-name file-name))
'compilation-mode
(lambda (_arg) (rubocop-buffer-name file-name)))
(error "Buffer is not visiting a file"))))
@@ -140,9 +144,17 @@ Alternatively prompt user for directory."
(interactive)
(rubocop--file-command rubocop-autocorrect-command))
+(defun rubocop-bundled-p ()
+ "Check if rubocop has been bundled."
+ (let ((gemfile-lock (expand-file-name "Gemfile.lock"
(rubocop-project-root))))
+ (when (file-exists-p gemfile-lock)
+ (with-temp-buffer
+ (insert-file-contents gemfile-lock)
+ (re-search-forward "rubocop" nil t)))))
+
(defun rubocop-ensure-installed ()
"Check if RuboCop is installed."
- (unless (executable-find "rubocop")
+ (unless (or (executable-find "rubocop") (rubocop-bundled-p))
(error "RuboCop is not installed")))
;;; Minor mode
- [nongnu] elpa/rubocop d4dad32 48/64: Add missing space, (continued)
- [nongnu] elpa/rubocop d4dad32 48/64: Add missing space, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop 080454e 54/64: Add a note about rubocop-keymap-prefix, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop 6c9c5a9 55/64: Add a bunch of commands for code formatting, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop f5fd18a 64/64: Add the ability to format on save, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop b0c5bc2 62/64: Tweak a heading, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop 608a3c1 58/64: Release 0.6.0, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop 0131536 39/64: Fix a docstring, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop 1372ee3 60/64: Tweak some wording, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop 2c884cd 25/64: Merge pull request #15 from fap-/load_tramp_dependency, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop f947fb0 30/64: Fix byte-compile warning about unused variable, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop 02ad056 35/64: [Fix #17] Consider rubocop installed if bundled,
ELPA Syncer <=
- [nongnu] elpa/rubocop 676cabe 36/64: Expand the project root path, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop a809fa7 42/64: [Fix #24] Always run RuboCop from the project's root when within a, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop 03bf155 52/64: Run auto-correct automatically on save (#29), ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop 38d982a 56/64: Add a note about alternative packages, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop d44737a 43/64: Fix a reference to RuboCop, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop 980bedb 49/64: Release 0.5, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop 8e9ec29 06/64: Update for RuboCop 0.9 (fixes #1), ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop dcde702 29/64: Improve the README a bit, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop 0ab1329 50/64: Update the README, ELPA Syncer, 2021/08/11
- [nongnu] elpa/rubocop 8b2c1f5 57/64: Remove mention of Prelude, ELPA Syncer, 2021/08/11