diff options
author | Alan Pearce | 2017-10-05 14:32:31 +0200 |
---|---|---|
committer | Alan Pearce | 2017-10-05 14:32:31 +0200 |
commit | db81c0b127dd23c71ca498aad40764bd0cb63be3 (patch) | |
tree | a9591bc42f624294506e31360ef14de25f1b0d9b /emacs | |
parent | 691833dcc0e68729a63e28acd20e61f39f6407c0 (diff) | |
download | dotfiles-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.el | 25 |
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") |