summary refs log tree commit diff stats
diff options
context:
space:
mode:
-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 1ad0cb23..f837c836 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")