Browse Source

remove packages with -r

DanielFGray 1 year ago
parent
commit
b73b98fc42
1 changed files with 8 additions and 0 deletions
  1. 8
    0
      npmsearch

+ 8
- 0
npmsearch View File

@@ -64,6 +64,14 @@ fzf() {
64 64
   command fzf --inline-info --ansi --reverse +s --no-hscroll "$@"
65 65
 }
66 66
 
67
+if [[ $1 = '-r' || $1 = '--remove' ]]; then
68
+  mapfile -t rm < <(
69
+    jq -r '{dependencies, devDependencies} | .[] | keys | .[]' package.json |
70
+      fzf -m --cycle -e --reverse)
71
+    (( ${#rm} > 0 )) && $(select_from 'yarn remove' 'npm uninstall') "${rm[@]}"
72
+  die
73
+fi
74
+
67 75
 printf 'searching...\r'
68 76
 search=$(npm search --json "$*") || exit
69 77
 

Loading…
Cancel
Save