summary refs log tree commit diff stats
path: root/emacs
diff options
context:
space:
mode:
authorAlan Pearce2017-10-05 14:32:31 +0200
committerAlan Pearce2017-10-05 14:32:31 +0200
commitdb81c0b127dd23c71ca498aad40764bd0cb63be3 (patch)
treea9591bc42f624294506e31360ef14de25f1b0d9b /emacs
parent691833dcc0e68729a63e28acd20e61f39f6407c0 (diff)
downloaddotfiles-db81c0b127dd23c71ca498aad40764bd0cb63be3.tar.lz
dotfiles-db81c0b127dd23c71ca498aad40764bd0cb63be3.tar.zst
dotfiles-db81c0b127dd23c71ca498aad40764bd0cb63be3.zip
Emacs: Make yarn- commands DWIM w.r.t. yarn/npm
Diffstat (limited to 'emacs')
-rw-r--r--emacs/.emacs.d/main.el25
1 files changed, 20 insertions, 5 deletions
diff --git a/emacs/.emacs.d/main.el b/emacs/.emacs.d/main.el
index 1ad0cb2..f837c83 100644
--- a/emacs/.emacs.d/main.el
+++ b/emacs/.emacs.d/main.el
@@ -490,28 +490,43 @@
             (defun yarn-install (&optional arg)
               (interactive "P")
               (projectile-with-default-dir (projectile-project-root)
-                (cmd-to-echo "yarn" "install")))
+                (cond
+                 ((string-equal (projectile-project-type) "node-yarn")
+                  (cmd-to-echo "yarn" "install"))
+                 (t (cmd-to-echo "npm" "install")))))
 
             (defun yarn-add-dev (package)
               (interactive "spackage: ")
               (projectile-with-default-dir (projectile-project-root)
-                (cmd-to-echo "yarn" (concat "add --dev " package))))
+                (cond
+                 ((string-equal (projectile-project-type) "node-yarn")
+                  (cmd-to-echo "yarn" (concat "add --dev " package)))
+                 (t (cmd-to-echo "npm" (concat "install --save-dev " package))))))
 
             (defun yarn-add (package)
               (interactive "spackage: ")
               (projectile-with-default-dir (projectile-project-root)
-                (cmd-to-echo "yarn" (concat "add " package))))
+                (cond
+                 ((string-equal (projectile-project-type) "node-yarn")
+                  (cmd-to-echo "yarn" (concat "add " package)))
+                 (t (cmd-to-echo "npm" (concat "install --save " package))))))
 
             (defun yarn-remove (package)
               (interactive "spackage: ")
               (projectile-with-default-dir (projectile-project-root)
-                (cmd-to-echo "yarn" (concat "remove " package))))
+                (cond
+                 ((string-equal (projectile-project-type) "node-yarn")
+                  (cmd-to-echo "yarn" (concat "remove " package)))
+                 (t (cmd-to-echo "npm" (concat "remove " package))))))
 
             (defun yarn-run (cmd)
               (interactive (list
                             (projectile-completing-read "command: " (alist-get 'scripts (json-read-file (expand-file-name "package.json" (projectile-project-root)))))))
               (projectile-with-default-dir (projectile-project-root)
-                (cmd-to-echo "yarn" (concat "run " cmd))))
+                (cond
+                 ((string-equal (projectile-project-type) "node-yarn")
+                  (cmd-to-echo "yarn" (concat "run " cmd)))
+                 (t (cmd-to-echo "npm" (concat "run " cmd))))))
 
             (defun ap/open-project (&optional arg)
               (interactive "P")